Skip to content
Snippets Groups Projects
Commit 2209133e authored by Nicolò Caruso's avatar Nicolò Caruso
Browse files

[ARP] Gyro separated angles log struct and fix logging

parent f8a35843
No related branches found
No related tags found
Loading
Pipeline #11108 failed
struct LogAngles
{
float roll, pitch, yaw;
LogAngles() : roll{0}, pitch{0}, yaw(0) {}
LogAngles(float Roll, float Pitch, float Yaw)
: roll{Roll}, pitch{Pitch}, yaw(Yaw)
{
}
void getAngles(float x, float y, float z)
{
this->roll = x * (180 / M_PI);
this->pitch = y * (180 / M_PI);
this->yaw = z * (180 / M_PI);
}
static std::string header() { return "Roll,Pitch,Yaw,quaternionZ\n"; }
void print(std::ostream& os) const
{
os << roll << "," << pitch << "," << yaw << "\n";
}
};
\ No newline at end of file
......@@ -21,6 +21,8 @@
*/
#include <drivers/timer/TimestampTimer.h>
#include <logAnglesData.h>
#include <logger/Logger.h>
#include <sensors/Vectornav/VN300/VN300.h>
#include <Eigen/Dense>
......@@ -36,31 +38,6 @@ using namespace Eigen;
using namespace miosix;
using namespace Boardcore;
struct LogAngles
{
float roll, pitch, yaw;
LogAngles() : roll{0}, pitch{0}, yaw(0) {}
LogAngles(float Roll, float Pitch, float Yaw)
: roll{Roll}, pitch{Pitch}, yaw(Yaw)
{
}
void getAngles(float x, float y, float z)
{
this->roll = x * (180 / M_PI);
this->pitch = y * (180 / M_PI);
this->yaw = z * (180 / M_PI);
}
static std::string header() { return "Roll,Pitch,Yaw,quaternionZ\n"; }
void print(std::ostream& os) const
{
os << roll << "," << pitch << "," << yaw << "\n";
}
};
void computeEulerAngles(const Vector3d& gyro, double dt, Vector3d& angles)
{
Vector3d body_rate = gyro;
......@@ -110,6 +87,8 @@ int main()
return 0;
}
Logger::getInstance().start();
uint64_t t0 = TimestampTimer::getTimestamp();
Vector3d angles = {0, 0, 0};
......@@ -123,7 +102,8 @@ int main()
sensor.sample();
sample = sensor.getLastSample();
Logger::getInstance().log(sample); // getting last sample & logs
Logger::getInstance().log<VN300Data>(
sample); // getting last sample & logs
Vector3d gyro = {sample.angularSpeedX, sample.angularSpeedY,
sample.angularSpeedZ};
......@@ -133,7 +113,7 @@ int main()
angles_log.getAngles(angles(0), angles(1), angles(2));
printf("Angles: %f, %f, %f\n", angles_log.pitch, angles_log.roll,
angles_log.yaw);
Boardcore::Logger::getInstance().log(angles_log);
Boardcore::Logger::getInstance().log<LogAngles>(angles_log);
t0 = TimestampTimer::getTimestamp();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment