It looks like that branch is for Humble. I’m using Foxy, can it be used with it or do I need to upgrade?
Hey @JoshNewans thank you for the great tutorial, it has been of great benefit to us as students. We are having difficulty loading the /controller_manager services, we’ve tried the solutions you suggested earlier in the thread to @Sasffm, but it is still not working. We have the same setup, and the device port has been set correctly, even the user has been added to the dialout group. The following is the error obtained on running the launch file.
[INFO] [launch]: All log files can be found below /home/vahin/.ros/log/2023-06-07-09-52-16-628234-ubuntu-13541
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [13544]
[robot_state_publisher-1] Parsing robot urdf xml string.
[robot_state_publisher-1] Link chassis had 2 children
[robot_state_publisher-1] Link caster_wheel had 0 children
[robot_state_publisher-1] Link laser_frame had 0 children
[robot_state_publisher-1] Link left_wheel had 0 children
[robot_state_publisher-1] Link right_wheel had 0 children
[robot_state_publisher-1] [INFO] [1686131537.466259297] [robot_state_publisher]: got segment base_link
[robot_state_publisher-1] [INFO] [1686131537.466644027] [robot_state_publisher]: got segment caster_wheel
[robot_state_publisher-1] [INFO] [1686131537.466723784] [robot_state_publisher]: got segment chassis
[robot_state_publisher-1] [INFO] [1686131537.466753468] [robot_state_publisher]: got segment laser_frame
[robot_state_publisher-1] [INFO] [1686131537.466781004] [robot_state_publisher]: got segment left_wheel
[robot_state_publisher-1] [INFO] [1686131537.466809170] [robot_state_publisher]: got segment right_wheel
[INFO] [ros2_control_node-2]: process started with pid [13606]
[INFO] [spawner.py-3]: process started with pid [13608]
[INFO] [spawner.py-4]: process started with pid [13610]
[ros2_control_node-2] [INFO] [1686131543.680967466] [DiffDriveArduino]: Configuring...
[ros2_control_node-2] [INFO] [1686131543.687668416] [DiffDriveArduino]: Finished Configuration
[ros2_control_node-2] [INFO] [1686131543.688505651] [DiffDriveArduino]: Starting Controller...
[ros2_control_node-2] [INFO] [1686131545.719892550] [controller_manager]: update rate is 30 Hz
[ros2_control_node-2] [INFO] [1686131545.762545973] [controller_manager]: Loading controller 'diff_cont'
[ros2_control_node-2] [ERROR] [1686131545.762714005] [controller_manager]: Loader for controller 'diff_cont' not found.
[ros2_control_node-2] [INFO] [1686131545.762758207] [controller_manager]: Available classes:
[ros2_control_node-2] [INFO] [1686131545.762797873] [controller_manager]: controller_manager/test_controller
[ros2_control_node-2] [INFO] [1686131545.762828928] [controller_manager]: controller_manager/test_controller_failed_init
[ros2_control_node-2] [INFO] [1686131545.762866667] [controller_manager]: controller_manager/test_controller_with_interfaces
[ros2_control_node-2] [INFO] [1686131545.835433835] [controller_manager]: Loading controller 'joint_broad'
[ros2_control_node-2] [ERROR] [1686131545.835685402] [controller_manager]: Loader for controller 'joint_broad' not found.
[ros2_control_node-2] [INFO] [1686131545.835744493] [controller_manager]: Available classes:
[ros2_control_node-2] [INFO] [1686131545.835786603] [controller_manager]: controller_manager/test_controller
[ros2_control_node-2] [INFO] [1686131545.835817731] [controller_manager]: controller_manager/test_controller_failed_init
[ros2_control_node-2] [INFO] [1686131545.835846286] [controller_manager]: controller_manager/test_controller_with_interfaces
[ERROR] [spawner.py-4]: process has died [pid 13610, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py diff_cont --ros-args'].
[ERROR] [spawner.py-3]: process has died [pid 13608, exit code 1, cmd '/opt/ros/foxy/lib/controller_manager/spawner.py joint_broad --ros-args'].
Is there something we’ve missed out on? The controller_manager had issues earlier as well when running on the dev machine but it was sorted when it was rerun a few times.
Ok so the main error here is that it goes to load diff_cont
and joint_broad
but can’t find them. Instead it is finding one called test_controller
(I’m not sure if you’ve put that in or if it’s standard?)
Do you have a controllers.yaml
file that you are passing in? What is inside it? You should have the diff drive controller and joint state broadcaster defined in there.
If that is set up correctly, then make sure it is actually being loaded!
Yeah the old branch is foxy but I’m not really maintaining it.
The principles are all pretty similar so if you compare the two and watch this video you should be able to figure it out.
Thank you for your prompt response and suggestions, we will look into it.
I have a really weird Issue. The robot drives forwards and backwards fine but it doesn’t turn.
Hmm that is odd.
Is this with teleoperation or autonomous control?
I’d first use ros2 topic echo
to check the contents of your cmd_vel topic are correct and you are sending a Z rotation.
If that is all ok then check your diff drive parameters (wheel spacing etc) are all correct and you don’t have anything odd in there like rotational limits.
Both it is even a problem when I just use the ROS-Arduino-Bridge.ino and miniterm. When I type o 255 255 or negative it works fine. When I type o 255 -255 the motors don’t turn at all.
After fooling around with it quite a bit, I do see that it is the PID values, possible something else as well. I could sit and fool with the values, but the behavior is still strange (the motors start slow and rev up to the required speed, but overshoot it and reverse directions). Open loop control works great. I would love to rewrite this thing at some point. I’m fuzzy on a few things I need to research first, like how to translate input tick count to speed to PWM. I’m also not sure what “Ko” is in the PID code. Josh, what are the RPM speeds of your motors? I think mine are about 250 or so, maybe too much for this application (if that even makes a difference). Anyway, I’ll keep fussing with it.
[INFO] [launch]: All log files can be found below /home/cliff/.ros/log/2023-06-11-09-19-26-129315-cliff-Legion-4342
[INFO] [launch]: Default logging verbosity is set to INFO
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:226> exception=PackageNotFoundError("package 'twist_mux' not found, searching: ['/home/cliff/dev_ws/install/serial_motor_demo', '/home/cliff/dev_ws/install/serial_motor_demo_msgs', '/home/cliff/dev_ws/install/diffdrive_arduino', '/home/cliff/dev_ws/install/serial', '/home/cliff/dev_ws/install/articubot_one', '/opt/ros/foxy']")>
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/ament_index_python/packages.py", line 50, in get_package_prefix
content, package_prefix = get_resource('packages', package_name)
File "/opt/ros/foxy/lib/python3.8/site-packages/ament_index_python/resources.py", line 48, in get_resource
raise LookupError(
LookupError: Could not find the resource 'twist_mux' of type 'packages'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 228, in _process_one_event
await self.__process_event(next_event)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 248, in __process_event
visit_all_entities_and_collect_futures(entity, self.__context))
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
[Previous line repeated 1 more time]
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
sub_entities = entity.visit(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
return self.execute(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/actions/node.py", line 453, in execute
ret = super().execute(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/execute_process.py", line 823, in execute
self.__expand_substitutions(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/execute_process.py", line 668, in __expand_substitutions
cmd = [perform_substitutions(context, x) for x in self.__cmd]
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/execute_process.py", line 668, in <listcomp>
cmd = [perform_substitutions(context, x) for x in self.__cmd]
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
return ''.join([context.perform_substitution(sub) for sub in subs])
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
return ''.join([context.perform_substitution(sub) for sub in subs])
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_context.py", line 232, in perform_substitution
return substitution.perform(self)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/substitutions/executable_in_package.py", line 76, in perform
package_prefix = super().perform(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/substitutions/find_package.py", line 79, in perform
result = self.find(package)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/substitutions/find_package.py", line 96, in find
return get_package_prefix(package_name)
File "/opt/ros/foxy/lib/python3.8/site-packages/ament_index_python/packages.py", line 52, in get_package_prefix
raise PackageNotFoundError(
ament_index_python.packages.PackageNotFoundError: "package 'twist_mux' not found, searching: ['/home/cliff/dev_ws/install/serial_motor_demo', '/home/cliff/dev_ws/install/serial_motor_demo_msgs', '/home/cliff/dev_ws/install/diffdrive_arduino', '/home/cliff/dev_ws/install/serial', '/home/cliff/dev_ws/install/articubot_one', '/opt/ros/foxy']"
Task exception was never retrieved
future: <Task finished name='Task-8' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:226> exception=RuntimeError('Signal event received before subprocess transport available.')>
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 228, in _process_one_event
await self.__process_event(next_event)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 248, in __process_event
visit_all_entities_and_collect_futures(entity, self.__context))
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
sub_entities = entity.visit(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
return self.execute(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/opaque_function.py", line 75, in execute
return self.__function(context, *self.__args, **self.__kwargs)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/execute_process.py", line 443, in __on_signal_process_event
raise RuntimeError('Signal event received before subprocess transport available.')
RuntimeError: Signal event received before subprocess transport available.
[INFO] [robot_state_publisher-1]: process started with pid [4345]
[robot_state_publisher-1] Parsing robot urdf xml string.
[robot_state_publisher-1] Link base_footprint had 0 children
[robot_state_publisher-1] Link chassis had 4 children
[robot_state_publisher-1] Link camera_link had 1 children
[robot_state_publisher-1] Link camera_link_optical had 0 children
[robot_state_publisher-1] Link caster_wheel had 0 children
[robot_state_publisher-1] Link face_link had 0 children
[robot_state_publisher-1] Link laser_frame had 0 children
[robot_state_publisher-1] Link left_wheel had 0 children
[robot_state_publisher-1] Link right_wheel had 0 children
[robot_state_publisher-1] [INFO] [1686455366.472416353] [robot_state_publisher]: got segment base_footprint
[robot_state_publisher-1] [INFO] [1686455366.472564150] [robot_state_publisher]: got segment base_link
[robot_state_publisher-1] [INFO] [1686455366.472588526] [robot_state_publisher]: got segment camera_link
[robot_state_publisher-1] [INFO] [1686455366.472606757] [robot_state_publisher]: got segment camera_link_optical
[robot_state_publisher-1] [INFO] [1686455366.472624637] [robot_state_publisher]: got segment caster_wheel
[robot_state_publisher-1] [INFO] [1686455366.472642309] [robot_state_publisher]: got segment chassis
[robot_state_publisher-1] [INFO] [1686455366.472659212] [robot_state_publisher]: got segment face_link
[robot_state_publisher-1] [INFO] [1686455366.472675486] [robot_state_publisher]: got segment laser_frame
[robot_state_publisher-1] [INFO] [1686455366.472692599] [robot_state_publisher]: got segment left_wheel
[robot_state_publisher-1] [INFO] [1686455366.472709362] [robot_state_publisher]: got segment right_wheel
[ERROR] [robot_state_publisher-1]: process[robot_state_publisher-1] failed to terminate '5' seconds after receiving 'SIGINT', escalating to 'SIGTERM'
[INFO] [robot_state_publisher-1]: sending signal 'SIGTERM' to process[robot_state_publisher-1]
[ERROR] [robot_state_publisher-1]: process has died [pid 4345, exit code -15, cmd '/opt/ros/foxy/lib/robot_state_publisher/robot_state_publisher --ros-args --params-file /tmp/launch_params_zw350_hn'].
Cant find whats actually going wrong, feels like its ros not building properly
Very odd, I’m suspicious of maybe a wiring issue with the motors/driver/arduino?
Do
o 255 0
o -255 0
o 0 255
-
o 0 -255
All work as expected?
Interesting, I have had similar problems with other motors. I still got them to work but they were a bit more sensitive to the PID settings.
Yeah me too. I didn’t write the Arduino code (just made some small mods) and would like to do it from scratch.
I also found this confusing. I believe this and also the reason everything is done in “encoder ticks per loop” is to avoid doing floating point arithmetic in the Arduino. So the Ko
just scales things up. E.g. if we want Kp = 0.5
(and Ko = 1
) we can’t do that, so instead we set Kp = 5
and Ko = 10
.
It’s a little while since I dug into it though so that might be not quite right.
Pretty sure they are 110RPM. 250 is pretty fast, especially if your encoders aren’t super fast. E.g. your requests might boil down to the difference between a few integers in counts per loop and the PID will be jumping rapidly between them.
Make sure when posting code blocks (I have edited yours) you put backticks (the ~
key without shift) around it to make it easier to read, like this:
```
My code here
```
Your issue here is you don’t have twist_mux
installed (sudo apt install ros-foxy-twist-mux
).
This error should be clearer, except I have not explicitly made twist_mux
a dependency of articubot_one
so it tries to run without checking that it exists, and you get that very messy error.
I found the problem it seems to be some internal problem with the Arduino uno, it works fine on the nano.
I think I will take a stab at writing new Arduino code. Josh, if you were personally to do this would you continue using Serial or would you go for something like MicroROS (keeping in mind one could no longer use the Nano if that were the case)? I use the Teensy quite a bit so perhaps I’ll try something for both (I’d like to learn MicroROS myself). This is out of scope so I’ll start a new topic for discussion later.
Hey Josh, wanted to let you know I purchased a couple of 100RPM motors and that seemed to do the trick. Everything is now running smoothly. Those other motors were probably just too fast for the PID/encoders to handle.
BTW, is it possible to get permissions to create new topics? It doesn’t look like I have (unless I’m not supposed to).
Nice, I’m very glad that sorted it (it’s always disappointing when you sink money into extra hardware and it doesn’t help!)
Yeah, creating new topics is restricted to paid members over at Patreon however I have tried to make the bottom tier very affordable. This also gets you access to the Discord server and helps support the channel.
I haven’t got Patreon and Discourse synced up yet though and have to update user permissions manually, so don’t be afraid to remind me if needed
Sounds fair. I have now joined Patreon.
Maybe the answer to this is in my face and I don’t see it, but I’m going to ask anyway. I’ve created a launch file for the physical robot after success with all the simulations. It runs and teleoperates just fine. When I open RVIZ, however, I noticed that the model’s wheels are screwed up because the wheel transforms can’t be resolved (we used to cheat and run joint_state_publisher_gui to resolve this). This does not happen when running RVIZ with the Gazebo simulation. Is this behavior correct? Is there something I can do (besides running the JSP gui) to fix this issue?
Edit: I figured it out. I had the wheels parented to the base_link. When I changed the parent to the chassis the joints are now recognized. I’m leaving this post for anyone who might have the same issue with their design.
Im having issues where my Twist msgs from teleop is having the following problems:
-not updating my robot position correctly
-unstable, moves slow sometimes and very fast other times
-when moving straight, it never updates the position except for a fixed 0.1 meter even if i keep going straight for more.
-after a few turns, it gets stuck and i cant use teleop anymore until i manually nudge the wheel.
note: the updates and revolutions are exact when im turning the wheels using my hands. the problems start when i use teleop.
and i am also confused about where to change my PID values because there are ones in the diffdrive_arduino.cpp (arduino_.setPidValues(30,20,0,100)) and ones in the arduino file, which ones should i be changing?
All the code works up until the gazebo simulation and mapping.
im using ros humble and have updates my files appropriately using your most recent video.
Any help as to where to start fixing the issue would be very very appreciateddd
FIXED!! = The issue was very very lame, even though i spent days changing the code assuming its the cause. The issue was wiring and power! the encoders and logic were getting the power from the controller because i forgot to provide it power and ground it from and to the arduino, and it caused it to keep shutting off and on and acting crazy.