Program Listing for File ros_gz_bridge.hpp
↰ Return to documentation for file (/tmp/ws/src/ros_gz/ros_gz_bridge/include/ros_gz_bridge/ros_gz_bridge.hpp
)
// Copyright 2022 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ROS_GZ_BRIDGE__ROS_GZ_BRIDGE_HPP_
#define ROS_GZ_BRIDGE__ROS_GZ_BRIDGE_HPP_
#include <memory>
#include <string>
#include <vector>
#include <gz/msgs/config.hh>
#include <gz/transport/Node.hh>
#include <rclcpp/node.hpp>
#include "ros_gz_bridge/bridge_config.hpp"
// Dataframe is available from versions 8.4.0 (fortress) forward
// This can be removed when the minimum supported version passes 8.4.0
#if (IGNITION_MSGS_MAJOR_VERSION > 8) || \
((IGNITION_MSGS_MAJOR_VERSION == 8) && (IGNITION_MSGS_MINOR_VERSION >= 4))
#define HAVE_DATAFRAME true
#endif
#if (GZ_MSGS_MAJOR_VERSION > 8) || \
((GZ_MSGS_MAJOR_VERSION == 8) && (GZ_MSGS_MINOR_VERSION >= 4))
#define HAVE_DATAFRAME true
#endif
// MaterialColor is available from versions 10.1.0 (Harmonic) forward
// This can be removed when the minimum supported version passes 10.1.0
#if (GZ_MSGS_MAJOR_VERSION > 10) || \
((GZ_MSGS_MAJOR_VERSION == 10) && (GZ_MSGS_MINOR_VERSION >= 1))
#define HAVE_MATERIALCOLOR true
#endif
namespace ros_gz_bridge
{
class BridgeHandle;
class RosGzBridge : public rclcpp::Node
{
public:
explicit RosGzBridge(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
void add_bridge(const BridgeConfig & config);
void add_service_bridge(
const std::string & ros_type_name,
const std::string & gz_req_type_name,
const std::string & gz_rep_type_name,
const std::string & service_name);
protected:
void spin();
protected:
std::shared_ptr<gz::transport::Node> gz_node_;
std::vector<std::shared_ptr<ros_gz_bridge::BridgeHandle>> handles_;
std::vector<rclcpp::ServiceBase::SharedPtr> services_;
rclcpp::TimerBase::SharedPtr heartbeat_timer_;
};
} // namespace ros_gz_bridge
#endif // ROS_GZ_BRIDGE__ROS_GZ_BRIDGE_HPP_