RIT VEXU Core API
Loading...
Searching...
No Matches
OdometryTank Class Reference

#include <odometry_tank.h>

Inheritance diagram for OdometryTank:
OdometryBase

Public Member Functions

 OdometryTank (vex::motor_group &left_side, vex::motor_group &right_side, robot_specs_t &config, vex::inertial *imu=NULL, bool is_async=true)
 
 OdometryTank (CustomEncoder &left_custom_enc, CustomEncoder &right_custom_enc, robot_specs_t &config, vex::inertial *imu=NULL, bool is_async=true)
 
 OdometryTank (vex::encoder &left_vex_enc, vex::encoder &right_vex_enc, robot_specs_t &config, vex::inertial *imu=NULL, bool is_async=true)
 
pose_t update () override
 
void set_position (const pose_t &newpos=zero_pos) override
 
- Public Member Functions inherited from OdometryBase
 OdometryBase (bool is_async)
 
pose_t get_position (void)
 
void end_async ()
 
double get_speed ()
 
double get_accel ()
 
double get_angular_speed_deg ()
 
double get_angular_accel_deg ()
 

Additional Inherited Members

- Static Public Member Functions inherited from OdometryBase
static int background_task (void *ptr)
 
static double pos_diff (pose_t start_pos, pose_t end_pos)
 
static double rot_diff (pose_t pos1, pose_t pos2)
 
static double smallest_angle (double start_deg, double end_deg)
 
- Public Attributes inherited from OdometryBase
bool end_task = false
 end_task is true if we instruct the odometry thread to shut down
 
- Static Public Attributes inherited from OdometryBase
static constexpr pose_t zero_pos = {.x = 0.0L, .y = 0.0L, .rot = 90.0L}
 
- Protected Attributes inherited from OdometryBase
vex::task * handle
 
vex::mutex mut
 
pose_t current_pos
 
double speed
 
double accel
 
double ang_speed_deg
 
double ang_accel_deg
 

Detailed Description

OdometryTank defines an odometry system for a tank drivetrain This requires encoders in the same orientation as the drive wheels Odometry is a "start and forget" subsystem, which means once it's created and configured, it will constantly run in the background and track the robot's X, Y and rotation coordinates.

Constructor & Destructor Documentation

◆ OdometryTank() [1/3]

OdometryTank::OdometryTank ( vex::motor_group & left_side,
vex::motor_group & right_side,
robot_specs_t & config,
vex::inertial * imu = NULL,
bool is_async = true )

Initialize the Odometry module, calculating position from the drive motors.

Parameters
left_sideThe left motors
right_sideThe right motors
configthe specifications that supply the odometry with descriptions of the robot. See robot_specs_t for what is contained
imuThe robot's inertial sensor. If not included, rotation is calculated from the encoders.
is_asyncIf true, position will be updated in the background continuously. If false, the programmer will have to manually call update().

◆ OdometryTank() [2/3]

OdometryTank::OdometryTank ( CustomEncoder & left_custom_enc,
CustomEncoder & right_custom_enc,
robot_specs_t & config,
vex::inertial * imu = NULL,
bool is_async = true )

Initialize the Odometry module, calculating position from the drive motors.

Parameters
left_custom_encThe left custom encoder
right_custom_encThe right custom encoder
configthe specifications that supply the odometry with descriptions of the robot. See robot_specs_t for what is contained
imuThe robot's inertial sensor. If not included, rotation is calculated from the encoders.
is_asyncIf true, position will be updated in the background continuously. If false, the programmer will have to manually call update().

◆ OdometryTank() [3/3]

OdometryTank::OdometryTank ( vex::encoder & left_vex_enc,
vex::encoder & right_vex_enc,
robot_specs_t & config,
vex::inertial * imu = NULL,
bool is_async = true )

Initialize the Odometry module, calculating position from the drive motors.

Parameters
left_vex_encThe left vex encoder
right_vex_encThe right vex encoder
configthe specifications that supply the odometry with descriptions of the robot. See robot_specs_t for what is contained
imuThe robot's inertial sensor. If not included, rotation is calculated from the encoders.
is_asyncIf true, position will be updated in the background continuously. If false, the programmer will have to manually call update().

Member Function Documentation

◆ set_position()

void OdometryTank::set_position ( const pose_t & newpos = zero_pos)
overridevirtual

set_position tells the odometry to place itself at a position

Parameters
newposthe position the odometry will take

Resets the position and rotational data to the input.

Reimplemented from OdometryBase.

◆ update()

pose_t OdometryTank::update ( )
overridevirtual

Update the current position on the field based on the sensors

Returns
the position that odometry has calculated itself to be at

Update, store and return the current position of the robot. Only use if not initializing with a separate thread.

Implements OdometryBase.


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