RIT VEXU Core API
|
#include <odometry_base.h>
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 |
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.
OdometryBase::OdometryBase | ( | bool | is_async | ) |
Construct a new Odometry Base object
is_async | True to run constantly in the background, false to call update() manually |
|
static |
Function that runs in the background task. This function pointer is passed to the vex::task constructor.
ptr | Pointer to OdometryBase object |
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.
double OdometryBase::get_accel | ( | ) |
Get the current acceleration
double OdometryBase::get_angular_accel_deg | ( | ) |
Get the current angular acceleration in degrees
double OdometryBase::get_angular_speed_deg | ( | ) |
Get the current angular speed in degrees
pose_t OdometryBase::get_position | ( | void | ) |
Gets the current position and rotation
Gets the current position and rotation
double OdometryBase::get_speed | ( | ) |
Get the current speed
Get the distance between two points
start_pos | distance from this point |
end_pos | to this point |
Get the change in rotation between two points
pos1 | position with initial rotation |
pos2 | position with final rotation |
Get the change in rotation between two points
Sets the current position of the robot
newpos | the new position that the odometry will believe it is at |
Sets the current position of the robot
Reimplemented in OdometryTank.
|
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.
start_deg | intitial angle (degrees) |
end_deg | final angle (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.
|
pure virtual |
Update the current position on the field based on the sensors
Implemented in Odometry3Wheel, and OdometryTank.
|
protected |
the rate at which we are accelerating (inch/s^2)
|
protected |
the rate at which we are accelerating our turn (deg/s^2)
|
protected |
the speed at which we are turning (deg/s)
|
protected |
Current position of the robot in terms of x,y,rotation
|
protected |
handle to the vex task that is running the odometry code
|
protected |
Mutex to control multithreading
|
protected |
the speed at which we are travelling (inch/s)
|
inlinestaticconstexpr |
Zeroed position. X=0, Y=0, Rotation= 90 degrees