Skip to content

Commit a604948

Browse files
committed
Fix resolution of frames with tf_prefix
1 parent 1eab1f5 commit a604948

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

src/rviz/default_plugin/effort_display.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <rviz/properties/int_property.h>
88
#include <rviz/frame_manager.h>
99
#include <rviz/validate_floats.h>
10+
#include <rviz/helpers/tf_prefix.h>
1011

1112
#include "effort_visual.h"
1213
#include "effort_display.h"
@@ -278,8 +279,7 @@ void EffortDisplay::processMessage(const sensor_msgs::JointState::ConstPtr& msg)
278279
int joint_type = joint->type;
279280
if (joint_type == urdf::Joint::REVOLUTE)
280281
{
281-
std::string tf_prefix = tf_prefix_property_->getStdString();
282-
std::string tf_frame_id = (tf_prefix.empty() ? "" : tf_prefix + "/") + joint->child_link_name;
282+
std::string tf_frame_id = concat(tf_prefix_property_->getStdString(), joint->child_link_name);
283283
Ogre::Quaternion orientation;
284284
Ogre::Vector3 position;
285285

src/rviz/helpers/tf_prefix.h

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2020, Bielefeld University
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* * Neither the name of the Bielefeld University nor the names of its
14+
* contributors may be used to endorse or promote products derived from
15+
* this software without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
* POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#pragma once
31+
#include <string>
32+
33+
namespace rviz
34+
{
35+
36+
std::string concat(const std::string& prefix, const std::string& frame)
37+
{
38+
if (prefix.empty())
39+
return frame;
40+
41+
std::string composite = prefix;
42+
composite.append("/");
43+
composite.append(frame);
44+
return composite;
45+
}
46+
47+
} // namespace rviz

src/rviz/robot/tf_link_updater.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929

3030
#include "tf_link_updater.h"
3131
#include <rviz/frame_manager.h>
32-
33-
#include <tf/tf.h>
32+
#include <rviz/helpers/tf_prefix.h>
3433

3534
#include <OgreVector3.h>
3635
#include <OgreQuaternion.h>
@@ -48,11 +47,7 @@ TFLinkUpdater::TFLinkUpdater(FrameManager* frame_manager, const StatusCallback&
4847
bool TFLinkUpdater::getLinkTransforms(const std::string& _link_name, Ogre::Vector3& visual_position, Ogre::Quaternion& visual_orientation,
4948
Ogre::Vector3& collision_position, Ogre::Quaternion& collision_orientation) const
5049
{
51-
std::string link_name = _link_name;
52-
if (!tf_prefix_.empty())
53-
{
54-
link_name = tf::resolve(tf_prefix_, link_name);
55-
}
50+
std::string link_name = concat(tf_prefix_, _link_name);
5651

5752
Ogre::Vector3 position;
5853
Ogre::Quaternion orientation;

0 commit comments

Comments
 (0)