Add router node.
This commit is contained in:
parent
21f8c2b7c4
commit
9c30904008
|
|
@ -30,6 +30,22 @@ rclcpp_components_register_node(zenoh_bridge_component
|
|||
EXECUTABLE zenoh_bridge
|
||||
)
|
||||
|
||||
add_library(zenoh_router_component SHARED src/ZenohRouter.cpp)
|
||||
target_include_directories(zenoh_router_component PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
|
||||
target_link_libraries(zenoh_router_component
|
||||
rclcpp::rclcpp
|
||||
rclcpp_components::component
|
||||
zenohcxx::zenohc
|
||||
fmt::fmt
|
||||
)
|
||||
|
||||
rclcpp_components_register_node(zenoh_router_component
|
||||
PLUGIN "j7s::ZenohRouter"
|
||||
EXECUTABLE zenoh_router
|
||||
)
|
||||
|
||||
add_executable(get_default_config
|
||||
src/bin/get_default_config.cpp
|
||||
)
|
||||
|
|
@ -39,7 +55,7 @@ target_link_libraries(get_default_config
|
|||
)
|
||||
|
||||
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
|
||||
install(TARGETS zenoh_bridge_component get_default_config
|
||||
install(TARGETS zenoh_bridge_component zenoh_router_component get_default_config
|
||||
EXPORT export_${PROJECT_NAME}
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// Copyright 2026 James Pace
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
// defined by the Mozilla Public License, v. 2.0.
|
||||
//
|
||||
#pragma once
|
||||
#include <rclcpp/rclcpp.hpp>
|
||||
|
||||
#include "zenoh.hxx"
|
||||
|
||||
namespace j7s
|
||||
{
|
||||
class ZenohRouter : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
ZenohRouter(const rclcpp::NodeOptions & options);
|
||||
|
||||
private:
|
||||
std::shared_ptr<zenoh::Session> m_zenohSession;
|
||||
};
|
||||
|
||||
} // namespace j7s
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
<launch>
|
||||
<node name="in_node" pkg="j7s_zenoh_bridge" exec="zenoh_bridge">
|
||||
<param name="zenoh_config_path" value="$(find-pkg-share j7s_zenoh_bridge)/params/DEFAULT_CONFIG.json5"/>
|
||||
<param name="zenoh_config_path" value="$(find-pkg-share j7s_zenoh_bridge)/params/client_config.json5"/>
|
||||
<param from="$(find-pkg-share j7s_zenoh_bridge)/params/in.yaml"/>
|
||||
</node>
|
||||
<node name="out_node" pkg="j7s_zenoh_bridge" exec="zenoh_bridge">
|
||||
<param name="zenoh_config_path" value="$(find-pkg-share j7s_zenoh_bridge)/params/DEFAULT_CONFIG.json5"/>
|
||||
<param name="zenoh_config_path" value="$(find-pkg-share j7s_zenoh_bridge)/params/client_config.json5"/>
|
||||
<param from="$(find-pkg-share j7s_zenoh_bridge)/params/out.yaml"/>
|
||||
</node>
|
||||
<node name="router" pkg="j7s_zenoh_bridge" exec="zenoh_router">
|
||||
<param name="zenoh_config_path" value="$(find-pkg-share j7s_zenoh_bridge)/params/router_config.json5"/>
|
||||
</node>
|
||||
</launch>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
///
|
||||
/// See https://docs.rs/zenoh/latest/zenoh/config/struct.EndPoint.html
|
||||
endpoints: [
|
||||
// "<proto>/<address>"
|
||||
"tcp/localhost:7447"
|
||||
],
|
||||
|
||||
},
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
/// The node's mode (router, peer or client)
|
||||
mode: "router",
|
||||
|
||||
/// The node's metadata (name, location, DNS name, etc.) Arbitrary JSON data not interpreted by zenoh and available in admin space @/<zid>/router, @/<zid>/peer or @/<zid>/client
|
||||
metadata: {
|
||||
},
|
||||
|
||||
/// Which endpoints to connect to. E.g. tcp/localhost:7447.
|
||||
/// By configuring the endpoints, it is possible to tell zenoh which router/peer to connect to at startup.
|
||||
connect: {
|
||||
/// timeout waiting for all endpoints connected (0: no retry, -1: infinite timeout)
|
||||
/// Accepts a single value (e.g. timeout_ms: 0)
|
||||
/// or different values for router, peer and client (e.g. timeout_ms: { router: -1, peer: -1, client: 0 }).
|
||||
timeout_ms: { router: -1, peer: -1, client: 0 },
|
||||
|
||||
/// The list of endpoints to connect to.
|
||||
/// Accepts a single list (e.g. endpoints: ["tcp/10.10.10.10:7447", "tcp/11.11.11.11:7447"])
|
||||
/// or different lists for router, peer and client (e.g. endpoints: { router: ["tcp/10.10.10.10:7447"], peer: ["tcp/11.11.11.11:7447"] }).
|
||||
///
|
||||
/// See https://docs.rs/zenoh/latest/zenoh/config/struct.EndPoint.html
|
||||
endpoints: [
|
||||
// "<proto>/<address>"
|
||||
],
|
||||
|
||||
},
|
||||
|
||||
/// Which endpoints to listen on. E.g. tcp/0.0.0.0:7447.
|
||||
/// By configuring the endpoints, it is possible to tell zenoh which are the endpoints that other routers,
|
||||
/// peers, or client can use to establish a zenoh session.
|
||||
listen: {
|
||||
|
||||
/// The list of endpoints to listen on.
|
||||
/// Accepts a single list (e.g. endpoints: ["tcp/[::]:7447", "udp/[::]:7447"])
|
||||
/// or different lists for router, peer and client (e.g. endpoints: { router: ["tcp/[::]:7447"], peer: ["tcp/[::]:0"] }).
|
||||
///
|
||||
/// See https://docs.rs/zenoh/latest/zenoh/config/struct.EndPoint.html
|
||||
endpoints: ["tcp/0.0.0.0:7447"],
|
||||
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// Copyright 2026 James Pace
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
//
|
||||
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
// defined by the Mozilla Public License, v. 2.0.
|
||||
//
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <j7s_zenoh_bridge/ZenohRouter.hpp>
|
||||
|
||||
namespace j7s
|
||||
{
|
||||
|
||||
ZenohRouter::ZenohRouter(const rclcpp::NodeOptions & options) : Node("zenoh_bridge", options)
|
||||
{
|
||||
const auto zenohConfigPath = this->declare_parameter<std::string>("zenoh_config_path");
|
||||
auto config = zenoh::Config::from_file(zenohConfigPath);
|
||||
m_zenohSession = std::make_shared<zenoh::Session>(std::move(config));
|
||||
}
|
||||
|
||||
}; // namespace j7s
|
||||
|
||||
#include <rclcpp_components/register_node_macro.hpp>
|
||||
RCLCPP_COMPONENTS_REGISTER_NODE(j7s::ZenohRouter)
|
||||
Loading…
Reference in New Issue