RSeries astromech firmware
TankDrivePWM Class Reference

#include <drive/TankDrivePWM.h>

Detailed Description

Base template of automatic forwarder from i2c to CommandEvent.

TankDrivePWM tankDrive;
+ Inheritance diagram for TankDrivePWM:
+ Collaboration diagram for TankDrivePWM:

Public Member Functions

 TankDrivePWM (ServoDispatch &dispatch, uint8_t leftNum, uint8_t rightNum, JoystickController &driveStick)
 Constructor. More...
 
 TankDrivePWM (ServoDispatch &dispatch, uint8_t leftNum, uint8_t rightNum, int throttleNum, JoystickController &driveStick)
 Constructor. More...
 
virtual void setup () override
 Subclasses must implement this function to perform any necessary setup that cannot happen in the constructor. More...
 
virtual void stop () override
 
- Public Member Functions inherited from TankDrive
 TankDrive (JoystickController &driveStick)
 Constructor. More...
 
bool getEnable ()
 
void setEnable (bool enable)
 
uint32_t getSerialLatency ()
 
void setSerialLatency (uint32_t ms)
 
bool getChannelMixing ()
 
void setChannelMixing (bool mixing)
 
bool getThrottleInverted ()
 
void setThrottleInverted (bool invert)
 
bool getTurnInverted ()
 
void setTurnInverted (bool invert)
 
bool getScaling ()
 
void setScaling (bool scaling)
 
float getMaxSpeed ()
 
void setMaxSpeed (float modifier)
 
unsigned getThrottleAccelerationScale ()
 
void setThrottleAccelerationScale (unsigned scale)
 
unsigned getThrottleDecelerationScale ()
 
void setThrottleDecelerationScale (unsigned scale)
 
unsigned getTurnAccelerationScale ()
 
void setTurnAccelerationScale (unsigned scale)
 
unsigned getTurnDecelerationScale ()
 
void setTurnDecelerationScale (unsigned scale)
 
void setAccelerationScale (unsigned scale)
 
void setDecelerationScale (unsigned scale)
 
void setDriveStick (JoystickController &driveStick)
 
void setGuestStick (JoystickController &guestStick)
 
float getGuestSpeedModifier ()
 
void setGuestSpeedModifier (float maxGuestSpeed)
 
void setTargetSteering (TargetSteering *target)
 
bool useThrottle ()
 
bool useHardStop ()
 
bool useLeftStick ()
 
bool useRightStick ()
 
void setUseThrottle (bool use)
 
void setUseHardStop (bool use)
 
void setUseLeftStick ()
 
void setUseRightStick ()
 
JoystickControllergetActiveStick ()
 
virtual void animate () override
 Dispatch any received i2c event to CommandEvent. More...
 
- Public Member Functions inherited from SetupEvent
 SetupEvent ()
 Default Constructor. More...
 
- Public Member Functions inherited from AnimatedEvent
 AnimatedEvent ()
 Default Constructor. More...
 
void setLoopDoneCallback (AnimatedLoopDone loopProc)
 

Protected Member Functions

virtual void motor (float left, float right, float throttle) override
 
virtual bool hasThrottle () override
 
- Protected Member Functions inherited from TankDrive
virtual float getThrottle ()
 
virtual float throttleSpeed (float speedModifier)
 
void driveStick (JoystickController *stick, float speedModifier)
 

Static Protected Member Functions

static float map (float x, float in_min, float in_max, float out_min, float out_max)
 

Protected Attributes

ServoDispatchfDispatch
 
uint8_t fLeft
 
uint8_t fRight
 
int fThrottle
 
- Protected Attributes inherited from TankDrive
JoystickControllerfDriveStick
 
JoystickControllerfGuestStick
 
TargetSteeringfTargetSteering
 
bool fEnabled = false
 
bool fWasConnected = false
 
bool fMotorsStopped = false
 
bool fChannelMixing = false
 
bool fScaling = false
 
bool fUseLeftStick = true
 
bool fUseThrottle = true
 
bool fUseHardStop = true
 
bool fThrottleInverted = false
 
bool fTurnInverted = false
 
float fSpeedModifier = 0
 
float fGuestSpeedModifier = 0
 
uint32_t fSerialLatency = 0
 
uint32_t fLastCommand = 0
 
unsigned fThrottleAccelerationScale = 0
 
unsigned fThrottleDecelerationScale = 0
 
unsigned fTurnAccelerationScale = 0
 
unsigned fTurnDecelerationScale = 0
 
float fDriveThrottle = 0
 
float fDriveTurning = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from SetupEvent
static void ready ()
 Calls setup() for each created AnimatedEvent subclass. More...
 
- Static Public Member Functions inherited from AnimatedEvent
static void process ()
 Calls animate() for each created AnimatedEvent subclass. More...
 

Constructor & Destructor Documentation

◆ TankDrivePWM() [1/2]

TankDrivePWM::TankDrivePWM ( ServoDispatch dispatch,
uint8_t  leftNum,
uint8_t  rightNum,
JoystickController driveStick 
)
inline

Constructor.

Will drive PWM pins

◆ TankDrivePWM() [2/2]

TankDrivePWM::TankDrivePWM ( ServoDispatch dispatch,
uint8_t  leftNum,
uint8_t  rightNum,
int  throttleNum,
JoystickController driveStick 
)
inline

Constructor.

Will drive PWM pins

Member Function Documentation

◆ hasThrottle()

virtual bool TankDrivePWM::hasThrottle ( )
inlineoverrideprotectedvirtual

Reimplemented from TankDrive.

◆ map()

static float TankDrivePWM::map ( float  x,
float  in_min,
float  in_max,
float  out_min,
float  out_max 
)
inlinestaticprotected

◆ motor()

virtual void TankDrivePWM::motor ( float  left,
float  right,
float  throttle 
)
inlineoverrideprotectedvirtual

Implements TankDrive.

◆ setup()

virtual void TankDrivePWM::setup ( )
inlineoverridevirtual

Subclasses must implement this function to perform any necessary setup that cannot happen in the constructor.

Reimplemented from TankDrive.

◆ stop()

virtual void TankDrivePWM::stop ( )
inlineoverridevirtual

Reimplemented from TankDrive.

Member Data Documentation

◆ fDispatch

ServoDispatch& TankDrivePWM::fDispatch
protected

◆ fLeft

uint8_t TankDrivePWM::fLeft
protected

◆ fRight

uint8_t TankDrivePWM::fRight
protected

◆ fThrottle

int TankDrivePWM::fThrottle
protected

The documentation for this class was generated from the following file:
TankDrivePWM.h
TankDrivePWM
Base template of automatic forwarder from i2c to CommandEvent.
Definition: TankDrivePWM.h:22