Discussion - Writing a ros2_control hardware interface (Making a Mobile Robot Pt 20)

Blog post coming

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.

2 Likes

Hi there, I’m looking to use this video to help me generate a hardware interface for the Robomaster (DJI) M2006 BLDC + C610 ESC’s that actuate my 3 DOF robotic arm (a ‘simple’ project to help me become more knowledgeable). I already hit a first snag when running colcon build --symlink-install after downloading both example_2 and example_6 from the ros2_control_demos repository. I get a ton of errors including the two below (I figured I’d start there):

  • In file included from /home/ubuntu/ros2_ws/src/example_2/hardware/diffbot_system.cpp:15: /home/ubuntu/ros2_ws/src/example_2/hardware/include/ros2_control_demo_example_2/diffbot_system.hpp:42:23: error: \u2018CallbackReturn\u2019 in namespace \u2018hardware_interface\u2019 does not name a type 42 | hardware_interface::CallbackReturn on_init(
  • /home/ubuntu/ros2_ws/src/example_2/hardware/diffbot_system.cpp: In member function \u2018hardware_interface::return_type ros2_control_demo_example_2::DiffBotSystemHardware::write(const rclcpp::Time&, const rclcpp::Duration&)\u2019: /home/ubuntu/ros2_ws/src/example_2/hardware/diffbot_system.cpp:227:7: error: \u2018info_\u2019 was not declared in this scope 227 | info_.joints[i].name.c_str());

I downloaded from the master branch on GitHub and am trying to build using Foxy in a docker container. I’ll admit that I’m very much NOT knowledgeable about C++, this might be something very silly. Much appreciated if someone can help me get started!

hi, joshnewans. i have issue with encoder dc motor. the two encoders wheels of my robot has different value of counter per second. how can I config ros2 control for each wheel. it is possible?

Hi, this usually means you haven’t installed ros2_control correctly, or haven’t “sourced” it.
Are you building ros2_control as well or just installing it through apt? I’d recommend the latter :slight_smile:

Hi, yeah a few people have raised this and I mentioned it briefly in the video. All you need to do is find where the shared value is used (XML, config struct, parameter reading) and duplicate it, name them appropriately for left/right, and set up the two wheel structs appropriately.
That probably sounds confusing but all in all it’s about 4 lines change.

1 Like

Hi, I installed ros2 control using apt. I ran source ~/ros2_ws/install/setup.bash but that did not improve things. In a Humble docker container I can build without issues. However, I’d like to use Foxy as I’ve haven’t been able to get Gazebo working on Humble on my M1 Mac. Also, when I ros2 launch ros2_control_demo_example_2 diffbot.launch.py on Humble, rviz is all black where the ‘world’ should be. Which is surprising as all other rviz GUI elements display correctly and there are no error messages in the terminal. Does the fact that I can compile on Humble, but not on Foxy trigger any thoughts?

Thanks Joshn for answering me. I followed your instructions . And I successfully colcon build my workplace. But I haven’t tried it in rviz2 yet. I’ll do it tomorrow. Because I’m very sleepy😅

Yeah so the humble and foxy branches are different. Right now main is foxy and humble is humble, so make sure you are on the right branch (I should clarify those in the naming, and humble will eventually become the default probably).

Re the rviz thing, is that in the humble docker container? I started having that problem a little while back, there was an update to a system package that broke it. From memory I had to manually downgrade a package to fix it.

I just found a discussion on it [here] (Black Screen on version 11.2.5 · Issue #948 · ros2/rviz · GitHub), check out the last post.

Thanks, I got the demos working in both Foxy and Humble docker containers.

1 Like

Hi @JoshNewans How could i do if i am using Foxy ? i need your instruction .