RobotDrive Class Reference

#include <RobotDrive.h>

Collaboration diagram for RobotDrive:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 RobotDrive (unsigned leftMotorChannel, unsigned rightMotorChannel, float sensitivity=0.5)
 RobotDrive (unsigned frontLeftMotorChannel, unsigned rearLeftMotorChannel, unsigned frontRightMotorChannel, unsigned rearRightMotorChannel, float sensitivity=0.5)
 RobotDrive (SpeedController *leftMotor, SpeedController *rightMotor, float sensitivity=0.5)
 RobotDrive (SpeedController *frontLeftMotor, SpeedController *rearLeftMotor, SpeedController *frontRightMotor, SpeedController *rearRightMotor, float sensitivity=0.5)
 ~RobotDrive (void)
void Drive (float speed, float curve)
void TankDrive (GenericHID *leftStick, GenericHID *rightStick)
void TankDrive (GenericHID *leftStick, unsigned leftAxis, GenericHID *rightStick, unsigned rightAxis)
void TankDrive (float leftValue, float rightValue)
void ArcadeDrive (GenericHID *stick)
void ArcadeDrive (GenericHID *moveStick, unsigned moveChannel, GenericHID *rotateStick, unsigned rotateChannel, GenericHID *spinStick=NULL, unsigned spinButton=0)
void ArcadeDrive (float moveValue, float rotateValue, bool spin)
void HolonomicDrive (float magnitude, float direction, float rotation)
void SetLeftRightMotorSpeeds (float leftSpeed, float rightSpeed)


Detailed Description

Utility class for handling Robot drive based on a definition of the motor configuration. The robot drive class handles basic driving for a robot. Currently, 2 and 4 motor standard drive trains are supported. In the future other drive types like swerve and meccanum might be implemented. Motor channel numbers are passed supplied on creation of the class. Those are used for either the Drive function (intended for hand created drive code, such as autonomous) or with the Tank/Arcade functions intended to be used for Operator Control driving.

Constructor & Destructor Documentation

RobotDrive::RobotDrive ( unsigned  leftMotorChannel,
unsigned  rightMotorChannel,
float  sensitivity = 0.5 
)

Constructor for RobotDrive with 2 motors specified with channel numbers. Set up parameters for a two wheel drive system where the left and right motor pwm channels are specified in the call. This call assumes Victors for controlling the motors.

Parameters:
leftMotorChannel The PWM channel number on the default digital module that drives the left motor.
rightMotorChannel The PWM channel number on the default digital module that drives the right motor.
sensitivity Effectively sets the turning sensitivity (or turn radius for a given value).

RobotDrive::RobotDrive ( unsigned  frontLeftMotor,
unsigned  rearLeftMotor,
unsigned  frontRightMotor,
unsigned  rearRightMotor,
float  sensitivity = 0.5 
)

Constructor for RobotDrive with 4 motors specified with channel numbers. Set up parameters for a four wheel drive system where all four motor pwm channels are specified in the call. This call assumes Victors for controlling the motors.

Parameters:
frontLeftMotor Front left motor channel number on the default digital module
rearLeftMotor Rear Left motor channel number on the default digital module
frontRightMotor Front right motor channel number on the default digital module
rearRightMotor Rear Right motor channel number on the default digital module
sensitivity Effectively sets the turning sensitivity (or turn radius for a given value)

RobotDrive::RobotDrive ( SpeedController leftMotor,
SpeedController rightMotor,
float  sensitivity = 0.5 
)

Constructor for RobotDrive with 2 motors specified as SpeedController objects. The SpeedController version of the constructor enables programs to use the RobotDrive classes with subclasses of the SpeedController objects, for example, versions with ramping or reshaping of the curve to suit motor bias or deadband elimination.

Parameters:
leftMotor The left SpeedController object used to drive the robot.
rightMotor the right SpeedController object used to drive the robot.
sensitivity Effectively sets the turning sensitivity (or turn radius for a given value)

RobotDrive::RobotDrive ( SpeedController frontLeftMotor,
SpeedController rearLeftMotor,
SpeedController frontRightMotor,
SpeedController rearRightMotor,
float  sensitivity = 0.5 
)

Constructor for RobotDrive with 4 motors specified as SpeedController objects. Speed controller input version of RobotDrive (see previous comments).

Parameters:
rearLeftMotor The back left SpeedController object used to drive the robot.
frontLeftMotor The front left SpeedController object used to drive the robot
rearRightMotor The back right SpeedController object used to drive the robot.
frontRightMotor The front right SpeedController object used to drive the robot.
sensitivity Effectively sets the turning sensitivity (or turn radius for a given value)

RobotDrive::~RobotDrive ( void   ) 

RobotDrive destructor. Deletes all the motor objects regardless of how they were allocated. Don't continue to use any passed-in PWM objects after this class destructor is run.


Member Function Documentation

void RobotDrive::Drive ( float  speed,
float  curve 
)

Drive the motors at "speed" and "curve".

The speed and curve are -1.0 to +1.0 values where 0.0 represents stopped and not turning. The algorithm for adding in the direction attempts to provide a constant turn radius for differing speeds.

This function sill most likely be used in an autonomous routine.

Parameters:
speed The forward component of the speed to send to the motors.
curve The rate of turn, constant for different forward speeds.

void RobotDrive::TankDrive ( GenericHID *  leftStick,
GenericHID *  rightStick 
)

Provide tank steering using the stored robot configuration. Drive the robot using two joystick inputs. The Y-axis will be selected from each Joystick object.

Parameters:
leftStick The joystick to control the left side of the robot.
rightStick The joystick to control the right side fo the robot.

void RobotDrive::TankDrive ( GenericHID *  leftStick,
unsigned  leftAxis,
GenericHID *  rightStick,
unsigned  rightAxis 
)

Provide tank steering using the stored robot configuration. This function lets you pick the axis to be used on each Joystick object for the left and right sides of the robot.

Parameters:
leftStick The Joystick object to use for the left side of the robot.
leftAxis The axis to select on the left side Joystick object.
rightStick The Joystick object to use for the right side of the robot.
rightAxis The axis to select on the right side Joystick object.

void RobotDrive::TankDrive ( float  leftValue,
float  rightValue 
)

Provide tank steering using the stored robot configuration. This function lets you directly provide joystick values from any source.

Parameters:
leftValue The value of the left stick.
rightValue The value of the right stick.

void RobotDrive::ArcadeDrive ( GenericHID *  stick  ) 

Arcade drive implements single stick driving. Given a single Joystick, the class assumes the Y axis for the move value and the X axis for the rotate value. (Should add more information here regarding the way that arcade drive works.)

Parameters:
stick The joystick to use for Arcade single-stick driving. The Y-axis will be selected for forwards/backwards and the X-axis will be selected for rotation rate.

void RobotDrive::ArcadeDrive ( GenericHID *  moveStick,
unsigned  moveAxis,
GenericHID *  rotateStick,
unsigned  rotateAxis,
GenericHID *  spinStick = NULL,
unsigned  spinButton = 0 
)

Arcade drive implements single stick driving. Given two joystick instances and two axis, compute the values to send to either two or four motors.

Parameters:
moveStick The Joystick object that represents the forward/backward direction
moveAxis The axis on the moveStick object to use for fowards/backwards (typically Y_AXIS)
rotateStick The Joystick object that represents the rotation value
rotateAxis The axis on the rotation object to use for the rotate right/left (typically X_AXIS)

void RobotDrive::ArcadeDrive ( float  moveValue,
float  rotateValue,
bool  spin 
)

Arcade drive implements single stick driving. This function lets you directly provide joystick values from any source.

Parameters:
moveValue The value to use for fowards/backwards
rotateValue The value to use for the rotate right/left

void RobotDrive::HolonomicDrive ( float  magnitude,
float  direction,
float  rotation 
)

Holonomic Drive class for Mecanum wheeled robots.

Experimental class for driving with Mecanum wheeled robots. There are 4 wheels on the robot, arranged so that the front and back wheels are toed in 45 degrees.

Parameters:
magnitude The speed that the robot should drive in a given direction.
direction The direction the robot should drive. The direction and maginitute are independent of the rotation rate.
rotation The rate of rotation for the robot that is completely independent of the magnitute or direction.

void RobotDrive::SetLeftRightMotorSpeeds ( float  leftSpeed,
float  rightSpeed 
)

Set the speed of the right and left motors. This is used once an appropriate drive setup function is called such as TwoWheelDrive(). The motors are set to "leftSpeed" and "rightSpeed" and includes flipping the direction of one side for opposing motors.

Parameters:
leftSpeed The speed to send to the left side of the robot.
rightSpeed The speed to send to the right side of the robot.


The documentation for this class was generated from the following files:

Generated on Thu Oct 2 14:01:31 2008 for WPI Robotics Library by  doxygen 1.5.5