|
TR-mbed 1.0
|
#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 |
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.
| enum Chassis::BrakeMode |
| 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.
| lfId | Left front motor CAN ID |
| rfId | Right front motor CAN ID |
| lbId | Left back motor CAN ID |
| rbId | Right back motor CAN ID |
| bool Chassis::allMotorsConnected | ( | ) |
| void Chassis::beyblade | ( | double | xVelocityRPM, |
| double | yVelocityRPM, | ||
| double | turretAngleDegrees, | ||
| bool | switchDirections | ||
| ) |
The beyblade method is used to spin the chassis while moving.
| xVelocityRPM | The x velocity in RPM |
| yVelocityRPM | The y velocity in RPM |
| turretAngleDegrees | The turret's angle in degrees, used to drive turret relative |
| switchDirections | Whether or not to switch directions |
| double Chassis::degreesToRadians | ( | double | degrees | ) |
Helper method to convert an angle from degrees to radians
| degrees | An angle measurement in degrees |
| void Chassis::driveAngle | ( | double | angleRadians, |
| double | speedRPM, | ||
| double | rotationVelcotiyRPM | ||
| ) |
The driveAngle method is used to drive the chassis with an absolute angle.
| angleRadians | Robot angle in radians |
| speedRPM | Speed in RPM |
| rotationVelcotiyRPM | Robot rotation velocity in RPM |
| void Chassis::driveFieldRelative | ( | ChassisSpeeds | speeds | ) |
The driveFieldRelative method is used to drive the chassis in a field relative manner.
| speeds | The field-relative speeds (x, y, and rotation) in RPM |
| void Chassis::driveMotors | ( | WheelSpeeds | speeds | ) |
The driveMotors method drives each motor at a specific speed
| speeds | The speeds in RPM to drive each motor at |
| void Chassis::driveOffsetAngle | ( | ChassisSpeeds | speeds, |
| double | angleOffset | ||
| ) |
The driveOffsetAngle method is used to drive the chassis with an offset angle.
| speeds | The speeds (x, y, and rotation) in RPM |
| angleOffset | The angle offset in radians |
` Drives the Chassis, compensating by a certain angle (angleOffset)
| void Chassis::driveOffsetAnglePower | ( | float | chassis_power, |
| uint16_t | chassis_power_limit, | ||
| ChassisSpeeds | speeds, | ||
| double | angleOffset, | ||
| int | dt, | ||
| double & | rotationalPower | ||
| ) |
| void Chassis::driveTurretRelative | ( | ChassisSpeeds | speeds, |
| double | turretAngleDegrees | ||
| ) |
The driveTurretRelative method is used to drive the chassis in a turret relative manner.
| speeds | The turret-relative speeds (x, y, and rotation) in RPM |
| turretAngleDegrees | The CCW-positive angle of the turret in degrees |
| void Chassis::driveTurretRelativePower | ( | float | chassis_power, |
| uint16_t | chassis_power_limit, | ||
| ChassisSpeeds | speeds, | ||
| double | turretAngleDegrees, | ||
| int | dt, | ||
| double & | rotationalPower | ||
| ) |
| void Chassis::driveXYR | ( | ChassisSpeeds | speeds | ) |
The driveXYR method is used to drive the chassis in a chassis relative manner.
| speeds | The robot-relative speeds (x, y, and rotation) in RPM |
| void Chassis::driveXYRPower | ( | float | chassis_power, |
| uint16_t | chassis_power_limit, | ||
| double | lX, | ||
| double | lY, | ||
| double | dt, | ||
| bool | beyblading, | ||
| double & | rotationalPower | ||
| ) |
| Chassis::BrakeMode Chassis::getBrakeMode | ( | ) |
A helper method to find the brake mode of the chassis.
| int Chassis::getHeadingDegreesPitch | ( | ) |
| int Chassis::getHeadingDegreesRoll | ( | ) |
| int Chassis::getHeadingDegreesYaw | ( | ) |
Gets the IMU's current angle reading in degrees
| Pose2D Chassis::getPose | ( | ) |
Gets the chassis's current 2D position
| ChassisSpeeds Chassis::getSpeeds | ( | ) |
Gets the chassis's current speeds
| void Chassis::initializeImu | ( | ) |
A helper method to initialize the IMU.
| void Chassis::periodic | ( | ) |
A method that should be run every main loop to update the Chassis's estimated position
| void Chassis::printMotorAngle | ( | ) |
Prints the current angles of the Chassis's motors, used for debugging
| void Chassis::readImu | ( | ) |
A helper method to read/update the IMU.
| void Chassis::setBrakeMode | ( | BrakeMode | brakeMode | ) |
A helper method to set the brake mode of the chassis.
| brakeMode | An enum representing the brake mode of the chassis |
| int8_t Chassis::isInverted[4] |
| double Chassis::prevVel |
| int Chassis::testData[300][4] |
| int Chassis::testDataIndex = 0 |