13 this->
staticTf = this->remappedTfTopic ==
"tf_static" || this->remappedTfTopic ==
"/tf_static";
18 if (!hasMappingsParam) {
20 ROS_WARN(
"The 'mappings' parameter to tf_remap is missing");
29 if (!tfRemapper.getMappings().empty()) {
30 ROS_INFO_STREAM(
"Applying the following mappings" << (bidirectional ?
" bidirectionally" :
"") <<
31 " to incoming tf frame ids:");
32 for (TfRemapper::MappingsType::const_iterator it = tfRemapper.getMappings().begin();
33 it != tfRemapper.getMappings().end(); ++it) {
34 ROS_INFO_STREAM(
"* " << it->first <<
" " << (bidirectional && !it->second.empty() ?
"<" :
"") <<
"-> " <<
35 (it->second.empty() ?
"DELETE" : it->second));
40 if (it->second.empty())
51 ROS_INFO(
"Running in static TF mode (caching all TFs, latched publisher)");
68 const std::string& callerid =
event.getPublisherName();
86 const std::string& callerid =
event.getPublisherName();
103 const tf2_msgs::TFMessage& message, tf2_msgs::TFMessage& cache)
const {
105 for (std::vector<geometry_msgs::TransformStamped>::const_iterator it = message.transforms.begin();
106 it != message.transforms.end(); ++it) {
108 for (std::vector<geometry_msgs::TransformStamped>::iterator cacheIt = cache.transforms.begin();
109 cacheIt != cache.transforms.end(); ++cacheIt) {
110 if (it->child_frame_id == cacheIt->child_frame_id) {
117 cache.transforms.push_back(*it);
121 int main(
int argc,
char * argv[])
TfRemapper reverseTfRemapper
The remapper that actually changes the TF messages.
TfRemapper tfRemapper
Name of the remapped topic ("/tf").
int main(int argc, char *argv[])
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void doRemapping(tf2_msgs::TFMessage &message) const
Rewrite TF frame names according to the rules given in constructor.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL const std::string & getName()
Remap frames in TF messages according to given rules.
tf2_msgs::TFMessage staticTfCache
If true, this node works with static TF, which need special care.
const boost::shared_ptr< ConstMessage > & getConstMessage() const
ros::Publisher oldTfPublisher
Publisher of /tf.
A node that remaps TF frame names according to the given set of rules.
ros::Subscriber remappedTfSubscriber
Subscriber to /tf_old.
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
ros::NodeHandle privateNodeHandle
ROS node handle.
const MappingsType & getMappings() const
Get the mappings this remapper uses.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
tf2_msgs::TFMessage reverseStaticTfCache
Cache of static TF messages.
std::string remappedTfTopic
Name of the old topic ("/tf_old").
ros::Publisher remappedTfPublisher
Subscriber to /tf (only in bidirectional mode).
#define ROS_INFO_STREAM(args)
bool getParam(const std::string &key, std::string &s) const
void oldTfCallback(const ros::MessageEvent< tf2_msgs::TFMessage const > &event)
The remapper that actually changes the TF messages in reverse direction.
ros::Subscriber oldTfSubscriber
Private ROS node handle.
void remappedTfCallback(const ros::MessageEvent< tf2_msgs::TFMessage const > &event)
Callback when a TF message arrives on the remapped TF topic.
bool staticTf
Publisher of /tf_old (only in bidirectional mode).
bool hasParam(const std::string &key) const
void addToStaticTfCache(const tf2_msgs::TFMessage &message, tf2_msgs::TFMessage &cache) const
Add the given TF message to the static TF cache. Newer TFs overwrite the older ones.
ros::NodeHandle publicNodeHandle
std::string oldTfTopic
Cache of static TF messages in the reverse direction.