tf2_relay_node.cpp
Go to the documentation of this file.
1 
26 #include "ros/ros.h"
27 
28 #include <boost/unordered_set.hpp>
29 
30 #include <vector>
31 #include <string>
32 
33 int main(int argc, char *argv[])
34 {
35  ros::init(argc, argv, "tf2_relay_node");
36 
37  ros::NodeHandle private_nh("~");
38 
39  std::string parameter_namespace;
40  if (private_nh.getParam("parameter_namespace", parameter_namespace))
41  {
42  private_nh = ros::NodeHandle(parameter_namespace);
43  }
44 
45  std::string from, to;
46  if (!private_nh.getParam("from", from) && !private_nh.getParam("to", to))
47  {
48  ROS_FATAL("Must provide either 'from' and 'to' namespace parameters");
49  return 1;
50  }
51 
52  if (from == to)
53  {
54  ROS_FATAL("'from' and 'to' namespaces must not be equal");
55  return 1;
56  }
57 
58  ros::NodeHandle origin(from), target(to);
59 
60  std::string tf_prefix, prefix_operation;
61  if (private_nh.getParam("tf_prefix", tf_prefix) && !private_nh.getParam("prefix_operation", prefix_operation))
62  {
63  ROS_FATAL_STREAM("If tf_prefix is provided, a prefix_operation must be specified");
64  return 1;
65  }
66 
67  double throttle_frequency = 0.0;
68  std::string key;
69  if (private_nh.searchParam("throttle_frequency", key))
70  {
71  std::string val;
72  private_nh.getParam(key, throttle_frequency);
73  }
74 
75  std::vector<std::string> global_frames;
76  private_nh.getParam("global_frames", global_frames);
77 
79  tf_prefix, prefix_operation, boost::unordered_set<std::string>(global_frames.begin(), global_frames.end()));
80 
81  tf2_relay::TransformRelay transform_relay(origin, target, throttle_frequency, false, frame_id_processor);
82  tf2_relay::TransformRelay static_transform_relay(origin, target, throttle_frequency, true, frame_id_processor);
83 
84  ros::spin();
85 
86  return 0;
87 }
#define ROS_FATAL(...)
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)
int main(int argc, char *argv[])
ROSCPP_DECL void spin(Spinner &spinner)
#define ROS_FATAL_STREAM(args)
bool searchParam(const std::string &key, std::string &result) const
bool getParam(const std::string &key, std::string &s) const


tf2_relay
Author(s):
autogenerated on Wed Jul 17 2019 03:28:00