#include <random>
#include <ros/ros.h>
{
static constexpr double minimum = -180;
static constexpr double supremum = 180;
};
template <class T>
void printit(const T& a, const std::string& name)
{
std::cout << name << ":\t" << std::left << std::showpos << std::setprecision(4) << a.value() << "\tin [ " << a.minimum << ",\t" << a.supremum << "\t["
<< std::endl;
}
template <class T>
void printcont(const T& cont, const std::string& name)
{
std::cout << name << ":\t";
for (const auto& el : cont)
std::cout << el << "\t";
std::cout << std::endl;
}
int main()
{
degrees h = radians::convert<degrees>(5 * M_PI_2);
printit(a, "a");
printit(b, "b");
printit(c, "c");
printit(d, "d");
printit(e, "e");
printit(f, "f");
printit(g, "g");
printit(h, "h");
printit(WRONG1, "WRONG1");
double adouble = a.value();
double amin = a.minimum;
double asup = degrees::supremum;
std::cout << "adouble:" << std::left << std::showpos << std::setprecision(4) << adouble << "\tin [ " << amin << ",\t" << asup << "\t[\trange: " << aran
<< std::endl;
std::cout << "----------------------------------------------------------------" << std::endl;
double ang = 666;
{
std::cout << std::left << std::showpos << std::setprecision(4) << ang << "\tis not within [ " << degrees::minimum << ",\t" << degrees::supremum << "\t["
<< std::endl;
std::cout << std::left << std::showpos << std::setprecision(4) << ang << "\tafter wrapping: " << wang << std::endl;
}
std::vector<double> data = {0, 61, 122, 183, 244, 305, 6, 67, 128, 189};
printcont(data, "data before unwrapping");
for (size_t it = 1; it < data.size(); it++)
{
const auto prev = data.at(it - 1);
auto& cur = data.at(it);
}
printcont(data, "data after unwrapping");
for (auto& el : data)
printcont(data, "data after wrapping");
for (size_t it = 1; it < data.size(); it++)
{
const auto prev = data.at(it - 1);
auto& cur = data.at(it);
}
printcont(data, "data after unwrapping");
std::cout << "----------------------------------------------------------------" << std::endl;
std::cout << std::left << std::showpos << std::setprecision(4) << "A:\t" << A.value() << std::endl
<< "B:\t" << B.value() << std::endl
std::cout << std::left << std::showpos << std::setprecision(4) << "C:\t" << C.value() << std::endl
<< "D:\t" << D.value() << std::endl
std::cout << std::left << std::showpos << std::setprecision(4) << "E:\t" << E.value() << std::endl
<< "F:\t" << F.value() << std::endl
std::cout << "----------------------------------------------------------------" << std::endl;
double a1 = -359;
double a2 = -2;
double coeff = 1.0 / 3.0;
std::cout << std::left << std::showpos << std::setprecision(4) << "a1:\t" << a1 << std::endl
<< "a2:\t" << a2 << std::endl
<< "coeff:\t" << coeff << std::endl
<<
"interp(a1, a2, coeff):\t" <<
degrees::interp(a1, a2, coeff) << std::endl
return 0;
}