33 #include "multimaster_msgs/GetClockOffset.h" 35 #include <boost/algorithm/string.hpp> 40 int main(
int argc,
char *argv[])
42 ros::init(argc, argv,
"message_relay_node");
48 std::string parameter_namespace;
49 if (private_nh.
getParam(
"parameter_namespace", parameter_namespace))
56 std::string from =
"", to =
"";
59 ROS_FATAL(
"Must provide either 'from' and 'to' namespace parameters");
65 ROS_FATAL(
"'from' and 'to' namespaces must not be equal");
73 std::string tf_prefix, prefix_operation;
74 if (private_nh.
getParam(
"tf_prefix", tf_prefix) && !private_nh.
getParam(
"prefix_operation", prefix_operation))
76 ROS_FATAL_STREAM(
"If tf_prefix is provided, a prefix_operation must be specified");
80 std::vector<std::string> global_frames;
81 private_nh.
getParam(
"global_frames", global_frames);
84 tf_prefix, prefix_operation, boost::unordered_set<std::string>(global_frames.begin(), global_frames.end()));
89 std::string time_offset_operation;
90 private_nh.
param<std::string>(
"time_offset_operation", time_offset_operation,
"");
93 if (time_offset_operation !=
"")
96 ros::ServiceClient clock_offset_client = origin->serviceClient<multimaster_msgs::GetClockOffset>
97 (
"/get_clock_offset");
100 ROS_WARN_STREAM(
"Waiting for /get_clock_offset service. Is clock_relay_node running?");
102 multimaster_msgs::GetClockOffset srv;
103 while (
ros::ok() && !clock_offset_client.
call(srv))
111 std::vector<message_relay::TopicRelay::Ptr> topic_relays;
113 if (private_nh.
getParam(
"topics", topics))
115 for (
int i = 0; i < topics.
size(); i++)
118 params.
topic =
static_cast<std::string
>(topics[i][
"topic"]);
119 params.
type =
static_cast<std::string
>(topics[i][
"type"]);
124 params.
queue_size =
static_cast<int>(topics[i][
"queue_size"]);
142 if (private_nh.
searchParam(
"throttle_frequency", key))
147 params.
latch =
static_cast<bool>(topics[i][
"latch"]);
148 params.
unreliable =
static_cast<bool>(topics[i][
"unreliable"]);
158 bool separate_service_queue;
159 private_nh.
param(
"separate_service_queue", separate_service_queue,
true);
163 if (separate_service_queue)
165 service_queue = boost::make_shared<ros::CallbackQueue>();
167 std::vector<message_relay::ServiceRelay::Ptr> service_relays;
169 if (private_nh.
getParam(
"services", services))
171 for (
int i = 0; i < services.
size(); i++)
174 params.
service =
static_cast<std::string
>(services[i][
"service"]);
175 params.
type =
static_cast<std::string
>(services[i][
"type"]);
188 std::vector<message_relay::ActionRelay::Ptr> action_relays;
190 if (private_nh.
getParam(
"actions", actions))
192 for (
int i = 0; i < actions.
size(); i++)
195 params.
action =
static_cast<std::string
>(actions[i][
"action"]);
196 params.
type =
static_cast<std::string
>(actions[i][
"type"]);
201 params.
queue_size =
static_cast<int>(actions[i][
"queue_size"]);
223 if (separate_service_queue)
225 service_spinner = boost::make_shared<ros::AsyncSpinner>(1, service_queue.get());
226 service_spinner->start();
double throttle_frequency
static ConstPtr create(std::string tf_prefix, std::string prefix_operation_string, boost::unordered_set< std::string > global_frame_names=boost::unordered_set< std::string >())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
boost::shared_ptr< ros::NodeHandle > origin
bool call(MReq &req, MRes &res)
boost::shared_ptr< ros::NodeHandle > target
TimeProcessor::ConstPtr time_processor
ActionRelay::Ptr createActionRelay(const ActionRelayParams ¶ms)
boost::shared_ptr< ros::NodeHandle > target
ROSCPP_DECL void spin(Spinner &spinner)
TimeProcessor::ConstPtr time_processor
FrameIdProcessor::ConstPtr frame_id_processor
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
#define ROS_FATAL_STREAM(args)
TimeProcessor::ConstPtr time_processor
bool searchParam(const std::string &key, std::string &result) const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
static ConstPtr create(std::string offset_operation_string, ros::Duration offset=ros::Duration(0.0))
int main(int argc, char *argv[])
boost::shared_ptr< ros::CallbackQueue > callback_queue
TopicRelay::Ptr createTopicRelay(const TopicRelayParams ¶ms)
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
boost::shared_ptr< ros::NodeHandle > origin
boost::shared_ptr< ros::NodeHandle > target
bool getParam(const std::string &key, std::string &s) const
double check_for_server_frequency
#define ROS_ERROR_STREAM(args)
ServiceRelay::Ptr createServiceRelay(const ServiceRelayParams ¶ms)
FrameIdProcessor::ConstPtr frame_id_processor
FrameIdProcessor::ConstPtr frame_id_processor
double feedback_throttle_frequency
boost::shared_ptr< ros::NodeHandle > origin