Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
ROSComms.ipp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020-2021 LEIDOS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16#pragma once
17
18namespace mock_drivers
19{
20// this verstion of the ROSComms object is used for publishers and subscribers
21template <typename T>
23
24};
25
27template <typename T>
28ROSComms<T>::ROSComms(CommTypes ct, bool latch, int qs, std::string t)
29{
30 comm_type_ = ct;
31 latch_ = latch;
32 queue_size_ = qs;
33 topic_ = t;
34};
35
37template <typename T>
38ROSComms<T>::ROSComms(std::function<void(T)> cbf, CommTypes ct, bool latch, int qs, std::string t)
39{
40 callback_function_ = cbf;
41 comm_type_ = ct;
42 latch_ = latch;
43 queue_size_ = qs;
44 topic_ = t;
45};
46
48template <typename M>
50{
51 M element;
52 return element;
53}
54
56template <typename T>
58{
59 // call the callback_function_ function
60 this->callback_function_(msg);
61}
62
64template <typename M, typename T>
65ROSComms<M, T>::ROSComms(std::function<bool(M, T)> cbf, CommTypes ct, std::string t)
66{
67 callback_function_ = cbf;
68 comm_type_ = ct;
69 topic_ = t;
70}
71
73template <typename M, typename T>
74bool ROSComms<M, T>::callback(M req, T res)
75{
76 // call the callback_function_ function
77 this->callback_function_(req, res);
78}
79
81template <typename M, typename T>
83{
84 T element;
85 return element;
86}
87
89template <typename M, typename T>
91{
92 M element;
93 return element;
94}
95
96} // namespace mock_drivers
This class is used to transfer all the information required to initialize ros topics/services.
Definition: ROSComms.h:34
CommTypes
Enum defining the different possible communications types.
Definition: comm_types.h:22
bool callback(cav_srvs::PlanTrajectory::Request &req, cav_srvs::PlanTrajectory::Response &res)
Definition: helper.cpp:21