Compare commits
3 commits
81bec195f0
...
f8d0b85def
| Author | SHA1 | Date | |
|---|---|---|---|
| f8d0b85def | |||
| b3c09c6047 | |||
| 99dc53a79f |
4 changed files with 25 additions and 17 deletions
BIN
cad/Drive Wheel-2.SLDPRT
Normal file
BIN
cad/Drive Wheel-2.SLDPRT
Normal file
Binary file not shown.
|
|
@ -2,6 +2,7 @@
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <smartmotor.h>
|
#include <smartmotor.h>
|
||||||
#include <SMC_gains.h>
|
#include <SMC_gains.h>
|
||||||
|
#include "trapezoidal.h"
|
||||||
|
|
||||||
const float ACCEL_LIMIT = 4.0; // cm/s/s
|
const float ACCEL_LIMIT = 4.0; // cm/s/s
|
||||||
const float VEL_LIMIT = 16.0; // cm/s
|
const float VEL_LIMIT = 16.0; // cm/s
|
||||||
|
|
@ -91,7 +92,7 @@ void loop() {
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
|
|
||||||
// move on if at setpoint TODO: check that the error is low as well
|
// move on if at setpoint TODO: check that the error is low as well
|
||||||
if (setpoint.completed) {
|
if (setpoint.complete) {
|
||||||
switch (robot_state) {
|
switch (robot_state) {
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
robot_state = TURN;
|
robot_state = TURN;
|
||||||
|
|
|
||||||
22
robot_controller/trapezoidal.h
Normal file
22
robot_controller/trapezoidal.h
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// unitless trapezoidal
|
||||||
|
struct Trapezoidal {
|
||||||
|
float max_vel;
|
||||||
|
float max_acc;
|
||||||
|
float dist;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Setpoint {
|
||||||
|
float velocity; // unitless
|
||||||
|
float position; // unitless
|
||||||
|
bool complete; // the setpoint will no longer change
|
||||||
|
};
|
||||||
|
|
||||||
|
// returns the position and velocity at the given time on a trapezoidal motion plan
|
||||||
|
// this could be baked if too computationally expensive
|
||||||
|
// not fully fuzzed
|
||||||
|
struct Setpoint trapezoidal_planner(struct Trapezoidal* trapezoidal, float time);
|
||||||
|
|
||||||
|
// returns the time a given plan will take
|
||||||
|
float trapezoidal_time(struct Trapezoidal* trapezoidal);
|
||||||
|
|
@ -1,21 +1,6 @@
|
||||||
|
#include "trapezoidal.h"
|
||||||
// trapezoidal impl, not fuzzed
|
// trapezoidal impl, not fuzzed
|
||||||
|
|
||||||
// unitless trapezoidal
|
|
||||||
struct Trapezoidal {
|
|
||||||
float max_vel;
|
|
||||||
float max_acc;
|
|
||||||
float dist;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Setpoint {
|
|
||||||
float velocity; // unitless
|
|
||||||
float position; // unitless
|
|
||||||
bool complete; // the setpoint will no longer change
|
|
||||||
};
|
|
||||||
|
|
||||||
// returns the position and velocity at the given time on a trapezoidal motion plan
|
|
||||||
// this could be baked if too computationally expensive
|
|
||||||
// not fully fuzzed
|
|
||||||
struct Setpoint trapezoidal_planner(struct Trapezoidal* trapezoidal, float time) {
|
struct Setpoint trapezoidal_planner(struct Trapezoidal* trapezoidal, float time) {
|
||||||
float max_vel = trapezoidal->max_vel;
|
float max_vel = trapezoidal->max_vel;
|
||||||
float max_acc = trapezoidal->max_acc;
|
float max_acc = trapezoidal->max_acc;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue