Variable VCM frequency based on curvature change
This commit is contained in:
parent
8e38340b3a
commit
5441c102cb
|
|
@ -63,11 +63,6 @@ cleanup:
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int edm_decap(uint8_t* data, uint16_t data_len, int its_msg_type) {
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void edm_init() {
|
void edm_init() {
|
||||||
facilities.edm.app_socket = itss_0connect(facilities.zmq.applications_address, ZMQ_REQ);
|
facilities.edm.app_socket = itss_0connect(facilities.zmq.applications_address, ZMQ_REQ);
|
||||||
pthread_mutex_init(&facilities.edm.lock, NULL);
|
pthread_mutex_init(&facilities.edm.lock, NULL);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,5 @@ typedef struct edm {
|
||||||
} edm_t;
|
} edm_t;
|
||||||
|
|
||||||
int edm_encap(uint8_t* msg, uint16_t* msg_len, uint16_t msg_buf_len, int its_msg_type);
|
int edm_encap(uint8_t* msg, uint16_t* msg_len, uint16_t msg_buf_len, int its_msg_type);
|
||||||
int edm_decap(uint8_t* data, uint16_t data_len, int its_msg_type);
|
|
||||||
|
|
||||||
void edm_init();
|
void edm_init();
|
||||||
|
|
|
||||||
43
src/vcm.c
43
src/vcm.c
|
|
@ -12,6 +12,10 @@
|
||||||
#include <it2s-asn/itss-management/ManagementRequest.h>
|
#include <it2s-asn/itss-management/ManagementRequest.h>
|
||||||
#include <it2s-asn/vcm/VCM.h>
|
#include <it2s-asn/vcm/VCM.h>
|
||||||
|
|
||||||
|
#include <tgmath.h>
|
||||||
|
|
||||||
|
#define TRAJECTORY_C_TH 1.0
|
||||||
|
|
||||||
static int do_paths_intersect(
|
static int do_paths_intersect(
|
||||||
itss_st_t* tA, int tA_len, uint16_t vA_length, uint16_t vA_width,
|
itss_st_t* tA, int tA_len, uint16_t vA_length, uint16_t vA_width,
|
||||||
itss_st_t* tB, int tB_len, uint16_t vB_length, uint16_t vB_width,
|
itss_st_t* tB, int tB_len, uint16_t vB_length, uint16_t vB_width,
|
||||||
|
|
@ -135,6 +139,7 @@ static void tx_vcm(VCM_t* vcm) {
|
||||||
|
|
||||||
itss_queue_send(facilities.tx_queue, buf, enc.encoded+1, ITSS_APPLICATIONS, bpr->id, "FI.message");
|
itss_queue_send(facilities.tx_queue, buf, enc.encoded+1, ITSS_APPLICATIONS, bpr->id, "FI.message");
|
||||||
|
|
||||||
|
log_warn("Last VCM sent %d ms ago", itss_time_get() - facilities.coordination.t_last_send_vcm);
|
||||||
facilities.coordination.t_last_send_vcm = itss_time_get();
|
facilities.coordination.t_last_send_vcm = itss_time_get();
|
||||||
|
|
||||||
if (facilities.logging.recorder) {
|
if (facilities.logging.recorder) {
|
||||||
|
|
@ -1131,7 +1136,43 @@ static bool vcm_timer_check(coordination_t* coordination, uint64_t now) {
|
||||||
bool send = false;
|
bool send = false;
|
||||||
|
|
||||||
if (now > coordination->t_last_send_vcm + coordination->vcm_period_max) {
|
if (now > coordination->t_last_send_vcm + coordination->vcm_period_max) {
|
||||||
send = true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (now < coordination->t_last_send_vcm + coordination->vcm_period_min) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (facilities.station_type != StationType_roadSideUnit) { // Vehicle
|
||||||
|
|
||||||
|
itss_trajectory_lock();
|
||||||
|
|
||||||
|
if (epv.trajectory.len > 2) {
|
||||||
|
|
||||||
|
double c_sum = 0;
|
||||||
|
for (int i = 0; i < epv.trajectory.len - 2; ++i) {
|
||||||
|
double d1 = itss_haversine(
|
||||||
|
epv.trajectory.path[i+1].latitude / 1.0e7,
|
||||||
|
epv.trajectory.path[i+1].longitude / 1.0e7,
|
||||||
|
epv.trajectory.path[i].latitude / 1.0e7,
|
||||||
|
epv.trajectory.path[i].longitude / 1.0e7);
|
||||||
|
double t1 = atan2(
|
||||||
|
epv.trajectory.path[i+1].latitude - epv.trajectory.path[i].latitude ,
|
||||||
|
epv.trajectory.path[i+1].longitude - epv.trajectory.path[i].longitude);
|
||||||
|
double t2 = atan2(
|
||||||
|
epv.trajectory.path[i+2].latitude - epv.trajectory.path[i].latitude ,
|
||||||
|
epv.trajectory.path[i+2].longitude - epv.trajectory.path[i].longitude);
|
||||||
|
c_sum += fabs(sin(t2-t1)*d1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fabs(c_sum - coordination->previous_c) > TRAJECTORY_C_TH) {
|
||||||
|
send = true;
|
||||||
|
coordination->previous_c = c_sum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itss_trajectory_unlock(epv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return send;
|
return send;
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ typedef struct coordination {
|
||||||
uint64_t t_last_send_vcm; /* timestamp of last sent (basic) VCM */
|
uint64_t t_last_send_vcm; /* timestamp of last sent (basic) VCM */
|
||||||
uint64_t vcm_period_min;
|
uint64_t vcm_period_min;
|
||||||
uint64_t vcm_period_max;
|
uint64_t vcm_period_max;
|
||||||
|
double previous_c;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
VCM_t* own_req; /* last VCM.request sent */
|
VCM_t* own_req; /* last VCM.request sent */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue