Skip to content

Commit

Permalink
initial vectornav documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
abbymartin committed Sep 22, 2024
1 parent 0861410 commit 3ced373
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/interfaces/include/SABInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "AnalogSensorsInterface.h"

/**
* The SAB Interface receieves CAN messages containing load cell and potentionmeter readings.
* The SAB Interface receieves CAN messages containing load cell and potentilmeter readings.
* Through this interface values are parsed, updated, and converted to real units.
*/
class SABInterface
Expand All @@ -25,7 +25,7 @@ class SABInterface
AnalogChannel pot4;

/**
* Constructor that defines conversion for both load cells and potentionmeter data
* Constructor that defines conversion for both load cells and potentiometer data
* Defined offset and scale values from MCU_rev15_defs are used to convert from raw data to correct units (pounds)
*/
SABInterface(
Expand Down
92 changes: 85 additions & 7 deletions lib/interfaces/include/VectornavInterface.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#ifndef VECTORNAVINTERFACE
#define VECTORNAVINTERFACE

/* Library */
#include "FlexCAN_T4.h"
#include "hytech.h"

/**
* Struct that holds gps, velocity/accel, and gyro data
*/
struct vector_nav {
float velocity_x;
float velocity_y;
Expand All @@ -18,44 +23,117 @@ struct vector_nav {
double longitude;
double ecef_coords[3]; // x,y,z
uint64_t gps_time; // gps time
uint8_t vn_status; // status
xyz_vec<float> angular_rates;
uint8_t vn_status; // Vectornav status
xyz_vec<float> angular_rates; //TODO WHAT IS THIS
};


/**
* Generic data type for CAN message queue
*/
template <typename message_queue>

/**
* Interface for the VectorNAV. The VectorNAV is our GPS/IMU and it gives
* extremely precise position and orientation data for the car.
*/
template <typename message_queue>
class VNInterface
{
private:
/* Watchdog last kicked time */
/**
* Circular buffer for CAN message queue.
*/
message_queue *msg_queue_;

/**
* CAN ID
* Value is accessible with a getter but doesn't seem to be used
*/
uint32_t can_id_;

/**
* Instance of vector_nav struct that holds data parsed from CAN message
*/
vector_nav vn_data;

public:
/**
* Constructor that sets msg_queue_ buffer to pointer to actual CAN output
*/
VNInterface(message_queue *msg_output_queue) {
msg_queue_ = msg_output_queue;
};

// retrieve methods
/**
* Functions to process received CAN message
* Updates appropriate vn_data fields with data unpacked and converted according to formulas in hytech.h
*/

/**
* Updates velocity x, y, and z values.
*/
void retrieve_velocity_CAN(CAN_message_t &recvd_msg);

/**
* Updates linear_accel x, y and z values.
*/
void retrieve_linear_accel_CAN(CAN_message_t &recvd_msg);

/**
* Updates values for 3D uncompensated linear acceleration
* Stored in an array rather than individual x, y, z values
*/
void retrieve_uncompLinear_accel_CAN(CAN_message_t &recvd_msg);

/**
* Updates yaw, pitch, and roll values
*/
void retrieve_ypr_CAN(CAN_message_t &recvd_msg);

/**
* Updates lattitude and longitude values
*/
void retrieve_lat_lon_CAN(CAN_message_t &recvd_msg);

/**
* Updates time value (units?) from GPS
*/
void retrieve_gps_time_CAN(CAN_message_t &recvd_msg);

/**
* Updates vn_status
* TODO - what type of values are these
*/
void retrieve_vn_status_CAN(CAN_message_t &recvd_msg);

/**
* Updates position x/y coordinates
* ECEF = Earth-centered Earth-fixed coordinates
*/
void retrieve_vn_ecef_pos_xy_CAN(CAN_message_t &recvd_msg);

/**
* Updates position z coordinate
* ECEF = Earth-centered Earth-fixed coordinates
* Stored in same array as x/y
*/
void retrieve_vn_ecef_pos_z_CAN(CAN_message_t &recvd_msg);

/**
* Updates x, y, and z angular velocity rate
*/
void receive_ang_rates_CAN(CAN_message_t &recvd_msg);
// getters

/**
* Getter for vn_data struct
*/
vector_nav get_vn_struct();

/**
* Getter for CAN ID
* Not actually used atm?
*/
uint32_t get_id() { return can_id_;};
};
#include "VectornavInterface.tpp"
#endif /* __WATCHDOG_INTERFACE_H__ */
#endif /* __VECTORNAV_INTERFACE_H__ */

0 comments on commit 3ced373

Please sign in to comment.