RIT VEXU Core API
|
#include <odometry_base.h>
Public Member Functions | |
OdometryBase (bool is_async) | |
virtual Pose2d | get_position (void) |
virtual void | set_position (const Pose2d &newpos=zero_pos) |
virtual Pose2d | update ()=0 |
void | end_async () |
virtual double | get_speed () |
virtual 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 | 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 | |
vex::task * | handle |
vex::mutex | mut |
Pose2d | 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.
|
virtual |
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
|
virtual |
Gets the current position and rotation
Gets the current position and rotation
|
virtual |
Get the current speed
|
virtual |
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.
double OdometryBase::accel |
the rate at which we are accelerating (inch/s^2)
double OdometryBase::ang_accel_deg |
the rate at which we are accelerating our turn (deg/s^2)
double OdometryBase::ang_speed_deg |
the speed at which we are turning (deg/s)
Pose2d OdometryBase::current_pos |
Current position of the robot in terms of x,y,rotation
vex::task* OdometryBase::handle |
handle to the vex task that is running the odometry code
vex::mutex OdometryBase::mut |
Mutex to control multithreading
double OdometryBase::speed |
the speed at which we are travelling (inch/s)