Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
obu-firmware builds against the vanetza-idf C-ITS library, which until now came from the colleague's microbu-esp32c5 tree beside the repository and was not tracked here, so a clone of this repository could not build the firmware it ships. The library alone is now part of obu-firmware, as obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from there by default; -DVANETZA_IDF_DIR still points the build elsewhere. The rest of the colleague's tree (their own VAM firmware, PKI tooling, station-link Python tools, the V2X2MAP bridge) stays out of this repository and gitignored; nothing is pushed to their repository. NOTES.md, docs/06, TODO.md and the pcap verifier's usage line point at the new location.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include <vanetza/common/position_fix.hpp>
|
||||
#include <vanetza/asn1/security_profile.hpp>
|
||||
#include VANETZA_ASN1_SECURITY_HEADER(Latitude.h)
|
||||
#include VANETZA_ASN1_SECURITY_HEADER(Longitude.h)
|
||||
#include VANETZA_ASN1_SECURITY_HEADER(TwoDLocation.h)
|
||||
#include <vanetza/security/v3/distance.hpp>
|
||||
#include <boost/units/cmath.hpp>
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
namespace security
|
||||
{
|
||||
namespace v3
|
||||
{
|
||||
|
||||
units::Length distance(const PositionFix& one, const asn1::TwoDLocation& other)
|
||||
{
|
||||
static const auto earth_radius = 6371000.0 * units::si::meter;
|
||||
const auto other_lat = convert_latitude(other.latitude);
|
||||
const auto other_lon = convert_longitude(other.longitude);
|
||||
const units::Angle delta_phi { one.latitude - other_lat };
|
||||
const units::Angle delta_lambda { one.longitude - other_lon };
|
||||
const auto sin_delta_phi = sin(delta_phi / 2.0);
|
||||
const auto sin_delta_lambda = sin(delta_lambda / 2.0);
|
||||
const auto a = sin_delta_phi * sin_delta_phi +
|
||||
cos(one.latitude) * cos(other_lat) * sin_delta_lambda * sin_delta_lambda;
|
||||
const auto c = 2.0 * atan2(sqrt(a), sqrt(1 - a));
|
||||
return earth_radius * c;
|
||||
}
|
||||
|
||||
units::GeoAngle convert_latitude(const asn1::Latitude& in)
|
||||
{
|
||||
static constexpr long latitude_scale = Vanetza_Security_NinetyDegreeInt_max;
|
||||
if (in >= Vanetza_Security_NinetyDegreeInt_min && in <= Vanetza_Security_NinetyDegreeInt_max) {
|
||||
return in * 90.0 / latitude_scale * units::degree;
|
||||
} else {
|
||||
return units::GeoAngle::from_value(std::numeric_limits<double>::quiet_NaN());
|
||||
}
|
||||
}
|
||||
|
||||
units::GeoAngle convert_longitude(const asn1::Longitude& in)
|
||||
{
|
||||
static constexpr long longitude_scale = Vanetza_Security_OneEightyDegreeInt_max;
|
||||
if (in >= Vanetza_Security_OneEightyDegreeInt_min && in <= Vanetza_Security_OneEightyDegreeInt_max) {
|
||||
return in * 180.0 / longitude_scale * units::degree;
|
||||
} else {
|
||||
return units::GeoAngle::from_value(std::numeric_limits<double>::quiet_NaN());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace v3
|
||||
} // namespace security
|
||||
} // namespace vanetza
|
||||
Reference in New Issue
Block a user