Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions Autopilot/Inc/VN300.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* VN300 Class to support the IMU and GPS drivers
*/

#ifndef VN300_HPP
#define VN300_HPP

template <typename Sensor>
class VN300 {

public:
Sensor getSensorInstance(){

// If instance is null, get it and set it
if (s_instance == nullptr){
s_instance = Sensor::getInstance();
}

//return
return s_instance;
}

private:

//A pointer to the existing class instance - nullptr if it doesnt exist
Sensor* s_instance;

};


struct VN300_GPSData{

//Position defining variables
double latitude; //in deg
double longitude; //in deg
double altitude; //in meters

//Velocity defining variables - they are defined as north, east and downwards positive
//All in m/s
float northVel;
float eastVel;
float downVel;

//Position accuracy estimates - indicate how accurate the position readings are
//All in meters
float northAcc;
float eastAcc;
float downAcc;

//Other useful accuracy variables
float speedAcc; //m/s
float timeAcc; //sec

//Other useful variables:

//Time of the GPS weeks in seconds
double time;

//The GPS week (1 GPS calendar is 1023 weeks)
uint16_t week;

//GNSS Fix type - consult user manual for more info
uint8_t gnssFix;

//Number of GNSS satellites being used
uint8_t numSats;
};


class VN300_GPS {

public:

//added to make sure people dont accidentally initialize
VN300_GPS(const VN300_GPS*) = delete;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait what does this do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not gonna lie I don't fully remember.

I copied this over from a previous singleton I wrote a while back - If I cant remember the reason for it I'll delete it


//Pulls new gps data from the VN300
void setGPSData();

//Returns GPS data struct
VN300_GPSData getGPSData();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get a bit more info on the gps data struct

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm it's above I found it i'm stupid


/*
* Called to either get the existing instance of the class, or create a new one if
* one currently does not exist
*/
static VN300_GPS* GetInstance();

private:

//Private constructor to prevent multiple instances
VN300_GPS();

int registerID;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would registerID do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly not too sure yet - I just left it there incase its eventually needed.

Will remove it if its not.


//A pointer to the existing class instance - nullptr if it doesnt exist
VN300_GPS* instance;

//Instance of struct to hold the gps data
VN300_GPSData data;

};
#endif