Hardware

class Chassis

Public Functions

void initialize()

Initialize the chassis.

Example

// Construct a chassis config
dlib::ChassisConfig chassis_config({
 {1, 2, 3}, // left motor ports
 {4, 5, 6}, // right motor ports
 450,   // the drivebase rpm
 3.25   // the drivebase wheel diameter
});

// Construct a chassis
dlib::Chassis chassis(chassis_config);

// Initialize the chassis
chassis.initialize();

void move(int32_t power)

Move the Chassis with a joystick input.

Example

// Construct a ChassisConfig
dlib::ChassisConfig chassis_config({
 {1, 2, 3}, // left motor ports
 {4, 5, 6}, // right motor ports
 450,   // the drivebase rpm
 3.25   // the drivebase wheel diameter
});

// Construct a Chassis
dlib::Chassis chassis(chassis_config);

// Move the chassis at max forward (127)
chassis.move(127);

Parameters:

power – the joystick input value

void move_voltage(double voltage)

Move the Chassis with a given voltage.

Parameters:

voltage – the voltage to send to the motors

void turn(int32_t power)

Turn the Chassis with a joystick input.

Example

// Construct a Chassis config
dlib::ChassisConfig chassis_config({
 {1, 2, 3}, // left motor ports
 {4, 5, 6}, // right motor ports
 450,   // the drivebase rpm
 3.25   // the drivebase wheel diameter
});

// Construct a chassis
dlib::Chassis chassis(chassis_config);

// Turn the chassis at max forward (127)
chassis.turn(127);

Parameters:

power – the joystick input value

void turn_voltage(double voltage)

Turn the chassis with a given voltage.

Parameters:

voltage – the voltage to send to the motors

void arcade(int32_t power, int32_t turn)

Turn the Chassis.

Example

// Construct a ChassisConfig
dlib::ChassisConfig chassis_config({
 {1, 2, 3}, // left motor ports
 {4, 5, 6}, // right motor ports
 450,   // the drivebase rpm
 3.25   // the drivebase wheel diameter
});

// Construct a Chassis
dlib::Chassis Chassis(chassis_config);

// Create a controller
pros::Controller master = pros::Controller(pros::E_CONTROLLER_MASTER);

// Instantiate power & turn
double power = master.get_analog(ANALOG_LEFT_Y);
double turn = master.get_analog(ANALOG_RIGHT_X);

// Move the chassis given power & turn
chassis.arcade(power, turn);

void brake()

Brake the Chassis.

double revolutions_to_displacement(double revolutions) const

Convert from motor revolutions to linear displacement for the Chassis.

Parameters:

revolutions – the number of motor revolutions

Returns:

linear displacement

double rpm_to_velocity(double rpm) const

Convert from motor rpm to linear velocity for the Chassis.

Parameters:

rpm

Returns:

linear velocity

double left_motors_displacement() const

Get the average linear displacement of the left side of the Chassis.

Returns:

the linear displacement of the left side of the Chassis

double right_motors_displacement() const

Get the average linear displacement of the right side of the Chassis.

Returns:

the linear displacement of the right side of the Chassis

double forward_motor_displacement() const

Get the forward linear displacment of the Chassis.

Returns:

the forward linear displacement of the Chassis

double left_motors_velocity() const

Get the linear velocity of the left side of the Chassis.

Returns:

the linear velocity of the left side of the Chassis

double right_motors_velocity() const

Get the linear velocity of the right side of the Chassis.

Returns:

the linear velocity of the right side of the Chassis

double forward_motor_velocity() const

Get the forward linear velocity of the Chassis.

Returns:

the forward linear velocity of the Chassis

class MotorGroup

Public Functions

void move(double power)

Move the motorgroup with a joystick input.

Parameters:

power – the joystick input value

void move_voltage(double voltage)

Move the MotorGroup with a given voltage.

Parameters:

voltage – the voltage to send to the motors

double get_position() const

Get the MotorGroup average position in revolutions.

Returns:

revolutions

double get_velocity() const

Get the MotorGroup average velocity in rpm.

Returns:

rpm

class Motor

Public Functions

double get_position() const

Get the position of the Motor in revolutions.

Returns:

revolutions

double get_velocity() const

Get the velocity of the Motor in rpm.

Returns:

rpm

class Imu

Public Functions

void initialize()

Initialize the Imu.

Example

void opcontrol(){
dlib::ImuConfig imu_config({
7,  // imu port
1.001   // optional imu scaling constant
});

dlib::Imu imu(imu_config);

imu.initialize();

double get_rotation() const

Get Imu rotation.

Example

void opcontrol(){
dlib::ImuConfig imu_config({
7,  // imu port
1.001   // optional imu scaling constant
});

dlib::Imu imu(imu_config);

double degrees = imu.get_rotation();

double get_heading() const

Get Imu heading.

Example

void opcontrol(){
dlib::ImuConfig imu_config({
7,  // imu port
1.001   // optional imu scaling constant
});

dlib::Imu imu(imu_config);

double degrees = imu.get_heading();

class Rotation

Public Functions

void initialize()

Initialize the Rotation sensor.

double get_position() const

Get the position of the rotation sensor in revolutions.

Returns:

revolutions

double get_velocity() const

Get the velocity of the rotation sensor in rpm.

Returns:

rpm

double get_linear_displacement() const

Get the linear displacement of the rotation sensor.

Returns:

linear displacement in meters

double get_linear_velocity() const

Get the linear velocity of the rotation sensor.

Returns:

linear velocity in meters per second

class Timer

Public Functions

void reset()

Reset the Timer.

double get_start_time()

Get the start time of the Timer.

Returns:

start time

double get_current_time()

Get the current time.

Returns:

the current time

double get_elapsed_time()

Get the elapsed time since the timer started.

Returns:

elapsed time