RIT VEXU Core API
Loading...
Searching...
No Matches
OdometryBase Class Referenceabstract

#include <odometry_base.h>

Inheritance diagram for OdometryBase:
Odometry3Wheel OdometryTank

Public Member Functions

 OdometryBase (bool is_async)
 
pose_t get_position (void)
 
virtual void set_position (const pose_t &newpos=zero_pos)
 
virtual pose_t update ()=0
 
void end_async ()
 
double get_speed ()
 
double get_accel ()
 
double get_angular_speed_deg ()
 
double get_angular_accel_deg ()
 

Static Public Member Functions

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

bool end_task = false
 end_task is true if we instruct the odometry thread to shut down
 

Static Public Attributes

static constexpr pose_t zero_pos = {.x = 0.0L, .y = 0.0L, .rot = 90.0L}
 

Protected Attributes

vex::task * handle
 
vex::mutex mut
 
pose_t current_pos
 
double speed
 
double accel
 
double ang_speed_deg
 
double ang_accel_deg
 

Detailed Description

OdometryBase

This base class contains all the shared code between different implementations of odometry. It handles the asynchronous management, position input/output and basic math functions, and holds positional types specific to field orientation.

All future odometry implementations should extend this file and redefine update() function.

Author
Ryan McGee
Date
Aug 11 2021

Constructor & Destructor Documentation

◆ OdometryBase()

OdometryBase::OdometryBase ( bool is_async)

Construct a new Odometry Base object

Parameters
is_asyncTrue to run constantly in the background, false to call update() manually

Member Function Documentation

◆ background_task()

int OdometryBase::background_task ( void * ptr)
static

Function that runs in the background task. This function pointer is passed to the vex::task constructor.

Parameters
ptrPointer to OdometryBase object
Returns
Required integer return code. Unused.

◆ end_async()

void OdometryBase::end_async ( )

End the background task. Cannot be restarted. If the user wants to end the thread but keep the data up to date, they must run the update() function manually from then on.

◆ get_accel()

double OdometryBase::get_accel ( )

Get the current acceleration

Returns
the acceleration rate of the robot (inch/s^2)

◆ get_angular_accel_deg()

double OdometryBase::get_angular_accel_deg ( )

Get the current angular acceleration in degrees

Returns
the angular acceleration at which we are turning (deg/s^2)

◆ get_angular_speed_deg()

double OdometryBase::get_angular_speed_deg ( )

Get the current angular speed in degrees

Returns
the angular velocity at which we are turning (deg/s)

◆ get_position()

pose_t OdometryBase::get_position ( void )

Gets the current position and rotation

Returns
the position that the odometry believes the robot is at

Gets the current position and rotation

◆ get_speed()

double OdometryBase::get_speed ( )

Get the current speed

Returns
the speed at which the robot is moving and grooving (inch/s)

◆ pos_diff()

double OdometryBase::pos_diff ( pose_t start_pos,
pose_t end_pos )
static

Get the distance between two points

Parameters
start_posdistance from this point
end_posto this point
Returns
the euclidean distance between start_pos and end_pos

◆ rot_diff()

double OdometryBase::rot_diff ( pose_t pos1,
pose_t pos2 )
static

Get the change in rotation between two points

Parameters
pos1position with initial rotation
pos2position with final rotation
Returns
change in rotation between pos1 and pos2

Get the change in rotation between two points

◆ set_position()

void OdometryBase::set_position ( const pose_t & newpos = zero_pos)
virtual

Sets the current position of the robot

Parameters
newposthe new position that the odometry will believe it is at

Sets the current position of the robot

Reimplemented in OdometryTank.

◆ smallest_angle()

double OdometryBase::smallest_angle ( double start_deg,
double end_deg )
static

Get the smallest difference in angle between a start heading and end heading. Returns the difference between -180 degrees and +180 degrees, representing the robot turning left or right, respectively.

Parameters
start_degintitial angle (degrees)
end_degfinal angle (degrees)
Returns
the smallest angle from the initial to the final angle. This takes into account the wrapping of rotations around 360 degrees

Get the smallest difference in angle between a start heading and end heading. Returns the difference between -180 degrees and +180 degrees, representing the robot turning left or right, respectively.

◆ update()

virtual pose_t OdometryBase::update ( )
pure virtual

Update the current position on the field based on the sensors

Returns
the location that the robot is at after the odometry does its calculations

Implemented in Odometry3Wheel, and OdometryTank.

Member Data Documentation

◆ accel

double OdometryBase::accel
protected

the rate at which we are accelerating (inch/s^2)

◆ ang_accel_deg

double OdometryBase::ang_accel_deg
protected

the rate at which we are accelerating our turn (deg/s^2)

◆ ang_speed_deg

double OdometryBase::ang_speed_deg
protected

the speed at which we are turning (deg/s)

◆ current_pos

pose_t OdometryBase::current_pos
protected

Current position of the robot in terms of x,y,rotation

◆ handle

vex::task* OdometryBase::handle
protected

handle to the vex task that is running the odometry code

◆ mut

vex::mutex OdometryBase::mut
protected

Mutex to control multithreading

◆ speed

double OdometryBase::speed
protected

the speed at which we are travelling (inch/s)

◆ zero_pos

constexpr pose_t OdometryBase::zero_pos = {.x = 0.0L, .y = 0.0L, .rot = 90.0L}
inlinestaticconstexpr

Zeroed position. X=0, Y=0, Rotation= 90 degrees


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