TR-mbed 1.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
Chassis Class Reference

#include <Chassis.h>

Public Types

enum  BrakeMode { BRAKE , COAST }
 

Public Member Functions

 Chassis (short lfId, short rfId, short lbId, short rbId, I2C *i2c)
 
void driveMotors (WheelSpeeds speeds)
 
void driveXYR (ChassisSpeeds speeds)
 
void driveXYRPower (float chassis_power, uint16_t chassis_power_limit, double lX, double lY, double dt, bool beyblading, double &rotationalPower)
 
void driveOffsetAnglePower (float chassis_power, uint16_t chassis_power_limit, ChassisSpeeds speeds, double angleOffset, int dt, double &rotationalPower)
 
void driveTurretRelativePower (float chassis_power, uint16_t chassis_power_limit, ChassisSpeeds speeds, double turretAngleDegrees, int dt, double &rotationalPower)
 
void driveFieldRelative (ChassisSpeeds speeds)
 
void driveTurretRelative (ChassisSpeeds speeds, double turretAngleDegrees)
 
void driveOffsetAngle (ChassisSpeeds speeds, double angleOffset)
 
void driveAngle (double angleRadians, double speedRPM, double rotationVelcotiyRPM)
 
void beyblade (double xVelocityRPM, double yVelocityRPM, double turretAngleDegrees, bool switchDirections)
 
DJIMotor getMotor (int index)
 
BrakeMode getBrakeMode ()
 
void setBrakeMode (BrakeMode brakeMode)
 
void initializeImu ()
 
void periodic ()
 
void printMotorAngle ()
 
double degreesToRadians (double degrees)
 
int getHeadingDegreesYaw ()
 
int getHeadingDegreesPitch ()
 
int getHeadingDegreesRoll ()
 
Pose2D getPose ()
 
ChassisSpeeds getSpeeds ()
 
void readImu ()
 
bool allMotorsConnected ()
 

Public Attributes

int8_t isInverted [4]
 
double prevVel
 
int testData [300][4]
 
int testDataIndex = 0
 

Detailed Description

The Chassis class is a wrapper for the DJIMotor class that allows for easy control of the chassis. It also contains methods for controlling the chassis in a field relative manner, and for controlling the chassis with an offset angle.

The Chassis class also contains methods for controlling the chassis with the IMU. The IMU is used to control the chassis in a field relative manner, and to control the chassis with an offset angle.

Member Enumeration Documentation

◆ BrakeMode

The BrakeMode enum is used to set the brake mode of the chassis.

Enumerator
BRAKE 
COAST 

Constructor & Destructor Documentation

◆ Chassis()

Chassis::Chassis ( short  lfId,
short  rfId,
short  lbId,
short  rbId,
I2C *  i2c 
)

The Chassis constructor. This constructor takes in the CAN IDs of the four motors on the chassis.

Parameters
lfIdLeft front motor CAN ID
rfIdRight front motor CAN ID
lbIdLeft back motor CAN ID
rbIdRight back motor CAN ID

Member Function Documentation

◆ allMotorsConnected()

bool Chassis::allMotorsConnected ( )

◆ beyblade()

void Chassis::beyblade ( double  xVelocityRPM,
double  yVelocityRPM,
double  turretAngleDegrees,
bool  switchDirections 
)

The beyblade method is used to spin the chassis while moving.

Parameters
xVelocityRPMThe x velocity in RPM
yVelocityRPMThe y velocity in RPM
turretAngleDegreesThe turret's angle in degrees, used to drive turret relative
switchDirectionsWhether or not to switch directions

◆ degreesToRadians()

double Chassis::degreesToRadians ( double  degrees)

Helper method to convert an angle from degrees to radians

Parameters
degreesAn angle measurement in degrees
Returns
The angle converted to radians

◆ driveAngle()

void Chassis::driveAngle ( double  angleRadians,
double  speedRPM,
double  rotationVelcotiyRPM 
)

The driveAngle method is used to drive the chassis with an absolute angle.

Parameters
angleRadiansRobot angle in radians
speedRPMSpeed in RPM
rotationVelcotiyRPMRobot rotation velocity in RPM

◆ driveFieldRelative()

void Chassis::driveFieldRelative ( ChassisSpeeds  speeds)

The driveFieldRelative method is used to drive the chassis in a field relative manner.

Parameters
speedsThe field-relative speeds (x, y, and rotation) in RPM

◆ driveMotors()

void Chassis::driveMotors ( WheelSpeeds  speeds)

The driveMotors method drives each motor at a specific speed

Parameters
speedsThe speeds in RPM to drive each motor at

◆ driveOffsetAngle()

void Chassis::driveOffsetAngle ( ChassisSpeeds  speeds,
double  angleOffset 
)

The driveOffsetAngle method is used to drive the chassis with an offset angle.

Parameters
speedsThe speeds (x, y, and rotation) in RPM
angleOffsetThe angle offset in radians

` Drives the Chassis, compensating by a certain angle (angleOffset)

◆ driveOffsetAnglePower()

void Chassis::driveOffsetAnglePower ( float  chassis_power,
uint16_t  chassis_power_limit,
ChassisSpeeds  speeds,
double  angleOffset,
int  dt,
double &  rotationalPower 
)

◆ driveTurretRelative()

void Chassis::driveTurretRelative ( ChassisSpeeds  speeds,
double  turretAngleDegrees 
)

The driveTurretRelative method is used to drive the chassis in a turret relative manner.

Parameters
speedsThe turret-relative speeds (x, y, and rotation) in RPM
turretAngleDegreesThe CCW-positive angle of the turret in degrees

◆ driveTurretRelativePower()

void Chassis::driveTurretRelativePower ( float  chassis_power,
uint16_t  chassis_power_limit,
ChassisSpeeds  speeds,
double  turretAngleDegrees,
int  dt,
double &  rotationalPower 
)

◆ driveXYR()

void Chassis::driveXYR ( ChassisSpeeds  speeds)

The driveXYR method is used to drive the chassis in a chassis relative manner.

Parameters
speedsThe robot-relative speeds (x, y, and rotation) in RPM

◆ driveXYRPower()

void Chassis::driveXYRPower ( float  chassis_power,
uint16_t  chassis_power_limit,
double  lX,
double  lY,
double  dt,
bool  beyblading,
double &  rotationalPower 
)

◆ getBrakeMode()

Chassis::BrakeMode Chassis::getBrakeMode ( )

A helper method to find the brake mode of the chassis.

Returns
An enum representing the brake mode of the chassis

◆ getHeadingDegreesPitch()

int Chassis::getHeadingDegreesPitch ( )

◆ getHeadingDegreesRoll()

int Chassis::getHeadingDegreesRoll ( )

◆ getHeadingDegreesYaw()

int Chassis::getHeadingDegreesYaw ( )

Gets the IMU's current angle reading in degrees

Returns
The IMU's current angle reading in degrees

◆ getMotor()

DJIMotor Chassis::getMotor ( int  index)

A helper method to find a DJIMotor object from an index.

Parameters
indexThe index of the motor
Returns
a DJIMotor object

◆ getPose()

Pose2D Chassis::getPose ( )

Gets the chassis's current 2D position

Returns
The chassis's current 2D position

◆ getSpeeds()

ChassisSpeeds Chassis::getSpeeds ( )

Gets the chassis's current speeds

Returns
The chassis's current speeds

◆ initializeImu()

void Chassis::initializeImu ( )

A helper method to initialize the IMU.

◆ periodic()

void Chassis::periodic ( )

A method that should be run every main loop to update the Chassis's estimated position

◆ printMotorAngle()

void Chassis::printMotorAngle ( )

Prints the current angles of the Chassis's motors, used for debugging

◆ readImu()

void Chassis::readImu ( )

A helper method to read/update the IMU.

◆ setBrakeMode()

void Chassis::setBrakeMode ( BrakeMode  brakeMode)

A helper method to set the brake mode of the chassis.

Parameters
brakeModeAn enum representing the brake mode of the chassis

Member Data Documentation

◆ isInverted

int8_t Chassis::isInverted[4]

◆ prevVel

double Chassis::prevVel

◆ testData

int Chassis::testData[300][4]

◆ testDataIndex

int Chassis::testDataIndex = 0

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