Fix generationDeltaTime
Signed-off-by: Tiago Garcia <tiago.rgarcia@av.it.pt>
This commit is contained in:
parent
f1b160d1f7
commit
579f6fe16f
|
@ -23,7 +23,7 @@ public:
|
||||||
void set_interval(vanetza::Clock::duration);
|
void set_interval(vanetza::Clock::duration);
|
||||||
void updateMGRS(double *, double *);
|
void updateMGRS(double *, double *);
|
||||||
void updateRP(double *, double *, double *);
|
void updateRP(double *, double *, double *);
|
||||||
void updateGenerationTime(int *, long *);
|
void updateGenerationDeltaTime(int *, long *);
|
||||||
void updateHeading(double *);
|
void updateHeading(double *);
|
||||||
void setVehicleDimensions(const autoware_adapi_v1_msgs::msg::VehicleDimensions &);
|
void setVehicleDimensions(const autoware_adapi_v1_msgs::msg::VehicleDimensions &);
|
||||||
void updateVelocityReport(const autoware_auto_vehicle_msgs::msg::VelocityReport::ConstSharedPtr);
|
void updateVelocityReport(const autoware_auto_vehicle_msgs::msg::VelocityReport::ConstSharedPtr);
|
||||||
|
@ -130,7 +130,7 @@ private:
|
||||||
};
|
};
|
||||||
VehicleStatus vehicleStatus_;
|
VehicleStatus vehicleStatus_;
|
||||||
|
|
||||||
int generationTime_;
|
int generationDeltaTime_;
|
||||||
long gdt_timestamp_;
|
long gdt_timestamp_;
|
||||||
|
|
||||||
double objectConfidenceThreshold_;
|
double objectConfidenceThreshold_;
|
||||||
|
@ -140,7 +140,6 @@ private:
|
||||||
bool sending_;
|
bool sending_;
|
||||||
bool is_sender_;
|
bool is_sender_;
|
||||||
bool reflect_packet_;
|
bool reflect_packet_;
|
||||||
bool include_all_persons_and_animals_;
|
|
||||||
|
|
||||||
int cam_num_;
|
int cam_num_;
|
||||||
int received_cam_num_;
|
int received_cam_num_;
|
||||||
|
|
|
@ -41,14 +41,13 @@ namespace v2x
|
||||||
positionConfidenceEllipse_(),
|
positionConfidenceEllipse_(),
|
||||||
velocityReport_(),
|
velocityReport_(),
|
||||||
vehicleStatus_(),
|
vehicleStatus_(),
|
||||||
generationTime_(0),
|
generationDeltaTime_(0),
|
||||||
updating_velocity_report_(false),
|
updating_velocity_report_(false),
|
||||||
updating_vehicle_status_(false),
|
updating_vehicle_status_(false),
|
||||||
sending_(false),
|
sending_(false),
|
||||||
is_sender_(is_sender),
|
is_sender_(is_sender),
|
||||||
reflect_packet_(false),
|
reflect_packet_(false),
|
||||||
objectConfidenceThreshold_(0.0),
|
objectConfidenceThreshold_(0.0),
|
||||||
include_all_persons_and_animals_(false),
|
|
||||||
cam_num_(0),
|
cam_num_(0),
|
||||||
received_cam_num_(0),
|
received_cam_num_(0),
|
||||||
use_dynamic_generation_rules_(false)
|
use_dynamic_generation_rules_(false)
|
||||||
|
@ -96,8 +95,8 @@ namespace v2x
|
||||||
positionConfidenceEllipse_.y.insert(*lon);
|
positionConfidenceEllipse_.y.insert(*lon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CamApplication::updateGenerationTime(int *gdt, long *gdt_timestamp) {
|
void CamApplication::updateGenerationDeltaTime(int *gdt, long *gdt_timestamp) {
|
||||||
generationTime_ = *gdt;
|
generationDeltaTime_ = *gdt;
|
||||||
gdt_timestamp_ = *gdt_timestamp; // ETSI-epoch milliseconds timestamp
|
gdt_timestamp_ = *gdt_timestamp; // ETSI-epoch milliseconds timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,9 +174,8 @@ namespace v2x
|
||||||
|
|
||||||
CoopAwareness_t &cam = message->cam;
|
CoopAwareness_t &cam = message->cam;
|
||||||
|
|
||||||
// Set GenerationTime
|
|
||||||
RCLCPP_INFO(node_->get_logger(), "[CpmApplication::send] %ld", gdt_timestamp_);
|
RCLCPP_INFO(node_->get_logger(), "[CpmApplication::send] %ld", gdt_timestamp_);
|
||||||
cam.generationDeltaTime = gdt_timestamp_;
|
cam.generationDeltaTime = generationDeltaTime_;
|
||||||
|
|
||||||
BasicContainer_t &basic_container = cam.camParameters.basicContainer;
|
BasicContainer_t &basic_container = cam.camParameters.basicContainer;
|
||||||
basic_container.stationType = StationType_passengerCar;
|
basic_container.stationType = StationType_passengerCar;
|
||||||
|
|
|
@ -32,7 +32,7 @@ using namespace vanetza;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
namespace v2x {
|
namespace v2x {
|
||||||
CpmApplication::CpmApplication(V2XNode *node, Runtime &rt, bool is_sender) :
|
CpmApplication::CpmApplication(V2XNode *node, Runtime &rt, bool is_sender) :
|
||||||
node_(node),
|
node_(node),
|
||||||
runtime_(rt),
|
runtime_(rt),
|
||||||
ego_(),
|
ego_(),
|
||||||
|
@ -156,7 +156,7 @@ namespace v2x {
|
||||||
x1 = x1 / 100.0;
|
x1 = x1 / 100.0;
|
||||||
y1 = y1 / 100.0;
|
y1 = y1 / 100.0;
|
||||||
object.position_x = x_mgrs + (cos(orientation) * x1 - sin(orientation) * y1);
|
object.position_x = x_mgrs + (cos(orientation) * x1 - sin(orientation) * y1);
|
||||||
object.position_y = y_mgrs + (sin(orientation) * x1 + cos(orientation) * y1);
|
object.position_y = y_mgrs + (sin(orientation) * x1 + cos(orientation) * y1);
|
||||||
object.shape_x = poc->list.array[i]->planarObjectDimension2->value;
|
object.shape_x = poc->list.array[i]->planarObjectDimension2->value;
|
||||||
object.shape_y = poc->list.array[i]->planarObjectDimension1->value;
|
object.shape_y = poc->list.array[i]->planarObjectDimension1->value;
|
||||||
object.shape_z = poc->list.array[i]->verticalObjectDimension->value;
|
object.shape_z = poc->list.array[i]->verticalObjectDimension->value;
|
||||||
|
@ -236,7 +236,7 @@ namespace v2x {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (found_object == objectsList.end()) {
|
if (found_object == objectsList.end()) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
found_object->to_send = true;
|
found_object->to_send = true;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ namespace v2x {
|
||||||
++cpm_object_id_;
|
++cpm_object_id_;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Object was already in internal memory
|
// Object was already in internal memory
|
||||||
|
|
||||||
// Object belongs to class person or animal
|
// Object belongs to class person or animal
|
||||||
|
@ -327,7 +327,7 @@ namespace v2x {
|
||||||
found_object->to_send = true;
|
found_object->to_send = true;
|
||||||
found_object->to_send_trigger = 5;
|
found_object->to_send_trigger = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object has not been included in a CPM in the past 500 ms.
|
// Object has not been included in a CPM in the past 500 ms.
|
||||||
if (runtime_.now().time_since_epoch().count() - found_object->timestamp.time_since_epoch().count() > 500000) {
|
if (runtime_.now().time_since_epoch().count() - found_object->timestamp.time_since_epoch().count() > 500000) {
|
||||||
// Include all objects of class person or animal in the current CPM
|
// Include all objects of class person or animal in the current CPM
|
||||||
|
@ -349,7 +349,7 @@ namespace v2x {
|
||||||
found_object->to_send = true;
|
found_object->to_send = true;
|
||||||
found_object->to_send_trigger = 1;
|
found_object->to_send_trigger = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Absolute speed changed by more than 0.5 m/s
|
// Absolute speed changed by more than 0.5 m/s
|
||||||
|
@ -359,7 +359,7 @@ namespace v2x {
|
||||||
if (speed > 0.5) {
|
if (speed > 0.5) {
|
||||||
found_object->to_send = true;
|
found_object->to_send = true;
|
||||||
found_object->to_send_trigger = 2;
|
found_object->to_send_trigger = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Orientation of speed vector changed by more than 4 degrees
|
// Orientation of speed vector changed by more than 4 degrees
|
||||||
double twist_angular_x_diff = (obj.kinematics.initial_twist_with_covariance.twist.angular.x - found_object->twist_angular_x) * 180 / M_PI;
|
double twist_angular_x_diff = (obj.kinematics.initial_twist_with_covariance.twist.angular.x - found_object->twist_angular_x) * 180 / M_PI;
|
||||||
|
@ -434,7 +434,7 @@ namespace v2x {
|
||||||
} else {
|
} else {
|
||||||
RCLCPP_INFO(node_->get_logger(), "[objectsList] %d,,,,", cpm_num);
|
RCLCPP_INFO(node_->get_logger(), "[objectsList] %d,,,,", cpm_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RCLCPP_INFO(node_->get_logger(), "------------------------");
|
// RCLCPP_INFO(node_->get_logger(), "------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ namespace v2x {
|
||||||
sending_ = true;
|
sending_ = true;
|
||||||
|
|
||||||
printObjectsList(cpm_num_);
|
printObjectsList(cpm_num_);
|
||||||
|
|
||||||
// RCLCPP_INFO(node_->get_logger(), "[CpmApplication::send] Sending CPM...");
|
// RCLCPP_INFO(node_->get_logger(), "[CpmApplication::send] Sending CPM...");
|
||||||
|
|
||||||
vanetza::asn1::Cpm message;
|
vanetza::asn1::Cpm message;
|
||||||
|
@ -578,7 +578,7 @@ namespace v2x {
|
||||||
RCLCPP_INFO(node_->get_logger(), "[CpmApplication::send] Sending CPM with %d objects", perceivedObjectsCount);
|
RCLCPP_INFO(node_->get_logger(), "[CpmApplication::send] Sending CPM with %d objects", perceivedObjectsCount);
|
||||||
|
|
||||||
insertCpmToCpmTable(message, (char*) "cpm_sent");
|
insertCpmToCpmTable(message, (char*) "cpm_sent");
|
||||||
|
|
||||||
std::unique_ptr<geonet::DownPacket> payload{new geonet::DownPacket()};
|
std::unique_ptr<geonet::DownPacket> payload{new geonet::DownPacket()};
|
||||||
|
|
||||||
payload->layer(OsiLayer::Application) = std::move(message);
|
payload->layer(OsiLayer::Application) = std::move(message);
|
||||||
|
@ -618,7 +618,7 @@ namespace v2x {
|
||||||
}
|
}
|
||||||
|
|
||||||
char* sql_command;
|
char* sql_command;
|
||||||
|
|
||||||
sql_command = (char*) "create table if not exists cpm_sent(id INTEGER PRIMARY KEY, timestamp BIGINT, perceivedObjectCount INTEGER);";
|
sql_command = (char*) "create table if not exists cpm_sent(id INTEGER PRIMARY KEY, timestamp BIGINT, perceivedObjectCount INTEGER);";
|
||||||
|
|
||||||
ret = sqlite3_exec(db, sql_command, NULL, NULL, &err);
|
ret = sqlite3_exec(db, sql_command, NULL, NULL, &err);
|
||||||
|
@ -661,7 +661,7 @@ namespace v2x {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream sql_command;
|
std::stringstream sql_command;
|
||||||
|
|
||||||
sql_command << "insert into " << table_name << " (timestamp, perceivedObjectCount) values (" << timestamp << ", " << perceivedObjectCount << ");";
|
sql_command << "insert into " << table_name << " (timestamp, perceivedObjectCount) values (" << timestamp << ", " << perceivedObjectCount << ");";
|
||||||
|
|
||||||
ret = sqlite3_exec(db, sql_command.str().c_str(), NULL, NULL, &err);
|
ret = sqlite3_exec(db, sql_command.str().c_str(), NULL, NULL, &err);
|
||||||
|
@ -677,4 +677,4 @@ namespace v2x {
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
// RCLCPP_INFO(node_->get_logger(), "CpmApplication::insertCpmToCpmTable Finished");
|
// RCLCPP_INFO(node_->get_logger(), "CpmApplication::insertCpmToCpmTable Finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -128,7 +128,7 @@ namespace v2x
|
||||||
cam->updateMGRS(&x, &y);
|
cam->updateMGRS(&x, &y);
|
||||||
cam->updateRP(&lat, &lon, &z);
|
cam->updateRP(&lat, &lon, &z);
|
||||||
cam->updateHeading(&yaw);
|
cam->updateHeading(&yaw);
|
||||||
cam->updateGenerationTime(&gdt, ×tamp_msec);
|
cam->updateGenerationDeltaTime(&gdt, ×tamp_msec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue