|
RSeries astromech firmware
|
|
Go to the documentation of this file. 1 #ifndef TankDriveRoboteq_h
2 #define TankDriveRoboteq_h
120 if (stick ==
nullptr)
124 write(
"^MMOD 1 3\r");
125 write(
"^MMOD 2 3\r");
139 write(
"^MMOD 1 6\r");
140 write(
"^MMOD 2 6\r");
162 speed = max(min(speed, 1.0f), 0.0f);
176 speed = max(min(speed, 1.0f), 0.0f);
200 virtual void motor(
float left,
float right,
float throttle)
override
204 left =
map(left, -1.0f, 1.0f, 0.0f, 1.0f);
205 right =
map(right, -1.0f, 1.0f, 0.0f, 1.0f);
239 snprintf(buf,
sizeof(buf),
"%s %d\r", cmd, arg1);
241 #ifdef USE_MOTOR_DEBUG
244 buf[strlen(buf)-1] = 0;
254 snprintf(buf,
sizeof(buf),
"%s %d %d\r", cmd, arg1, arg2);
256 #ifdef USE_MOTOR_DEBUG
259 buf[strlen(buf)-1] = 0;
275 static float map(
float x,
float in_min,
float in_max,
float out_min,
float out_max)
277 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
virtual bool isCommandModeActive()
Definition: TankDriveRoboteq.h:146
virtual bool hasThrottle() override
Definition: TankDriveRoboteq.h:231
virtual void leaveCommandMode()
Definition: TankDriveRoboteq.h:133
Definition: TurtleDrive.h:1
static float map(float x, float in_min, float in_max, float out_min, float out_max)
Definition: TankDriveRoboteq.h:275
int getMoveDistanceCount(double millimeters)
Definition: TurtleDrive.h:13
Definition: TankDriveRoboteq.h:23
virtual void stop() override
Definition: TankDriveRoboteq.h:103
#define DEBUG_PRINTLN(s)
Definition: ReelTwo.h:188
TankDriveRoboteq(ServoDispatch &dispatch, int leftNum, int rightNum, int throttleNum, JoystickController &driveStick)
Constructor.
Definition: TankDriveRoboteq.h:75
HardwareSerial * fSerial
Definition: TankDriveRoboteq.h:193
TankDriveRoboteq(ServoDispatch &dispatch, int leftNum, int rightNum, JoystickController &driveStick)
Constructor.
Definition: TankDriveRoboteq.h:66
void driveStick(JoystickController *stick, float speedModifier)
Definition: TankDrive.h:346
void moveTo(uint16_t num, uint32_t startDelay, uint32_t moveTime, float pos)
Definition: ServoDispatch.h:132
void setMaxSpeed(float modifier)
Definition: TankDrive.h:137
int getTurnDistanceCount(double turnDegrees)
Definition: TurtleDrive.h:18
void writeIntCmd(const char *cmd, int arg1)
Definition: TankDriveRoboteq.h:236
Base template of automatic forwarder from i2c to CommandEvent.
Definition: TankDrive.h:37
int fThrottle
Definition: TankDriveRoboteq.h:198
ServoDispatch * fDispatch
Definition: TankDriveRoboteq.h:194
virtual void turnDegrees(double degrees, float speed=0.1)
Definition: TankDriveRoboteq.h:170
#define MOTOR_DEBUG_PRINTLN(s)
Definition: TankDrive.h:17
TankDriveRoboteq(HardwareSerial &serial, ServoDispatch &dispatch, int leftNum, int rightNum, int throttleNum, JoystickController &driveStick)
Constructor.
Definition: TankDriveRoboteq.h:51
int fRight
Definition: TankDriveRoboteq.h:197
#define MOTOR_DEBUG_PRINT(s)
Definition: TankDrive.h:16
TankDriveRoboteq(HardwareSerial &serial, JoystickController &driveStick)
Constructor.
Definition: TankDriveRoboteq.h:32
Servo interace implemented eitehr by ServoDispatchPCA9685 or ServoDispatchDirect.
Definition: ServoDispatch.h:83
int fLeft
Definition: TankDriveRoboteq.h:196
Definition: JoystickController.h:4
JoystickController * getActiveStick()
Definition: TankDrive.h:268
virtual void motor(float left, float right, float throttle) override
Definition: TankDriveRoboteq.h:200
virtual bool enterCommandMode()
Definition: TankDriveRoboteq.h:115
virtual void moveMillimeters(double mm, float speed=0.1)
Definition: TankDriveRoboteq.h:157
TankDriveRoboteq(HardwareSerial &serial, ServoDispatch &dispatch, int leftNum, int rightNum, JoystickController &driveStick)
Constructor.
Definition: TankDriveRoboteq.h:42
virtual void stop()
Definition: TankDrive.h:261
virtual void setup() override
Subclasses must implement this function to perform any necessary setup that cannot happen in the cons...
Definition: TankDriveRoboteq.h:85
bool fCommandMode
Definition: TankDriveRoboteq.h:195
void writeIntCmd(const char *cmd, int arg1, int arg2)
Definition: TankDriveRoboteq.h:251
void write(const char *cmd)
Definition: TankDriveRoboteq.h:266