Skip to content
Snippets Groups Projects
Commit d1c59f3e authored by Riccardo Musso's avatar Riccardo Musso Committed by Emilio Corigliano
Browse files

[Converter] implemented simple convertion function from NED to angles

parent ebc398f9
No related branches found
No related tags found
1 merge request!48[GS, ARP] New entrypoint for lyra_gs and ARP related things
...@@ -104,3 +104,6 @@ add_executable(nokia-groundstation-entry ...@@ -104,3 +104,6 @@ add_executable(nokia-groundstation-entry
) )
target_include_directories(nokia-groundstation-entry PRIVATE ${OBSW_INCLUDE_DIRS}) target_include_directories(nokia-groundstation-entry PRIVATE ${OBSW_INCLUDE_DIRS})
sbs_target(nokia-groundstation-entry stm32f429zi_skyward_groundstation_v2) sbs_target(nokia-groundstation-entry stm32f429zi_skyward_groundstation_v2)
add_executable(automated-antennas-entry src/entrypoints/Groundstation/automated-antennas-entry.cpp)
sbs_target(automated-antennas-entry stm32f407vg_stm32f4discovery)
#pragma once
#include <cmath>
struct NEDCoords
{
float n = 0;
float e = 0;
float d = 0;
};
struct AntennaAngles
{
float theta1 = 0;
float theta2 = 0;
};
AntennaAngles rocketPositionToAntennaAngles(const NEDCoords& ned)
{
AntennaAngles angles;
angles.theta1 = std::atan2(ned.n, ned.e);
angles.theta2 = std::atan2(-ned.d, ned.n);
return angles;
}
\ No newline at end of file
#include <drivers/timer/TimestampTimer.h>
#include <miosix.h>
#include "AutomatedAntennas/Converter.h"
using namespace miosix;
using namespace Boardcore;
inline float randf() { return (std::rand() % 200 - 100) / 100.f; }
int main()
{
constexpr int N = 10000;
printf("Starting test\n");
uint64_t start = TimestampTimer::getTimestamp();
for (int i = 0; i < N; i++)
{
NEDCoords coords = {randf(), randf(), randf()};
AntennaAngles angles = rocketPositionToAntennaAngles(coords);
printf("NED: %.2f ; %.2f ; %.2f -> Angles %.2f ; %.2f\n", coords.n,
coords.e, coords.d, angles.theta1, angles.theta2);
}
uint64_t end = TimestampTimer::getTimestamp();
printf("Took %lld millis for %d calls.\n", (end - start) / 1000ull, N);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment