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!