ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

open two vrpn_client_ros nodes with different parent frame

asked 2019-03-21 12:49:18 -0500

cocodmdr gravatar image

Hello, I am using optitrack's motive and vrpn_client_ros on ROS kinetic: it works really well and I would like to go further! I am looking for a way to get twice the data that optitrack is sending but change the parent frame so I can do different transformation for each parent frame. I tried something with the launch file above but it seems that I cannot run twice the same node, or at least because the child frame renaming is not really working. Do you know a way of doing this ? Thank you for your answers

  <launch>


  <node pkg="trimbot_optitrack" type="optitrack_world_tf_broadcaster.py" name="broadcaster_fixed" />



  <arg name="server" default="localhost"/>

  <node pkg="vrpn_client_ros" type="vrpn_client_node" name="vrpn_client_node_1" output="screen">
  <rosparam subst_value="true">
      server: $(arg server)
      port: 3883

      update_frequency: 100.0
      frame_id: parent_frame_1

      # Use the VRPN server's time, or the client's ROS time.
      use_server_time: false
      broadcast_tf: true
      # Must either specify refresh frequency > 0.0, or a list of trackers to create
      #refresh_tracker_frequency: 1.0
      trackers:
      - FirstTracker1
      - SecondTracker1
    </rosparam>
  </node>

  <node pkg="vrpn_client_ros" type="vrpn_client_node" name="vrpn_client_node_2" output="screen">

  <rosparam subst_value="true">

    server: $(arg server)
    port: 3883

    update_frequency: 100.0
    frame_id: parent_frame_2

    # Use the VRPN server's time, or the client's ROS time.
    use_server_time: false
    broadcast_tf: true

    # Must either specify refresh frequency > 0.0, or a list of trackers to create
    refresh_tracker_frequency: 1.0
    trackers:
      - FirstTracker2
      - SecondTracker2
    </rosparam>
  </node>
  </launch>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-22 03:58:17 -0500

cocodmdr gravatar image

updated 2019-03-22 04:00:31 -0500

I figured out an other way of doing this with tf tools ! I listened to the tf given by optitrack and created a copy of it :with a broadcaster.

#!/usr/bin/env python  
import rospy
import tf
import math

    if __name__ == '__main__':
        rospy.init_node('optitrack_world_tf_broadcaster')
        br = tf.TransformBroadcaster()
        listener = tf.TransformListener()
        rate = rospy.Rate(10.0)

        while not rospy.is_shutdown():
            #default transform

            # br.sendTransform((0, 0, 0),
            #                  (0, 0, 0, 1),
            #                  rospy.Time.now(),
            #                  "optitrack_world",
            #                  "root")

            br.sendTransform((-0.16920417515546746, -0.5563525767050427, -0.27338196631565076),
                             (-1.05271512e-03,  1.37081378e-04,  5.78279757e-01,  8.15835878e-01),
                             rospy.Time.now(),
                             "optitrack_world",
                             "root")

            br.sendTransform((0, 0, 0),
                             (0, 0, 0, 1),
                             rospy.Time.now(),
                             "optitrack_world_2",
                             "root")

            # br.sendTransform((-0.16920417515546746, -0.5563525767050427, -0.27338196631565076),
            #                  (-1.05271512e-03,  1.37081378e-04,  5.78279757e-01,  8.15835878e-01),
            #                  rospy.Time.now(),
            #                  "optitrack_world_2",
            #                  "root")

            #duplicate optitrack marker by changing the parent frame
            try:
                pose=listener.lookupTransform('/optitrack_world', '/opti_jaco_tool', rospy.Time(0))
                #print(pose)

            except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
                continue

            br.sendTransform(pose[0],
                             pose[1],
                             rospy.Time.now(),
                             "opti_jaco_tool_2",
                             "optitrack_world_2")

            br.sendTransform((0.05084971876793498, 0.10725755461471259, -0.04812376658638684),
                             (0.21858535534051216, -0.26630475431444084, -0.5192716979131322, -0.7820864939596369),
                             rospy.Time.now(),
                             "opti_tcp",
                             "opti_jaco_tool")

            br.sendTransform((0.05084971876793498, 0.10725755461471259, -0.04812376658638684),
                             (0.21858535534051216, -0.26630475431444084, -0.5192716979131322, -0.7820864939596369),
                             rospy.Time.now(),
                             "opti_tcp_2",
                             "opti_jaco_tool_2")

            rate.sleep()
edit flag offensive delete link more

Question Tools

Stats

Asked: 2019-03-21 12:49:18 -0500

Seen: 221 times

Last updated: Mar 22 '19