Keep the colleague's microbu-esp32c5 tree in this repository
obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
#ifndef AREAS_HPP_CVK1NIAI
|
||||
#define AREAS_HPP_CVK1NIAI
|
||||
|
||||
#include <vanetza/geodesy/geodesy.hpp>
|
||||
#include <vanetza/units/area.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
namespace geonet
|
||||
{
|
||||
|
||||
using geodesy::CartesianPosition;
|
||||
using geodesy::GeodeticPosition;
|
||||
using geodesy::distance;
|
||||
using geodesy::local_cartesian;
|
||||
|
||||
struct Circle
|
||||
{
|
||||
Circle() : r(1.0 * units::si::meters) {}
|
||||
units::Length r; // radius
|
||||
};
|
||||
|
||||
struct Rectangle
|
||||
{
|
||||
Rectangle() : a(1.0 * units::si::meters), b(1.0 * units::si::meters) {}
|
||||
units::Length a; // center to long side
|
||||
units::Length b; // center to short side
|
||||
};
|
||||
|
||||
struct Ellipse
|
||||
{
|
||||
Ellipse() : a(1.0 * units::si::meters), b(1.0 * units::si::meters) {}
|
||||
units::Length a; // long semi-axis
|
||||
units::Length b; // short semi-axis
|
||||
};
|
||||
|
||||
struct Area
|
||||
{
|
||||
boost::variant<Rectangle, Ellipse, Circle> shape;
|
||||
GeodeticPosition position;
|
||||
units::Angle angle;
|
||||
};
|
||||
|
||||
double geometric_function(const Circle&, const CartesianPosition&);
|
||||
double geometric_function(const Rectangle&, const CartesianPosition&);
|
||||
double geometric_function(const Ellipse&, const CartesianPosition&);
|
||||
double geometric_function(const decltype(Area::shape)&, const CartesianPosition&);
|
||||
|
||||
/**
|
||||
* Canonicalize a point in a shape's coordinate system w.r.t. its azimuth angle
|
||||
* \param point Point to canonicalize
|
||||
* \param azimuth Azimuth angle of shape's long side
|
||||
* \return canonical position (suitable for geometric_function)
|
||||
*/
|
||||
CartesianPosition canonicalize(const CartesianPosition& point, units::Angle azimuth);
|
||||
|
||||
/**
|
||||
* Check if positon is within or at border of area
|
||||
* \param area with shape, dimensions, azimuth and center point position
|
||||
* \param position Geodetic position to check against area
|
||||
* \return true if position is inside or at border
|
||||
*/
|
||||
bool inside_or_at_border(const Area&, const GeodeticPosition&);
|
||||
|
||||
/**
|
||||
* Calculate area size in square km.
|
||||
* \param area Area object
|
||||
* \return area size
|
||||
*/
|
||||
units::Area area_size(const Area&);
|
||||
|
||||
template<class SHAPE>
|
||||
bool inside_shape(const SHAPE& shape, const CartesianPosition& p)
|
||||
{
|
||||
return geometric_function(shape, p) > 0.0;
|
||||
}
|
||||
|
||||
template<class SHAPE>
|
||||
bool outside_shape(const SHAPE& shape, const CartesianPosition& p)
|
||||
{
|
||||
return geometric_function(shape, p) < 0.0;
|
||||
}
|
||||
|
||||
template<class SHAPE>
|
||||
bool at_shape_border(const SHAPE& shape, const CartesianPosition& p)
|
||||
{
|
||||
return geometric_function(shape, p) == 0.0;
|
||||
}
|
||||
|
||||
template<class SHAPE>
|
||||
bool at_center_point(const SHAPE& shape, const CartesianPosition& p)
|
||||
{
|
||||
return geometric_function(shape, p) == 1.0;
|
||||
}
|
||||
|
||||
} // namespace geonet
|
||||
} // namespace vanetza
|
||||
|
||||
#endif /* AREAS_HPP_CVK1NIAI */
|
||||
|
||||
Reference in New Issue
Block a user