Discussion - Adding a Lidar to our Robot (Making a Mobile Robot Pt 8)

Blog Post

This is the discussion topic for the video and blog post linked above. Please keep all replies relevant to the content, otherwise create a new topic.

I am a beginner.
$ros2 service call …no working
But
$ros2 service list …is working

Could you please tell me why…

Hey John, sorry for the delay in getting back to this and your YouTube comments - I’ve been busy with the latest video. I’m going to run through and try to reply to them now.

As far as this one goes though, it’s hard to say for sure what the issue is without more context.
So with the lidar driver running, you can run the ros2 service list command and you see the /start_motor and /stop_motor services, but when you call them the lidar doesn’t do anything?

Are you able to get data from the lidar?

Hi Josh,

pi :
ros2 run rplidar_ros rplidar_composition --ros-args -p serial_port:=/dev/ttyUSB0 -p frame_id:=lidar_link -p angle_compensate:=true -p scan_mode:=Standard

mybot@dev-PC:~/dev_ws$ ros2 service list
/rplidar_node/describe_parameters
/rplidar_node/get_parameter_types
/rplidar_node/get_parameters
/rplidar_node/list_parameters
/rplidar_node/set_parameters
/rplidar_node/set_parameters_atomically
/start_motor
/stop_motor

mybot@dev-PC:~/dev_ws$ ros2 service call
usage: ros2 service call [-h] [-r N] service_name service_type [values]
ros2 service call: error: the following arguments are required: service_name, service_type
mybot@dev-PC:~/dev_ws$

mybot@dev-PC:~$ ros2 service call /stop_motor std_msgs/Empty {}
Traceback (most recent call last):
File “/opt/ros/foxy/bin/ros2”, line 11, in
load_entry_point(‘ros2cli==0.9.12’, ‘console_scripts’, ‘ros2’)()
File “/opt/ros/foxy/lib/python3.8/site-packages/ros2cli/cli.py”, line 67, in main
rc = extension.main(parser=parser, args=args)
File “/opt/ros/foxy/lib/python3.8/site-packages/ros2service/command/service.py”, line 41, in main
return extension.main(args=args)
File “/opt/ros/foxy/lib/python3.8/site-packages/ros2service/verb/call.py”, line 58, in main
return requester(
File “/opt/ros/foxy/lib/python3.8/site-packages/ros2service/verb/call.py”, line 69, in requester
module = importlib.import_module(‘.’.join(parts[:-1]))
File “/usr/lib/python3.8/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘std_msgs.srv’
mybot@dev-PC:~$

mybot@dev-PC:~$ ros2 service call /stop_motor std_srvs/srv/Empty
waiting for service to become available…
requester: making request: std_srvs.srv.Empty_Request()

response:
std_srvs.srv.Empty_Response()

mybot@dev-PC:~$ ros2 service call /start_motor std_srvs/srv/Empty
waiting for service to become available…
requester: making request: std_srvs.srv.Empty_Request()

response:
std_srvs.srv.Empty_Response()

------> tried … the motor spin is stopped and start

Hi John, so that looks to me like you got it working then? If so, that’s great!

I can see that you had trouble in there with getting std_msgs and std_srvs mixed up - I’ve definitely made that mistake before and it can be annoying as it’s so subtle!

Hi Josh,
Previously I was using the Slamtec/sllidar_ros2 repo for the lidar node. It seemed to work ok but the start/stop services didn’t.
I switched to allenh1/rplidar_ros and found one unexplained difference. The angle_increment is slightly different with the same scan mode, etc. Since the rplidar_ros is newer I’m going to stick with that. Do you have any thoughts on this? Grabbing random repos off github can lead to all sorts of rabbit holes.

The one thing that bugs me is the lidar spins constantly unless I run the node and tell it to stop. Setting auto_standby:=true helps but quitting the node causes the lidar to start spinning again. It’s probably buried somewhere in the driver.

Cheers

Hi Josh,

I am loving this project so far and really enjoying all the new things to learn!
With the Lidar I have one from a turtlebot 3 kit, it uses a different driver which I installed with this code:

sudo apt install ros-foxy-hls-lfcd-lds-driver.

I am having trouble figuring out how to get it to launch and read data in RVIZ.
I tried using the code:

roslaunch hls_lfcd_lds_driver hlds_laser.launch

However it gives me an import error, any suggestions would be amazing!

Thank you!

Hey! It looks like you are trying to use a ROS 1 launch command, ROS 2 would look something like ros2 launch hls_lfcd_lds_driver hlds.launch (although I haven’t used that package so can’t confirm if that’s correct). Let me know if that works :slight_smile:

That worked however I realized I was using an outdated driver and the more up to date one is the ld08_driver.

How would you suggest installing and running this, I am having difficulty trying to figure that out?

I really appreciate it

Yeah I just took a look and the documentation is pretty sparse, I’m surprised it’s not better. There’s a bit for the old driver but not the new one. It looks like it hasn’t even been packaged for installation.

I’d clone the ld08_driver repo into your workspace, check out the humble-devel branch if you’re on humble, build it, and run the node or launch the launch file. The launch file does basically nothing though.

Beyond that I can’t help too much sorry as I don’t have one of these.

I’m facing some issues
I’m getting data from RPLiDAR sensor when i connected to Pi
I checked with “ros2 topic echo /scan” but when I subscribed to /scan topic from my Computer it’s not showing data neither in Rviz nor in Terminal by running “ros topic echo /scan”

I’m having trouble running the node cpp of YDlidar x3. Do you have any experience with this lidar? I really need some advice. I’m using ROS2 Humble. Thanks. :wave:

Hi Josh!
Thanks for all well-explained tutorials for construction of a mobile robot. I just procured my Lidar and connected it to my raspberry pi 4. I have one issue though ( hopefully you have a solution for that :slight_smile: ). When I run the command to run the RpLidar node by using the ros2 run rplidar …, it shows a bit of information about the hardware (rev, health etc…) but when it comes to publishing a scan, I notice that my Lidar stops spinning for a moment (for milliseconds) and then starts turning again. However, during this, I get an error message on the screen:
[ERROR] [1690437769.099036892] [rplidar_node]: Cannot start scan: ‘80008000’
Can you help me with this issue? Seems to be a power issue but I don’t understand how this could be the case since I checked it after unplugging arduino from the pi as well. Any help on this matter would be highly appreciated.
Thank You in Advance!

The problem is resolved now. I increased the voltage supplied to GPIO pins of Raspberry Pi. The previous voltage was about 4.95V, so I increased it upto 5.15V. It works totally fine now.
Thank You!

hi Josh
I am trying to use the rplidar_ros package but I got an error like this
[ERROR] [1693739762.086191590] [rplidar_node]: Error, operation time out. SL_RESULT_OPERATION_TIMEOUT!

Hi Josh,
Thanks for the great set of tutorials. I am trying to do the same on a small robot I’m making. So far, I’ve managed to go through pretty much all the blogs and videos until mapping and it’s worked fine. However, I am facing an issue - since the LiDAR on my robot isn’t mounted outside and rather inside the body, I need to filter out the messages so that slam_toolbox doesn’t take the garbage data into consideration.

Looking around I found ros-perceptions’ laser_filters and used them. The filter “works” and I am able to use an Angular filter to filter out any laser scan messages I don’t need. There is an issue though. The filter takes in messages from /scan and spits out filtered messages on /scan_filtered. When I try to see /scan_filtered in rviz (or use it for mapping using slam toolbox) I get the following error messages -

[INFO] [1694107119.733352335] [rviz]: Message Filter dropping message: frame 'laser_frame' at time 1694107136.289 for reason 'Unknown'

I still get very few laser scan messages which are accepted, but too little, and its even worse with slam toolbox not able to create any map using it.

What’s facinating is that when I switch to “laser_frame” as the fixed frame in rviz, no messages are dropped.
I am still very new to ROS and not sure how to fix this issue.

Hope you can help or atleast show me the right way to get this resolved.

Thanks!

Hi Muthu,

Did you ever find a solution to this? I’m getting the same error and am unsure if it has to do with the ros version (iron) I am using being incompatible or something else entirely.

I’m contemplating cloning a repo from github as a workaround (ex allenh1’s repo), but was hoping to follow Josh’s method if possible.

Thanks!
Max

I resolved my issue by increasing the voltage to my pi using the screw terminal on the motor driver board. Seems to be a common trend :slight_smile:

I am using a Power bank to power my pi and getting the same 80008000 || operation timed out Error .
i used a voltage regulator to convert 12v to 5v and used it on my raspberry pi 3 B model but unfortunately its usb ports got fried/short circuited due to excess voltage i believe . I cannot risk to do the same to my raspberrypi 4 too which i am currently using . What are other ways to give more power to the pi and it still being mobile car .

And what does " the screw terminal on the motor driver board " means i cant understand ?

Hi, now you are my favorite youtuber/engneer/programmer… Simply I love your work… Articubot make me very happy and I have built It following your tutorial, I’m Italian and you are the only person that made understable tutorial for me… Now… The real robot articubot you realized is great, I have “clone” it, simulated and real… I noticed that this fall off when surface Is not a flat… Lidar can’t detect hole or if Is on the table…Simply fall off… Now…an ir sensor (like roomba) Arduino compatibile (5V on/off) cost nothing… I would like to add it in front and rear of wheels (using depht camera for this is not so simple) but I’m not able ti do it…I am able to add an Arduino and read sensors, publish to Ros2 topic etc… But integrate it into navigation code, visualize in Rviz Is a problem for me (flat surface in Rviz Is zero and can’t visualize negative surface)… Can you help me to do this? For me would be fantastic realize something working like roomba navigation; articubot_one help me to do it except for anti-falling sensor. Please consider this for your work :slight_smile: thanks