Ask Your Question

ultrasonic sensor does not match with URDF

asked 2021-03-09 02:17:07 -0500

updated 2021-03-10 00:04:53 -0500

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 =
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

edit retag flag offensive close merge delete


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.

gvdhoorn gravatar image gvdhoorn  ( 2021-03-09 03:02:07 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2021-03-09 03:05:25 -0500 )edit

@gvdhoom I converted t he values to meter and now i can not see anything on RVIZ

AmirSaman gravatar image AmirSaman  ( 2021-03-09 03:57:13 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2021-03-09 04:17:18 -0500 )edit

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

AmirSaman gravatar image AmirSaman  ( 2021-03-10 00:06:50 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-03-10 02:50:18 -0500

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-03-09 02:17:07 -0500

Seen: 107 times

Last updated: Mar 10