RSeries astromech firmware
TankDriveSabertooth.h
Go to the documentation of this file.
1 #ifndef TankDriveSabertooh_h
2 #define TankDriveSabertooh_h
3 
4 #include "drive/TankDrive.h"
6 
23 {
24 public:
31  TankDriveSabertooth(int id, HardwareSerial& serial, JoystickController& driveStick) :
33  SabertoothDriver(id, serial)
34  {
35  }
36 
37  virtual void setup() override
38  {
39  setBaudRate(9600);
40  setRamping(80);
41  setTimeout(950);
42  }
43 
44  virtual void stop() override
45  {
48  }
49 
50 protected:
51  virtual void motor(float left, float right, float throttle) override
52  {
53  left *= throttle;
54  right *= throttle;
55  MOTOR_DEBUG_PRINT("ST1: ");
56  MOTOR_DEBUG_PRINT((int)(left * 127));
57  MOTOR_DEBUG_PRINT(" ST2: ");
58  MOTOR_DEBUG_PRINTLN((int)(right * 127));
59  SabertoothDriver::motor(1, left * 127);
60  SabertoothDriver::motor(2, right * 127);
61  }
62 };
63 #endif
SabertoothDriver.h
TankDriveSabertooth::setup
virtual void setup() override
Subclasses must implement this function to perform any necessary setup that cannot happen in the cons...
Definition: TankDriveSabertooth.h:37
TankDriveSabertooth::TankDriveSabertooth
TankDriveSabertooth(int id, HardwareSerial &serial, JoystickController &driveStick)
Constructor.
Definition: TankDriveSabertooth.h:31
TankDriveSabertooth
Definition: TankDriveSabertooth.h:22
SabertoothDriver::motor
void motor(int power) const
Definition: SabertoothDriver.h:116
SabertoothDriver::setBaudRate
void setBaudRate(long baudRate) const
Definition: SabertoothDriver.h:185
TankDrive::driveStick
void driveStick(JoystickController *stick, float speedModifier)
Definition: TankDrive.h:346
TankDrive
Base template of automatic forwarder from i2c to CommandEvent.
Definition: TankDrive.h:37
MOTOR_DEBUG_PRINTLN
#define MOTOR_DEBUG_PRINTLN(s)
Definition: TankDrive.h:17
MOTOR_DEBUG_PRINT
#define MOTOR_DEBUG_PRINT(s)
Definition: TankDrive.h:16
SabertoothDriver::setTimeout
void setTimeout(int milliseconds) const
Definition: SabertoothDriver.h:257
JoystickController
Definition: JoystickController.h:4
SabertoothDriver::stop
void stop() const
Definition: SabertoothDriver.h:155
SabertoothDriver::setRamping
void setRamping(byte value) const
Definition: SabertoothDriver.h:244
SabertoothDriver
Definition: SabertoothDriver.h:31
TankDrive.h
TankDriveSabertooth::stop
virtual void stop() override
Definition: TankDriveSabertooth.h:44
TankDriveSabertooth::motor
virtual void motor(float left, float right, float throttle) override
Definition: TankDriveSabertooth.h:51
TankDrive::stop
virtual void stop()
Definition: TankDrive.h:261