Comments (6)
Most use cases simply use the remapping arguments. Is that not adequate for your use case?
from geometry2.
I'm working on kind of multirobot monitoring tool but I want to subscribe only to one robot's TF at the time to save bandwidth. While it would be possible to prepare some node in the middle which may handle "online remapping" (subscribing to /robotX/tf and republishing as /tf) I guess this will lead to strange effects after switch (moreover, there will be some additional - unnecessary processing/delay because of republishing). So I guess that most correct approach will be always recreate TransformListener listening to appropriate topics (or fixed topics but in specified namespace, e.g. /robotX).
from geometry2.
I think you can actually do this already by passing in a custom node_handle with the appropriate remappings applied to it but not to the general use one.
from geometry2.
Thanks Tully, I completely missed this possibility. I will give it a try.
from geometry2.
Hello,
I wanted to have a node which has a tf listener object that listens to topics /tf and /tf_static, and, in the same node, have a second listener that listens to tranformations on different topics, e.g. /ground_truth/tf and /ground_truth/tf_static.
I read you suggestion above but don't know how to create a node handle with remapped arguments.
Do you have any suggestions how I could do this?
Thanks in advance,
Miguel
from geometry2.
Got it. I will write it down here. It may hep others.
First, I created a class called ConfigurableTransformListener which inherits from standard TransformListener. Then, the ConfigurableTransformListener overwrites the constructor, defining which tf and tf_static topics to use.
Seems to be working. Here's the code.
import rospy
from time import sleep
import threading
from tf2_msgs.msg import TFMessage
import tf2_ros
class ConfigurableTransformListener(tf2_ros.TransformListener):
def __init__(self, buffer, queue_size=None, buff_size=65536, tcp_nodelay=False, tf_topic='tf', tf_static_topic='tf_static'):
# Copy past the code from the tf2_ros.TransformListener constructor method, changing the subscribed topics.
self.buffer = buffer
self.last_update = rospy.Time.now()
self.last_update_lock = threading.Lock()
self.tf_sub = rospy.Subscriber(tf_topic, TFMessage, self.callback,
queue_size=queue_size, buff_size=buff_size, tcp_nodelay=tcp_nodelay)
self.tf_static_sub = rospy.Subscriber(tf_static_topic, TFMessage, self.static_callback,
queue_size=queue_size, buff_size=buff_size, tcp_nodelay=tcp_nodelay)
def main():
rospy.init_node('dual_tf_listener', anonymous=False)
tfBuffer = tf2_ros.Buffer()
# listener = tf2_ros.TransformListener(tfBuffer) # this is the conventional way.
listener = ConfigurableTransformListener(tfBuffer, tf_topic='tf_ground_truth',
tf_static_topic='tf_static_ground_truth')
rate = rospy.Rate(3.0)
while not rospy.is_shutdown():
try:
trans = tfBuffer.lookup_transform('world', 'shoulder_link', rospy.Time())
print(trans)
except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException):
print('Could not get transform')
continue
print('sleeping')
sleep(1)
if __name__ == '__main__':
main()
from geometry2.
Related Issues (20)
- tf2 giving NAN values
- Release 0.6.7 never made it into Melodic distro? HOT 2
- PermissionError when using view_frames HOT 2
- Fail out of lookupTransform immediately if extrapolation into the past is required instead of waiting for timeout HOT 1
- Including tf2_geometry_msgs in a catkin package includes two versions of Eigen HOT 1
- Pose and Transform messages are redundant HOT 1
- ROS wiki tf2 tutorial page has errors
- sleep_duration of can_transform takes too much time HOT 1
- New release for Noetic HOT 13
- Wrong warning TF_REPEATED_DATA if 2 different transforms (with different frames) but same timestamp HOT 1
- tf_py.BufferCore not respecting cache_time argument HOT 2
- dotransform TransformStamped datatype not process child_frame_id HOT 2
- rostime_converter loses nanosecond precision
- Failing when Building for Humble with catkin errors
- Error while compiling using catkin for python3.8 HOT 1
- Using AngleShortestPath or getAngleShortestPath in python HOT 2
- Python tf2 buffer does not Detect Jumps in Time HOT 2
- Error in tf2 tutorial
- the parameter "time" not used in canTransform? HOT 1
- Treating a frame and a transform as the same is unclear without digging into source code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geometry2.