1 #ifndef GROUP9_V2VSERVICE_HPP 2 #define GROUP9_V2VSERVICE_HPP 7 #include "cluon/OD4Session.hpp" 8 #include "cluon/UDPSender.hpp" 9 #include "cluon/UDPReceiver.hpp" 10 #include "cluon/Envelope.hpp" 11 #include "Messages.hpp" 24 static const int BROADCAST_CHANNEL = 250;
25 static const int DEFAULT_PORT = 50001;
27 static const int ANNOUNCE_PRESENCE = 1001;
28 static const int FOLLOW_REQUEST = 1002;
29 static const int FOLLOW_RESPONSE = 1003;
30 static const int STOP_FOLLOW = 1004;
31 static const int LEADER_STATUS = 2001;
32 static const int FOLLOWER_STATUS = 3001;
36 std::map <std::string, std::string> presentCars;
38 V2VService(std::string ip, std::string
id, std::string partnerIp, std::string partnerId,
39 std::string speed_after, std::string left, std::string right, uint16_t queue_max);
45 void leaderStatus(
float speed,
float steeringAngle, uint8_t distanceTraveled);
49 static constexpr
float m_OFFSET = -0.12f;
52 std::string _PARTNER_IP;
53 std::string _PARTNER_ID;
54 std::string _SPEED_AFTER;
59 bool isPresentPartner =
false;
60 bool isFollower =
false;
61 bool isLeader =
false;
66 std::shared_ptr<cluon::OD4Session> broadcast;
67 std::shared_ptr<cluon::UDPReceiver> incoming;
68 std::shared_ptr<cluon::UDPSender> toLeader;
69 std::shared_ptr<cluon::UDPSender> toFollower;
71 static uint32_t getTime();
72 static std::pair<int16_t, std::string> extract(std::string data);
74 static std::string encode(T msg);
76 static T decode(std::string data);
void stopFollow(std::string vehicleIp)
V2VService(std::string ip, std::string id, std::string partnerIp, std::string partnerId, std::string speed_after, std::string left, std::string right, uint16_t queue_max)
void leaderStatus(float speed, float steeringAngle, uint8_t distanceTraveled)