pacmod_ros_msg_handler.h
Go to the documentation of this file.
1 // Copyright (c) 2019 AutonomouStuff, LLC
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef PACMOD_PACMOD_ROS_MSG_HANDLER_H
22 #define PACMOD_PACMOD_ROS_MSG_HANDLER_H
23 
24 #include <pacmod/pacmod_common.h>
25 
26 #include <mutex>
27 #include <string>
28 #include <vector>
29 #include <memory>
30 
31 namespace AS
32 {
33 namespace Drivers
34 {
35 namespace PACMod
36 {
38 {
39 public:
40  LockedData();
41 
42  bool isValid() const;
43  void setIsValid(bool valid);
44 
45  std::vector<unsigned char> getData() const;
46  void setData(std::vector<unsigned char> new_data);
47 
48 private:
49  std::vector<unsigned char> _data;
50  bool _is_valid;
51  mutable std::mutex _data_mut;
52  mutable std::mutex _valid_mut;
53 };
54 
56 {
57 public:
58  void fillAndPublish(const int64_t& can_id,
59  std::string frame_id,
60  const ros::Publisher& pub,
61  const std::shared_ptr<PacmodTxMsg>& parser_class);
62 
63 private:
64  void fillSystemRptInt(const std::shared_ptr<PacmodTxMsg>& parser_class,
65  pacmod_msgs::SystemRptInt* new_msg,
66  std::string frame_id);
67  void fillSystemRptFloat(const std::shared_ptr<PacmodTxMsg>& parser_class,
68  pacmod_msgs::SystemRptFloat* new_msg,
69  std::string frame_id);
70  void fillGlobalRpt(const std::shared_ptr<PacmodTxMsg>& parser_class,
71  pacmod_msgs::GlobalRpt* new_msg,
72  std::string frame_id);
73  void fillVehicleSpeedRpt(const std::shared_ptr<PacmodTxMsg>& parser_class,
74  pacmod_msgs::VehicleSpeedRpt* new_msg,
75  std::string frame_id);
76  void fillMotorRpt1(const std::shared_ptr<PacmodTxMsg>& parser_class,
77  pacmod_msgs::MotorRpt1* new_msg,
78  std::string frame_id);
79  void fillMotorRpt2(const std::shared_ptr<PacmodTxMsg>& parser_class,
80  pacmod_msgs::MotorRpt2* new_msg,
81  std::string frame_id);
82  void fillMotorRpt3(const std::shared_ptr<PacmodTxMsg>& parser_class,
83  pacmod_msgs::MotorRpt3* new_msg,
84  std::string frame_id);
85  void fillWheelSpeedRpt(const std::shared_ptr<PacmodTxMsg>& parser_class,
86  pacmod_msgs::WheelSpeedRpt* new_msg,
87  std::string frame_id);
88  void fillSteeringPIDRpt1(const std::shared_ptr<PacmodTxMsg>& parser_class,
89  pacmod_msgs::SteeringPIDRpt1* new_msg,
90  std::string frame_id);
91  void fillSteeringPIDRpt2(const std::shared_ptr<PacmodTxMsg>& parser_class,
92  pacmod_msgs::SteeringPIDRpt2* new_msg,
93  std::string frame_id);
94  void fillSteeringPIDRpt3(const std::shared_ptr<PacmodTxMsg>& parser_class,
95  pacmod_msgs::SteeringPIDRpt3* new_msg,
96  std::string frame_id);
97  void fillParkingBrakeStatusRpt(const std::shared_ptr<PacmodTxMsg>& parser_class,
98  pacmod_msgs::ParkingBrakeStatusRpt* new_msg,
99  std::string frame_id);
100  void fillYawRateRpt(const std::shared_ptr<PacmodTxMsg>& parser_class,
101  pacmod_msgs::YawRateRpt* new_msg,
102  std::string frame_id);
103  void fillLatLonHeadingRpt(const std::shared_ptr<PacmodTxMsg>& parser_class,
104  pacmod_msgs::LatLonHeadingRpt* new_msg,
105  std::string frame_id);
106  void fillDateTimeRpt(const std::shared_ptr<PacmodTxMsg>& parser_class,
107  pacmod_msgs::DateTimeRpt* new_msg,
108  std::string frame_id);
109  void fillSteeringPIDRpt4(const std::shared_ptr<PacmodTxMsg>& parser_class,
110  pacmod_msgs::SteeringPIDRpt4* new_msg,
111  std::string frame_id);
112  void fillVinRpt(const std::shared_ptr<PacmodTxMsg>& parser_class,
113  pacmod_msgs::VinRpt* new_msg,
114  std::string frame_id);
115 };
116 
118 {
119 public:
120  static std::vector<uint8_t> unpackAndEncode(const int64_t& can_id,
121  const pacmod_msgs::PacmodCmd::ConstPtr& msg);
122  static std::vector<uint8_t> unpackAndEncode(const int64_t& can_id,
123  const pacmod_msgs::PositionWithSpeed::ConstPtr& msg);
124 };
125 } // namespace PACMod
126 } // namespace Drivers
127 } // namespace AS
128 
129 #endif // PACMOD_PACMOD_ROS_MSG_HANDLER_H
Definition: pacmod_core.h:30
std::vector< unsigned char > _data
std::vector< unsigned char > getData() const
void setData(std::vector< unsigned char > new_data)


pacmod
Author(s): Joe Driscoll , Josh Whitley
autogenerated on Mon Feb 28 2022 23:03:08