ARMS  3.1.1
Documentation for ARMS movement library
arms::chassis Namespace Reference

This namespace contains all of the functions and variables needed to control the chassis. More...

Functions

void setBrakeMode (pros::motor_brake_mode_e_t b)
 
bool settled ()
 
void waitUntilFinished (double exit_error)
 
void move (std::vector< double > target, double max, double exit_error, double lp, double ap, MoveFlags=NONE)
 
void move (double target, double max, double exit_error, double lp, double ap, MoveFlags=NONE)
 move the chassis a target distance forward More...
 
void turn (double target, double max, double exit_error, double ap, MoveFlags=NONE)
 turn the chassis a target angle More...
 
void turn (Point target, double max, double exit_error, double ap, MoveFlags=NONE)
 turn the chassis to face a target point More...
 
void tank (double left, double right, bool velocity=false)
 move the chassis using tank drive More...
 
void arcade (double vertical, double horizontal, bool velocity=false)
 move the chassis using arcade drive More...
 

Variables

double maxSpeed
 
std::shared_ptr< pros::Motor_Group > leftMotors
 
std::shared_ptr< pros::Motor_Group > rightMotors
 

Detailed Description

This namespace contains all of the functions and variables needed to control the chassis.

Function Documentation

◆ arcade()

void arms::chassis::arcade ( double  forward,
double  turn,
bool  velocity = false 
)

move the chassis using arcade drive

Parameters
forwardThe forward velocity or percentage (0%-100%).
turnThe turn velocity or percentage (0%-100%).
velocityWhether the values are velocities or percentages. Defaults to false for percentage mode.

Example 1:

//move the chassis forward at 100% speed
void arcade(double vertical, double horizontal, bool velocity=false)
move the chassis using arcade drive

Example 2:

//move the chassis forward at 100 rpm
chassis::arcade(100, 0, true);

Example 3:

//move the chassis forward at 100% speed, and turn left at 50% speed
chassis::arcade(100, -50);

◆ move() [1/2]

void arms::chassis::move ( double  target,
double  max,
double  exit_error,
double  lp,
double  ap,
MoveFlags  flags = NONE 
)

move the chassis a target distance forward

Parameters
targetThe target distance to move to.
flagsThe flags to use when moving the chassis.
maxThe maximum speed to move at.
exit_errorThe minimum distance from the target point to exit the movement.
lpThe linear kP for the movement.
apThe angular kP for the movement.
flagsThe flags to use when moving the chassis.

Almost all parameters are optional. Technically, only the target parameter is required. However, it is recommended to provide the max parameter aswell so that you have control over the maximum speed of the chassis.

Example 1:

//move the chassis forwards 24 inches at 100% max speed
chassis::move(24, 100);
void move(std::vector< double > target, double max, double exit_error, double lp, double ap, MoveFlags=NONE)

Example 2:

//move the chassis backwards 72 inches at 100% max speed
chassis::move(-72, 100, arms::REVERSE);

Example 3:

//move the chassis forwards 48 inches at 75% max speed with a 2 inch exit error with PID disabled
chassis::move(48, 75, 2, arms::THRU);

Moves the chassis a target distance. Almost all parameters are optional. Technically, only the target parameter is required. However, it is recommended to provide the max parameter aswell so that you have control over the maximum speed of the chassis.

The target parameter is used to specify how far the chassis should move. The max parameter can be used to set the maximum speed of the movement. It will default to 100% if not provided.
The exit_error parameter can be used to set the minimum error from the target point to exit the movement. It will default to what is provided in config::h::MIN_ERROR if not provided.
The lp parameter can be used to set the linear kP for the movement. It will default to what is provided in config.h if not provided.
The ap parameter can be used to set the angular kP for the movement. It will default to what is provided in config.h if not provided.
The flags parameter can be used to set the flags for the movement. A list of them and their descriptions can be found in the MoveFlags enum. The arms::RELATIVE flag is always enabled for this, as you should only use this to move a relative distance straight with the bot.

◆ move() [2/2]

void arms::chassis::move ( std::vector< double >  target,
double  max,
double  exit_error,
double  lp,
double  ap,
MoveFlags  flags = NONE 
)

Perform a 2D chassis movement based on the parameters provided.

Parameters
targetThe target point to move to.
maxThe maximum speed to move at.
exit_errorThe minimum distance from the target point to exit the movement.
lpThe linear kP for the movement.
apThe angular kP for the movement.
flagsThe flags to use when moving the chassis.

Example 1:

//move the chassis to coordinate {50, 40} at 100% max speed
chassis::move({50, 40}, 100);

Example 2:

//move the chassis to coordinate {30, 72} at 100% max speed backwards
chassis::move({30, 72}, 100, arms::REVERSE);

Example 3:

//move the chassis to the pose {48, 48, 90deg} at 75% max speed with a 2 inch exit error
//Movements to a pose will use our `Boomerang controller`, which uses trigonometry to move to the target point and angle
chassis::move({48, 48, 90}, 75, 2);

Moves the chassis to a target point. Almost all parameters are optional. Technically, only the target parameter is required. However, it is recommended to provide the max parameter aswell so that you have control over the maximum speed of the chassis.

The target parameter is a vector of doubles that represents the target point (x, y), or pose (x, y, theta). For a target point, our standard point-point odometry motion is used. For a target pose, our Boomerang controller is used. More information on these can be seen at MotionControl.
The max parameter can be used to set the maximum speed of the movement. It will default to 100% if not provided.
The exit_error parameter can be used to set the minimum error from the target point to exit the movement. It will default to what is provided in config::h::MIN_ERROR if not provided.
The lp parameter can be used to set the linear kP for the movement. It will default to what is provided in config.h if not provided.
The ap parameter can be used to set the angular kP for the movement. It will default to what is provided in config.h if not provided.
The flags parameter can be used to set the flags for the movement. A list of them and their descriptions can be found in the MoveFlags enum.

◆ setBrakeMode()

void arms::chassis::setBrakeMode ( pros::motor_brake_mode_e_t  brakeMode)

Sets the chassis's brake mode

Parameters
brakeModeThe chassis brake mode

Example 1:

//set the chassis's brake mode to coast
chassis::setBrakeMode(pros::E_MOTOR_BRAKE_COAST);
void setBrakeMode(pros::motor_brake_mode_e_t b)

Sets the chassis's brake mode to a valid PROS Brake Mode Options are coast, hold, and brake.

◆ settled()

bool arms::chassis::settled ( )
Returns
True if the chassis is settled, false otherwise

Example 1:

//wait until the chassis is settled
while(!chassis::settled()) {
pros::delay(20);
}

Checks if the chassis is settled.

◆ tank()

void arms::chassis::tank ( double  left,
double  right,
bool  velocity = false 
)

move the chassis using tank drive

Parameters
leftThe left side velocity or percentage (0%-100%).
rightThe right side velocity or percentage (0%-100%).
velocityWhether the values are velocities or percentages. Defaults to false for percentage mode.

Example 1:

//move the chassis forward at 100% speed
chassis::tank(100, 100);
void tank(double left, double right, bool velocity=false)
move the chassis using tank drive

Example 2:

//move the chassis forward at 100 rpm
chassis::tank(100, 100, true);

Example 3:

//move the left side of the chassis forward at 100% speed, and the right side backwards at 50% speed
chassis::tank(100, -50);

◆ turn() [1/2]

void arms::chassis::turn ( double  target,
double  max,
double  exit_error,
double  ap,
MoveFlags  flags = NONE 
)

turn the chassis a target angle

Perform a turn movement

Parameters
targetThe target angle to turn to.
flagsThe flags to use when moving the chassis.
maxThe maximum speed to move at.
exit_errorThe minimum distance from the target point to exit the movement.
apThe angular kP for the movement.
flagsThe flags to use when moving the chassis.

Almost all parameters are optional. Technically, only the target parameter is required. However, it is recommended to provide the max parameter aswell so that you have control over the maximum speed of the chassis.

Example 1:

//turn the chassis to face 90 degrees at 100% max speed
chassis::turn(90, 100);
void turn(double target, double max, double exit_error, double ap, MoveFlags=NONE)
turn the chassis a target angle

Example 2:

//turn the chassis 180 degrees clockwise at 100% max speed
chassis::turn(-180, 100, arms::RELATIVE);

Example 3:

//turn the chassis to face 90 degrees at 75% max speed with a 2 degree exit error with PID disabled
chassis::turn(90, 75, 2, arms::THRU);

Turns the chassis a target angle. Almost all parameters are optional. Technically, only the target parameter is required. However, it is recommended to provide the max parameter aswell so that you have control over the maximum speed of the chassis.

The target parameter is a double that represents the target angle (theta). We use our PID controller to turn to the target angle. More information on this can be seen at MotionControl.
The max parameter can be used to set the maximum speed of the movement. It will default to 100% if not provided.
The exit_error parameter can be used to set the minimum error from the target point to exit the movement. It will default to what is provided in config::h::MIN_ERROR if not provided.
The ap parameter can be used to set the angular kP for the movement. It will default to what is provided in config.h if not provided.
The flags parameter can be used to set the flags for the movement. A list of them and their descriptions can be found in the MoveFlags enum.

◆ turn() [2/2]

void arms::chassis::turn ( Point  target,
double  max,
double  exit_error,
double  ap,
MoveFlags  flags = NONE 
)

turn the chassis to face a target point

Parameters
targetThe target point to turn to.
flagsThe flags to use when moving the chassis.
maxThe maximum speed to move at.
exit_errorThe minimum distance from the target point to exit the movement.
apThe angular kP for the movement.
flagsThe flags to use when moving the chassis.

Example 1:

//turn the chassis to face the point (24, 24) at 100% speed
chassis::turn({24, 24}, 100);

Example 2:

//turn the chassis to face the point {72, -48} at 75% speed
chassis::turn({72, -48}, 75);

Example 3:

//turn the chassis to face the point (24, 24) at 100% speed with a 2 degree exit error with PID disabled
chassis::turn({24, 24}, 100, 2, arms::THRU);

Turns the chassis a target angle. Almost all parameters are optional. Technically, only the target parameter is required. However, it is recommended to provide the max parameter aswell so that you have control over the maximum speed of the chassis.

The target parameter is a Point that represents the point we want to turn to face. We use our PID controller to turn to the target angle. More information on this can be seen at MotionControl.
The max parameter can be used to set the maximum speed of the movement. It will default to 100% if not provided.
The exit_error parameter can be used to set the minimum error from the target point to exit the movement. It will default to what is provided in config::h::MIN_ERROR if not provided.
The ap parameter can be used to set the angular kP for the movement. It will default to what is provided in config.h if not provided.
The flags parameter can be used to set the flags for the movement. A list of them and their descriptions can be found in the MoveFlags enum.

◆ waitUntilFinished()

void arms::chassis::waitUntilFinished ( double  exit_error)
Parameters
exit_errorThe minimum error from the target point to exit the wait

Example 1:

//wait for the chassis to finish a movement with a 1 inch error
void waitUntilFinished(double exit_error)

Waits for the chassis to reach a target point within a certain exit_error. This function should not be required, as chassis::move is already a blocking function by default. However, this may need to be used if the chassis::move function is called with the MoveFlags::async flag.

Variable Documentation

◆ leftMotors

std::shared_ptr< pros::Motor_Group > arms::chassis::leftMotors
extern

This variable is a pointer to a Motor_Group object that contains all of the left motors.

◆ maxSpeed

double arms::chassis::maxSpeed
extern

This variable is used to set the maximum speed of the chassis.

◆ rightMotors

std::shared_ptr< pros::Motor_Group > arms::chassis::rightMotors
extern

This variable is a pointer to a Motor_Group object that contains all of the right motors.