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

#include <odometry_serial.h>

Inheritance diagram for OdometrySerial:
OdometryBase

Public Member Functions

 OdometrySerial (bool is_async, bool calc_vel_acc_on_brain, Pose2d initial_pose, Pose2d sensor_offset, int32_t port, int32_t baudrate)
 
void send_config (const Pose2d &initial_pose, const Pose2d &sensor_offset, const bool &calc_vel_acc_on_brain)
 
Pose2d update () override
 
void set_position (const Pose2d &new_pose) override
 
int receive_cobs_packet (uint32_t port, uint8_t *buffer, size_t buffer_size)
 
Pose2d get_position (void) override
 
Pose2d get_pose2d (void)
 
size_t cobs_decode (const uint8_t *buffer, size_t length, void *data)
 
size_t cobs_encode (const void *data, size_t length, uint8_t *buffer)
 
- Public Member Functions inherited from OdometryBase
 OdometryBase (bool is_async)
 
void end_async ()
 
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 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
 
vex::task * handle
 
vex::mutex mut
 
Pose2d current_pos
 
double speed
 
double accel
 
double ang_speed_deg
 
double ang_accel_deg
 

Detailed Description

OdometrySerial

This class handles the code for an odometry setup where calculations are done on an external coprocessor. Data is sent to the brain via smart port, using a generic serial (UART) connection.

This is a "set and forget" class, meaning once the object is created, the robot will immediately begin tracking it's movement in the background.

https://rit.enterprise.slack.com/files/U04112Y5RB6/F080M01KPA5/predictperpindiculars2.pdf 2024-2025 Notebook: Entries/Software Entries/Localization/N-Pod Odometry

Author
Jack Cammarata
Date
Jan 16 2025

Constructor & Destructor Documentation

◆ OdometrySerial()

OdometrySerial::OdometrySerial ( bool is_async,
bool calc_vel_acc_on_brain,
Pose2d initial_pose,
Pose2d sensor_offset,
int32_t port,
int32_t baudrate )

Construct a new Odometry Serial Object

OdometrySerial

This class handles the code for an odometry setup where calculations are done on an external coprocessor. Data is sent to the brain via smart port, using a generic serial (UART) connection.

This is a "set and forget" class, meaning once the object is created, the robot will immediately begin tracking it's movement in the background.

https://rit.enterprise.slack.com/files/U04112Y5RB6/F080M01KPA5/predictperpindiculars2.pdf 2024-2025 Notebook: Entries/Software Entries/Localization/N-Pod Odometry

Author
Jack Cammarata
Date
Jan 16 2025 Construct a new Odometry Serial Object

Member Function Documentation

◆ cobs_decode()

size_t OdometrySerial::cobs_decode ( const uint8_t * buffer,
size_t length,
void * data )

COBS decode data from buffer

Parameters
bufferPointer to encoded input bytes
lengthNumber of bytes to decode
dataPointer to decoded output data
Returns
Number of bytes successfully decoded
Note
Stops decoding if delimiter byte is found

◆ cobs_encode()

size_t OdometrySerial::cobs_encode ( const void * data,
size_t length,
uint8_t * buffer )

COBS encode data to buffer

Parameters
dataPointer to input data to encode
lengthNumber of bytes to encode
bufferPointer to encoded output buffer
Returns
Encoded buffer length in bytes
Note
Does not output delimiter byte

◆ get_pose2d()

Pose2d OdometrySerial::get_pose2d ( void )

Gets the current position and rotation

Returns
the position that the odometry believes the robot is at

◆ get_position()

Pose2d OdometrySerial::get_position ( void )
overridevirtual

Gets the current position and rotation

Returns
the position that the odometry believes the robot is at

Reimplemented from OdometryBase.

◆ receive_cobs_packet()

int OdometrySerial::receive_cobs_packet ( uint32_t port,
uint8_t * buffer,
size_t buffer_size )

Attempts to recieve an entire packet encoded with COBS, stops at delimiter or there's a buffer overflow

Parameters
portthe port number the serial is plugged into, counts from 0 instead of 1
bufferpointer to a uint8_t[] where we put the data
buffer_sizelength in bytes of the buffer
Returns
0 success

◆ send_config()

void OdometrySerial::send_config ( const Pose2d & initial_pose,
const Pose2d & sensor_offset,
const bool & calc_vel_acc_on_brain )

Send

◆ set_position()

void OdometrySerial::set_position ( const Pose2d & new_pose)
overridevirtual

Resets the position and rotational data to the input.

Resets the position and rotational data to the input.

Parameters
new_posethe pose to set the odometry to

Reimplemented from OdometryBase.

◆ update()

Pose2d OdometrySerial::update ( )
overridevirtual

Update the current position of the robot once by reading a single packet from the serial port

Returns
the robot's updated position

Update the current position of the robot once by reading a single packet from the serial port, then updating all over values, velocity, accel

Returns
the robot's updated position

Implements OdometryBase.


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