0
$\begingroup$

Rosanswers logo

Hi, I'm using ROS melodic on Ubuntu 18 and I want to perform SLAM using rviz.

I have got a dual drive robot controlled by Arduino via Serial. I have a node that reads/writes data from serial and publish/subscribe them as topic.

This is the topic list:

/clicked_point
/cmd_vel
/cmd_vel_mux/input/navi
/diagnostics
/horizontal_servo_pos
/initialpose
/joint_states
/joy
/joy/set_feedback
/left_encoder
/left_motor_speed
/left_velocity
/left_wheel_target
/make_scan
/map
/map_metadata
/map_updates
/move_base/current_goal
/move_base/goal
/move_base_simple/goal
/odom
/right_encoder
/right_motor_speed
/right_velocity
/right_wheel_target
/rosout
/rosout_agg
/scan
/serial_msg
/slam_gmapping/entropy
/tf
/tf_static
/ultrasonic_distance
/ultrasonic_scan
/vertical_servo_pos

This is my file .urdf

<robot name="robot">

  <link name="odom">
  </link>

  <joint name="base_to_odom" type="fixed">
    <parent link="odom"/>
    <child link="base_footprint"/>
    <origin xyz="0 0 0" rpy="0 0 0"/>
  </joint>

  <link name="base_footprint">
    <visual>
      <geometry>
        <box size="0.23 0.12 0.01"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0.055"/>
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
  </link>
</robot>

This is my launch file for navigation:

<launch>

  <arg name="model" default="$(find robot)/urdf/robot_z.urdf"/>
  <arg name="gui" default="true" />
  <arg name="rvizconfig" default="$(find robot)/rviz/config_z.rviz" />

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

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

  <include file="$(find robot)/launch/includes/gmapping.launch.xml"/>
  <include file="$(find robot)/launch/includes/move_base.launch.xml"/>
   
</launch>

I can use a Joystick to move around the robot.

This is my rviz screenshot: Rviz with fixed frame = map https://pasteboard.co/IumPN58.png

I can move the robot (rappresented by "little car" ) in this world but the laser scanner refers to /odom in the center of world. I tried to change "Fixed frame" from map to "base_footprint" and the robot figure holds in the map while the other axes move around the world with laser scanner points as shown in figure: Rviz with fixed frame = base_footprint https://pasteboard.co/IumQ8iJ.png

How can I link the robot with laser scanner and odometry?

However I get this warning:

[ WARN] [1566756673.514885761]: Timed out waiting for transform from \base_footprint to \map to become available before running costmap, tf error: canTransform: target_frame \map does not exist. canTransform: source_frame \base_footprint does not exist.. canTransform returned after 0.100995 timeout was 0.1.

I also like to use 2DNavGoal function to comand the robot from rviz but when i use it, nothing in appening.

Thanks a lot. If you need other info I will update the post.


Originally posted by FabioZ96 on ROS Answers with karma: 48 on 2019-08-25

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

You are missing important transforms. Without them, your data is not properly tied together. See REP 105 for the coordinate transforms you need to provide.

For the laser scan, you need to tell TF where your laser scanner is in relation to your robot. Add a link to your URDF to represent the laser and then add a joint from the base_footprint to it. Something like this should work, although it won't have a visualisation of the sensor itself and you will need to fix the actual location of the sensor on the robot:

<joint name="base_to_laser" type="fixed">
  <parent link="base_footprint"/>
  <child link="laser"/>
  <origin xyz="0 0 0" rpy="0 0 0"/>
</joint>

<link name="laser"/>

Originally posted by Geoff with karma: 4203 on 2019-08-25

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by FabioZ96 on 2019-08-28:
Thanks for your answer. I tried to add this code to my URDF file and I tried to create joints combining map, odom, base_footprint and others according REP 105. It doesn't work anyway. I still get this warning

[ WARN] [1566983313.478918449]: Timed out waiting for transform from \base_footprint to \map to become available before running costmap, tf error: canTransform: target_frame \map does not exist. canTransform: source_frame \base_footprint does not exist.. canTransform returned after 0.100382 timeout was 0.1.

Nothing changes.

Comment by Geoff on 2019-08-28:
By "It doesn't work anyway" do you mean the laser data still does not move with the robot?

The warning about navigation should be ignored until you've got the laser data fixed on the robot properly. Then you can start dealing with getting navigation working.

Comment by FabioZ96 on 2019-08-28:
Exactly...the laser scan data stay in the center while the robot moves around as shown in first figure.

Comment by Geoff on 2019-08-29:
Please post the result of running rosrun tf view_frames

Comment by FabioZ96 on 2019-08-30:
fabio@fabio:~/Scrivania/ProgettoLab/prog/robot_ws$ rosrun tf view_frames Listening to /tf for 5.0 seconds Done Listening dot - graphviz version 2.40.1 (20161225.0304)

Detected dot version 2.40
frames.pdf generated

Here is the file .pdf generated: https://drive.google.com/drive/folders/1s23baWBvgleJ5pxvWWRfsrwq-j_1Q1H7?usp=sharing

$\endgroup$
0
$\begingroup$

Rosanswers logo

I solved it.

The problem was that the publisher of laser scan, set the frame id to "odom" and not to "scan".

I solved tring this:

scan = LaserScan()
**scan.header.frame_id = "base_scan" #fake_laser_frame"**
...#code to set object's param
scan.ranges = ranges
self._scan_pub.publish(scan)

Originally posted by FabioZ96 with karma: 48 on 2019-09-05

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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