0
$\begingroup$

Rosanswers logo

Hi, I am trying to move a robot through the map in the RVIZ. I have a robot URDF file and also a map. Is it possible to publish a transform between robot base link and map?

By assuming that it is possible, I am trying to is that,

  <launch>
    <arg name="model" default="$(find robot_description)/urdf/description.urdf"/>
    <arg name="gui" default="true" />
    <arg name="rvizconfig" default="$(find urdf_tutorial)/rviz/urdf.rviz" />

    <param name="use_sim_time" value="false"/>
    <param name="robot_description" command="$(find xacro)/xacro $(arg model)" />
    <param name="use_gui" value="$(arg gui)" />

    <node pkg="map_server" type="map_server" name="map_server" args="$(find lidar_simulation)/map/z_map_canteen_28_03_test1.yaml">
      <param name="frame_id" value="map" />
    </node>

    <node pkg="tf" type="static_transform_publisher" name="base_map" args="0 0 0 0 0 0 /odom /map 100" />
    <node pkg="tf" type="static_transform_publisher" name="base_link_odom" args="0 0 0 1.571 0 0 /map /base_link 100" />

    <node if="$(arg gui)" name="joint_state_publisher" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" />
    <node unless="$(arg gui)" name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />

    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />

  </launch>

The above is the launch file. When I launch it, the RVIZ opens and can also visualize the robot and the map. example

To move the robot along with the map, I use topic_tools/transform package and publishing the topic with the following commands.

rosrun topic_tools transform /tf /tf tf2_msgs/TFMessage '[std_msgs.msgeader(0, rospy.Time.now(), "/map"), "/base_link", geometry_msgs.msg.Transform(geometry_msgs.msg.Vector3(1,1,0), geometry_msgs.msg.Quaternion(1.571,0,0,1))]' --import rospy std_msgs geometry_msgs

rosrun topic_tools transform /tf /tf tf2_msgs/TFMessage 'geometry_msgs.msg.TransformStamped [std_msgs.msg.Header(0, rospy.Time.now(), "/map"), "/base_link", geometry_msgs.msg.Transform(geometry_msgs.msg.Vector3(1,1,0), geometry_msgs.msg.Quaternion(1.571,0,0,1))]' --import rospy std_msgs geometry_msgs

Since, the /tf topic uses tf2_msgs/TFMessage and, the rosmsg types and details

But this not working by showing the error TypeError: Invalid number of arguments, args should be ['transforms'] args are( ) . Is there any way to move the robot along with the map or also do my currently trying ways correct?

Thanks for your attention.


Originally posted by yanaing on ROS Answers with karma: 35 on 2020-04-13

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

See this tutorial in c++ or python:

http://wiki.ros.org/tf2/Tutorials/Writing%20a%20tf2%20broadcaster%20%28C%2B%2B%29#How_to_broadcast_transforms

http://wiki.ros.org/tf2/Tutorials/Writing%20a%20tf2%20broadcaster%20%28Python%29

Rewrite the subscriber to a Timer based callback that takes e.g pose.x = pose.x + 0.1 per time iteration (or reading from a file etc) to move it.

You could otherwise manually in the terminal publish the transformation step by step by using:

rosrun tf2_ros static_transform_publisher 1 0 0 0 0 0 map base_link

Depends on what you are trying to do.


Originally posted by bob-ROS with karma: 525 on 2020-04-13

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by yanaing on 2020-04-13:
It works. But the node I have used it tf and therefor I used rosrun tf static_transform_publisher 1 1 0 1.571 0 0 map base_link 5000 and it worked, but it frequently changed to its original location and transform location. Thanks for your help.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.