JaiaBot 2.0.0
JaiaBot micro-AUV software
 
Loading...
Searching...
No Matches
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
33namespace jaiabot
34{
35namespace intervehicle
36{
37// hub_command numeric group is based off bot id
38inline 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?
46inline 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
59inline 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
67template <typename DCCLMessage>
68goby::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
72template <typename DCCLMessage>
73std::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
constexpr int bot_id_total
Definition comms.h:42
constexpr int bot_id_max
Definition comms.h:41
constexpr goby::middleware::Group hub_command
Definition groups.h:94
constexpr goby::middleware::Group engineering_command
Definition groups.h:97
std::function< goby::middleware::Group(const DCCLMessage &)> default_subscriber_group_func([](const DCCLMessage &) -> goby::middleware::Group { return goby::middleware::Group(jaiabot::INTERVEHICLE_API_VERSION);})
goby::middleware::DynamicGroup hub_command_group(std::uint32_t bot_id)
goby::middleware::DynamicGroup engineering_command_group(std::uint32_t bot_id)
goby::middleware::Publisher< DCCLMessage > default_publisher({}, [](DCCLMessage &, const goby::middleware::Group &) {})
std::uint32_t api_version_from_hub_command(std::uint32_t bot_id, std::uint32_t hub_command_group)
constexpr std::uint32_t INTERVEHICLE_API_VERSION
Definition version.h:44