Rosanswers logo

Hi guys,

I have a real robot with 4 diffrent ultrasonic sensors publishing on 4 different topics. I used the same name in my URDF file as publishers however when i want to display it on RVIZ the location is wrong. is there any guidline that i can refer to ? or anyone has idea what i am doing wrong ?

image description

image description

This is the topic echo

ubuntu@ubuntu:~$ rostopic echo /lSonic

  seq: 4023
    secs: 1615356239
    nsecs: 343081474
  frame_id: "/base_footprint"
radiation_type: 0
field_of_view: 0.25999999046325684
min_range: 0.0
max_range: 7.0
range: 5.357534885406494

This is the topic info

ubuntu@ubuntu:~$ rostopic info /lSonic
Type: sensor_msgs/Range

 * /ultrasonic (http://ubuntu:42959/)

 * /rviz_1615277321083748871 (http://vm-ubuntu-20:42115/)

This is ultrasonic publisher code

r = Range()
r.header.stamp = rospy.Time.now()
r.header.frame_id = "/base_footprint"
r.radiation_type = 0
r.field_of_view = 0.26
r.min_range = 0.0
r.max_range = 7.0
r.range = measurementInCM(GPIO_SIGPIN)/100

Originally posted by AmirSaman on ROS Answers with karma: 130 on 2021-03-09

Post score: 1

Original comments

Comment by gvdhoorn on 2021-03-09:
I'm sorry to have to do this for something so seemingly unimportant, but please don't post screenshots of terminal text in question on ROS Answers. It's all text, so there is no need. Just copy-paste the text from the terminal into your question text. Do make sure to format it properly by selecting the text and pressing ctrl+k (or clicking the Preformatted Text button (the one with 101010 on it)).

You don't need to post a new question, just edit your curent one. You can use the edit button/link for this.

After you replace the screenshot with the error message itself, we can re-open your question.

Comment by gvdhoorn on 2021-03-09:
As to your problem: as stated in the sensor_msgs/Range documentation, min_range, max_range and range use units of metres.

Does your sensor really have a max range of 350 metres?

It's likely you're populating the fields with data in centimetres.

Comment by AmirSaman on 2021-03-09:
@gvdhoom I converted t he values to meter and now i can not see anything on RVIZ

Comment by gvdhoorn on 2021-03-09:
The max_range of your sensor is 7.5 cm? That seems really small. Previously (in the screenshots) it was 350 metres (or centimetres, if it was centimetres). Wouldn't that be 3.5 m after conversion instead?

Comparing the screenshots with the rostopic echo output you show now, perhaps you divided by 1e3 instead of 1e2?

And field_of_view is 0.10000000149011612 radians? That's only approx 5.7 degrees. Possible of course, but also seems small.

Comment by AmirSaman on 2021-03-10:
Thank you for your answer, I already modify the code accordingly now it become better however the location is still wrong. look at the first picture the range should be start from leftside of the robot and look at left not right


1 Answer 1


Rosanswers logo

I found the soultion, the problem was in this line

frame_id: "/base_footprint" I had to remove the "/" and now everything is working fine.

Originally posted by AmirSaman with karma: 130 on 2021-03-10

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

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