The bench transmitter sent a parked car: one fixed position, speed 0, no heading, a CAM every second. It now simulates a car driving a loop through six waypoints around Berliner Tor on the real streets, which makes it a moving target for the app's map and the use case detection without taking a car out. The route is generated, not hand-traced. tools/make_route.py asks the OSRM demo server for a driving route through the waypoints and back to the first, thins the 371 street points to 103 (none more than 1.5 m off the line), and writes main/route_points.h. It also saves OSRM's answer (--offline rebuilds from it) and a map page to check the route before flashing. Each waypoint is sent with the direction towards the next one: without it, points on divided roads such as Beim Strohhause snapped to the opposite carriageway and the loop came out at 8.4 km of U-turns. With it the loop is 5.2 km, still including two turn-round detours that OSRM needs to reach the waypoints legally (Borgfelder Strasse / Anckelmannsplatz, and Nagelsweg / Norderstrasse / Repsoldstrasse). Route data (c) OpenStreetMap contributors, ODbL. main/route.c moves the car along the points. It cruises at 50 km/h and limits each bend to the speed that keeps sideways acceleration at 2 m/s^2, so a junction turn is taken at about 15 km/h and a gentle curve barely slows it; braking (2 m/s^2) and acceleration (1.5 m/s^2) are planned across as many points as a bend needs. A simulated lap on the host is 5.16 km in 7.7 min, averaging 40 km/h. CAMs now follow the EN 302 637-2 generation rules instead of a fixed 1 Hz: checked every 100 ms, sent on a heading change over 4 degrees, a move over 4 m, a speed change over 0.5 m/s, or after 1 s - about 3 Hz at 50 km/h. generationDeltaTime is milliseconds since boot. The GeoNetworking source position vector now carries the same speed and heading as the CAM instead of zeros. NOTES.md gains build and flash steps (including reading a board's app descriptor first, since both firmwares name their image obu_firmware.bin) and a section on the simulated drive. The pointer to docs/04-transmit-setup.md is corrected: that file is not in the repo. Flashed to the COM8 board and checked on its console: it starts driving on power-up and sends CAMs with changing position, speed and heading. Not yet received over the air.
41 lines
1.7 KiB
C
41 lines
1.7 KiB
C
#ifndef ROUTE_H
|
|
#define ROUTE_H
|
|
#include <stdint.h>
|
|
|
|
// Simulated drive around a closed loop of waypoints, so the beacon looks like a
|
|
// car going round the block instead of a parked one.
|
|
//
|
|
// The car follows straight lines between the points and goes from the last one
|
|
// back to the first, forever. For street-following, the points are the street
|
|
// geometry from tools/make_route.py (main/route_points.h). Speed is a function
|
|
// of where the car is on a segment: it cruises, brakes ahead of each bend down to
|
|
// the speed that bend allows, and accelerates away after it. Heading is the
|
|
// bearing of the current segment.
|
|
//
|
|
// Uses only standard headers, so it also compiles on the host for testing.
|
|
|
|
typedef struct {
|
|
int32_t latitude_tenmicrodeg; // 1/10 microdegree, same units as the CAM
|
|
int32_t longitude_tenmicrodeg;
|
|
} route_point_t;
|
|
|
|
typedef struct {
|
|
int32_t latitude_tenmicrodeg;
|
|
int32_t longitude_tenmicrodeg;
|
|
uint16_t speed_cm_s; // SpeedValue units (0.01 m/s)
|
|
uint16_t heading_ddeg; // HeadingValue units (0.1 deg, 0..3599, 0 = north, clockwise)
|
|
int segment; // index of the route point the car last passed
|
|
} route_state_t;
|
|
|
|
#define ROUTE_MAX_POINTS 512 // keep in step with MAX_POINTS in tools/make_route.py
|
|
|
|
// `points` must stay valid for as long as the route is used. Returns 0, or -1
|
|
// if n is out of range (2..ROUTE_MAX_POINTS) or a segment has zero length.
|
|
// min_corner_mps is the slowest the car ever goes (hairpins, U-turns).
|
|
int route_init(const route_point_t *points, int n, double cruise_mps, double min_corner_mps);
|
|
|
|
// Moves the car on by dt_s seconds and writes its new position into `out`.
|
|
void route_step(double dt_s, route_state_t *out);
|
|
|
|
#endif
|