JaiaBot  1.19.0
JaiaBot micro-AUV software
intervehicle.h
Go to the documentation of this file.
1 // Copyright 2023:
2 // JaiaRobotics LLC
3 // File authors:
4 // Toby Schneider <toby@gobysoft.org>
5 //
6 //
7 // This file is part of the JaiaBot Project Libraries
8 // ("The Jaia Libraries").
9 //
10 // The Jaia Libraries are free software: you can redistribute them and/or modify
11 // them under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 2.1 of the License, or
13 // (at your option) any later version.
14 //
15 // The Jaia Libraries are distributed in the hope that they will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with the Jaia Libraries. If not, see <http://www.gnu.org/licenses/>.
22 
23 #ifndef JAIABOT_CORE_SRC_LIB_INTERVEHICLE_H
24 #define JAIABOT_CORE_SRC_LIB_INTERVEHICLE_H
25 
26 #include "goby/middleware/group.h"
27 #include "goby/middleware/transport/publisher.h"
28 
29 #include "jaiabot/comms/comms.h"
30 #include "jaiabot/groups.h"
32 
33 namespace jaiabot
34 {
35 namespace intervehicle
36 {
37 // hub_command numeric group is based off bot id
38 inline goby::middleware::DynamicGroup hub_command_group(std::uint32_t bot_id)
39 {
40  return goby::middleware::DynamicGroup(jaiabot::groups::hub_command,
43 }
44 
45 // given a bot id and the hub_command group numeric value, what API version is this subscriber (bot) using?
46 inline std::uint32_t api_version_from_hub_command(std::uint32_t bot_id,
47  std::uint32_t hub_command_group)
48 {
50 }
51 
52 // in case we ever exceed maximum valid Goby group
55  goby::middleware::Group::maximum_valid_group,
56  "jaiabot::INTERVEHICLE_API_VERSION exceeds maximum valid goby::middleware::Group "
57  "value for hub_command");
58 
59 inline goby::middleware::DynamicGroup engineering_command_group(std::uint32_t bot_id)
60 {
61  return goby::middleware::DynamicGroup(jaiabot::groups::engineering_command,
64 }
65 
66 // as the group is inferred from jaiabot::INTERVEHICLE_API_VERSION and possibly the already-set bot_id field we don't need to set anything using the group function. However Goby requires one to exist for using non-broadcast groups, so we define a no-op group_func
67 template <typename DCCLMessage>
68 goby::middleware::Publisher<DCCLMessage>
69  default_publisher({}, [](DCCLMessage&, const goby::middleware::Group&) {});
70 
71 // for all non-command intervehicle groups, we use the INTERVEHICLE_API_VERSION directly as the group numeric value
72 template <typename DCCLMessage>
73 std::function<goby::middleware::Group(const DCCLMessage&)>
74  default_subscriber_group_func([](const DCCLMessage&) -> goby::middleware::Group {
75  return goby::middleware::Group(jaiabot::INTERVEHICLE_API_VERSION);
76  });
77 
78 } // namespace intervehicle
79 } // namespace jaiabot
80 
81 #endif
jaiabot::intervehicle::engineering_command_group
goby::middleware::DynamicGroup engineering_command_group(std::uint32_t bot_id)
Definition: intervehicle.h:59
jaia_dccl.pb.h
jaiabot::comms::bot_id_max
constexpr int bot_id_max
Definition: comms.h:41
jaiabot::groups::engineering_command
constexpr goby::middleware::Group engineering_command
Definition: groups.h:86
jaiabot::intervehicle::api_version_from_hub_command
std::uint32_t api_version_from_hub_command(std::uint32_t bot_id, std::uint32_t hub_command_group)
Definition: intervehicle.h:46
jaiabot::groups::hub_command
constexpr goby::middleware::Group hub_command
Definition: groups.h:83
jaiabot::intervehicle::default_subscriber_group_func
std::function< goby::middleware::Group(const DCCLMessage &)> default_subscriber_group_func([](const DCCLMessage &) -> goby::middleware::Group { return goby::middleware::Group(jaiabot::INTERVEHICLE_API_VERSION);})
Definition: intervehicle.h:74
jaiabot::INTERVEHICLE_API_VERSION
constexpr std::uint32_t INTERVEHICLE_API_VERSION
Definition: version.h:44
jaiabot
Definition: config.pb.h:56
jaiabot::comms::bot_id_total
constexpr int bot_id_total
Definition: comms.h:42
groups.h
comms.h
jaiabot::intervehicle::hub_command_group
goby::middleware::DynamicGroup hub_command_group(std::uint32_t bot_id)
Definition: intervehicle.h:38
jaiabot::intervehicle::default_publisher
goby::middleware::Publisher< DCCLMessage > default_publisher({}, [](DCCLMessage &, const goby::middleware::Group &) {})