2021-10-27 21:56:21 +00:00
|
|
|
#ifndef CPM_APPLICATION_HPP_EUIC2VFR
|
|
|
|
#define CPM_APPLICATION_HPP_EUIC2VFR
|
|
|
|
|
|
|
|
#include "autoware_v2x/application.hpp"
|
|
|
|
#include "rclcpp/rclcpp.hpp"
|
|
|
|
#include <boost/asio/io_service.hpp>
|
|
|
|
#include <boost/asio/steady_timer.hpp>
|
2022-03-28 02:17:51 +00:00
|
|
|
#include "autoware_auto_perception_msgs/msg/predicted_objects.hpp"
|
2021-10-27 21:56:21 +00:00
|
|
|
#include "autoware_v2x/positioning.hpp"
|
2022-04-01 06:07:11 +00:00
|
|
|
#include <vanetza/asn1/cpm.hpp>
|
2021-10-27 21:56:21 +00:00
|
|
|
|
2021-11-10 15:21:32 +00:00
|
|
|
namespace v2x
|
2021-10-27 21:56:21 +00:00
|
|
|
{
|
2021-11-10 15:21:32 +00:00
|
|
|
class V2XNode;
|
|
|
|
class CpmApplication : public Application
|
|
|
|
{
|
|
|
|
public:
|
2022-02-27 03:26:28 +00:00
|
|
|
CpmApplication(V2XNode *node, vanetza::Runtime &, bool is_sender);
|
2021-11-10 15:21:32 +00:00
|
|
|
PortType port() override;
|
2022-03-28 02:17:51 +00:00
|
|
|
std::string uuidToHexString(const unique_identifier_msgs::msg::UUID&);
|
2021-11-10 15:21:32 +00:00
|
|
|
void indicate(const DataIndication &, UpPacketPtr) override;
|
|
|
|
void set_interval(vanetza::Clock::duration);
|
2022-03-30 05:51:13 +00:00
|
|
|
void setAllObjectsOfPersonsAnimalsToSend(const autoware_auto_perception_msgs::msg::PredictedObjects::ConstSharedPtr);
|
|
|
|
void updateObjectsList(const autoware_auto_perception_msgs::msg::PredictedObjects::ConstSharedPtr);
|
2021-11-10 15:21:32 +00:00
|
|
|
void updateMGRS(double *, double *);
|
|
|
|
void updateRP(double *, double *, double *);
|
2021-11-23 04:02:54 +00:00
|
|
|
void updateGenerationDeltaTime(int *, long long *);
|
2021-11-10 15:21:32 +00:00
|
|
|
void updateHeading(double *);
|
2022-04-01 05:51:10 +00:00
|
|
|
void printObjectsList(int);
|
2021-11-10 15:21:32 +00:00
|
|
|
void send();
|
|
|
|
|
2022-04-01 06:07:11 +00:00
|
|
|
/** Creates the database schema.
|
|
|
|
* Creates tables for cpm_sent, cpm_received
|
|
|
|
*/
|
|
|
|
void createTables();
|
|
|
|
|
|
|
|
/** Inserts CPM into the database.
|
|
|
|
* Constructs and executes queries for inserting the specified CPM data.
|
|
|
|
* @param cpm The CPM to be inserted
|
|
|
|
* @param table_name The table to insert the CPM into (cpm_sent or cpm_received)
|
|
|
|
*/
|
2022-04-01 07:37:53 +00:00
|
|
|
void insertCpmToCpmTable(vanetza::asn1::Cpm, char*);
|
2022-04-01 06:07:11 +00:00
|
|
|
|
2022-03-28 02:17:51 +00:00
|
|
|
struct Object {
|
2022-03-30 05:51:13 +00:00
|
|
|
std::string uuid;
|
|
|
|
int objectID; // 0-255 for CPM
|
|
|
|
vanetza::Clock::time_point timestamp;
|
|
|
|
rclcpp::Time timestamp_ros;
|
2021-11-10 15:21:32 +00:00
|
|
|
double position_x;
|
|
|
|
double position_y;
|
|
|
|
double position_z;
|
|
|
|
double orientation_x;
|
|
|
|
double orientation_y;
|
|
|
|
double orientation_z;
|
|
|
|
double orientation_w;
|
2022-03-30 05:51:13 +00:00
|
|
|
double twist_linear_x;
|
|
|
|
double twist_linear_y;
|
|
|
|
double twist_angular_x;
|
|
|
|
double twist_angular_y;
|
2021-11-14 04:26:18 +00:00
|
|
|
int shape_x;
|
|
|
|
int shape_y;
|
|
|
|
int shape_z;
|
2021-11-10 15:21:32 +00:00
|
|
|
int xDistance;
|
|
|
|
int yDistance;
|
2021-11-17 08:45:25 +00:00
|
|
|
int xSpeed;
|
|
|
|
int ySpeed;
|
2021-11-14 04:26:18 +00:00
|
|
|
int yawAngle;
|
2021-11-10 15:21:32 +00:00
|
|
|
vanetza::PositionFix position;
|
|
|
|
int timeOfMeasurement;
|
2022-03-30 05:51:13 +00:00
|
|
|
bool to_send;
|
2022-04-01 05:51:10 +00:00
|
|
|
int to_send_trigger;
|
2021-11-10 15:21:32 +00:00
|
|
|
};
|
2022-03-30 05:51:13 +00:00
|
|
|
std::vector<CpmApplication::Object> objectsList;
|
2021-11-10 15:21:32 +00:00
|
|
|
std::vector<CpmApplication::Object> receivedObjectsStack;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void schedule_timer();
|
|
|
|
void on_timer(vanetza::Clock::time_point);
|
|
|
|
|
|
|
|
V2XNode *node_;
|
|
|
|
vanetza::Runtime &runtime_;
|
|
|
|
vanetza::Clock::duration cpm_interval_;
|
|
|
|
|
2022-02-16 07:53:45 +00:00
|
|
|
struct Ego_station {
|
|
|
|
double mgrs_x;
|
|
|
|
double mgrs_y;
|
|
|
|
double latitude;
|
|
|
|
double longitude;
|
|
|
|
double altitude;
|
|
|
|
double heading;
|
|
|
|
};
|
|
|
|
|
|
|
|
Ego_station ego_;
|
|
|
|
|
2021-11-10 15:21:32 +00:00
|
|
|
int generationDeltaTime_;
|
2021-11-23 04:02:54 +00:00
|
|
|
long long gdt_timestamp_;
|
2021-11-10 15:21:32 +00:00
|
|
|
|
2022-03-30 05:51:13 +00:00
|
|
|
double objectConfidenceThreshold_;
|
|
|
|
|
|
|
|
bool updating_objects_list_;
|
2021-11-10 15:21:32 +00:00
|
|
|
bool sending_;
|
2022-01-21 13:07:33 +00:00
|
|
|
bool is_sender_;
|
|
|
|
bool reflect_packet_;
|
2022-03-30 05:51:13 +00:00
|
|
|
bool include_all_persons_and_animals_;
|
2022-04-01 05:51:10 +00:00
|
|
|
|
|
|
|
int cpm_num_;
|
|
|
|
int received_cpm_num_;
|
|
|
|
|
|
|
|
int cpm_object_id_;
|
2022-07-21 00:12:08 +00:00
|
|
|
|
|
|
|
bool use_dynamic_generation_rules_;
|
2021-11-10 08:14:01 +00:00
|
|
|
};
|
2021-11-10 15:21:32 +00:00
|
|
|
}
|
2021-10-27 21:56:21 +00:00
|
|
|
|
|
|
|
#endif /* CPM_APPLICATION_HPP_EUIC2VFR */
|