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.
110 lines
2.7 KiB
C++
110 lines
2.7 KiB
C++
#include <gtest/gtest.h>
|
|
#include <vanetza/common/manual_runtime.hpp>
|
|
#include <vanetza/common/position_provider.hpp>
|
|
#include <vanetza/geonet/mib.hpp>
|
|
#include <vanetza/geonet/position_updater.hpp>
|
|
#include <vanetza/geonet/router.hpp>
|
|
#include <chrono>
|
|
|
|
using namespace vanetza;
|
|
using namespace vanetza::geonet;
|
|
using namespace std::chrono;
|
|
|
|
class IncrementalPositionProvider : public PositionProvider
|
|
{
|
|
public:
|
|
const PositionFix& position_fix() override
|
|
{
|
|
next_position();
|
|
return position;
|
|
}
|
|
|
|
private:
|
|
void next_position()
|
|
{
|
|
++updates;
|
|
position.latitude = updates * 3.0 * units::degree;
|
|
position.longitude = updates * -1.5 * units::degree;
|
|
position.confidence.semi_minor = 25.0 * units::si::meter;
|
|
position.confidence.semi_major = 25.0 * units::si::meter;
|
|
}
|
|
|
|
unsigned updates = 0;
|
|
PositionFix position;
|
|
};
|
|
|
|
class PositionUpdaterTest : public ::testing::Test
|
|
{
|
|
public:
|
|
PositionUpdaterTest() :
|
|
router(runtime, mib), updater(runtime, positioning, router)
|
|
{
|
|
}
|
|
|
|
void SetUp() override
|
|
{
|
|
mib.itsGnSecurity = false; /*< no security entity required */
|
|
mib.itsGnMinimumUpdateFrequencyEPV = 1.0 * units::si::hertz;
|
|
}
|
|
|
|
unsigned lpv_updates()
|
|
{
|
|
units::GeoAngle latitude { router.get_local_position_vector().latitude };
|
|
return latitude.value() / 3;
|
|
}
|
|
|
|
protected:
|
|
ManualRuntime runtime;
|
|
MIB mib;
|
|
Router router;
|
|
IncrementalPositionProvider positioning;
|
|
PositionUpdater updater;
|
|
};
|
|
|
|
TEST_F(PositionUpdaterTest, default_update_rate)
|
|
{
|
|
EXPECT_EQ(0, lpv_updates());
|
|
runtime.trigger(milliseconds(950));
|
|
EXPECT_EQ(0, lpv_updates());
|
|
runtime.trigger(milliseconds(60));
|
|
EXPECT_EQ(1, lpv_updates());
|
|
runtime.trigger(seconds(1));
|
|
EXPECT_EQ(2, lpv_updates());
|
|
runtime.trigger(seconds(1));
|
|
EXPECT_EQ(3, lpv_updates());
|
|
}
|
|
|
|
TEST_F(PositionUpdaterTest, custom_update_interval)
|
|
{
|
|
updater.update_rate(seconds(10));
|
|
runtime.trigger(seconds(9));
|
|
EXPECT_EQ(0, lpv_updates());
|
|
runtime.trigger(seconds(1));
|
|
EXPECT_EQ(1, lpv_updates());
|
|
runtime.trigger(seconds(10));
|
|
EXPECT_EQ(2, lpv_updates());
|
|
}
|
|
|
|
TEST_F(PositionUpdaterTest, custom_update_frequency)
|
|
{
|
|
updater.update_rate(4.0 * units::si::hertz);
|
|
runtime.trigger(milliseconds(250));
|
|
EXPECT_EQ(1, lpv_updates());
|
|
runtime.trigger(milliseconds(250));
|
|
EXPECT_EQ(2, lpv_updates());
|
|
}
|
|
|
|
TEST_F(PositionUpdaterTest, zero_hertz)
|
|
{
|
|
updater.update_rate(0.0 * units::si::hertz);
|
|
runtime.trigger(seconds(60));
|
|
EXPECT_EQ(0, lpv_updates());
|
|
}
|
|
|
|
TEST_F(PositionUpdaterTest, negative_interval)
|
|
{
|
|
updater.update_rate(milliseconds(-200));
|
|
runtime.trigger(seconds(60));
|
|
EXPECT_EQ(0, lpv_updates());
|
|
}
|