PickNikRobotics / topic_based_ros2_control

ros2_control hardware interface that uses topics to command the robot and publish its state
BSD 3-Clause "New" or "Revised" License
61 stars 19 forks source link

Implement package for diff drive robot #15

Open holmbuar opened 11 months ago

holmbuar commented 11 months ago

I have made a working hardware component for a diff drive robot, based on the ROS2 control demo. I even set up a communication ROS2 node to my microcontroller inside the HW interface, which I later learned was bad practice.

I was pointed to this package, installed the apt version, and now I'm trying to understand how I can use it in my ROS2 humble based project.

After adding the plugin to ros2_control.xacro,

<hardware>
  <plugin>topic_based_ros2_control/TopicBasedSystem</plugin>
  <param name="joint_commands_topic">/diffbot_joint_commands</param>
  <param name="joint_states_topic">/diffbot_joint_states</param>
  <param name="trigger_joint_command_threshold">0.001</param>
  <param name="sum_wrapped_joint_states">false</param>
</hardware>

I can build and launch the diffbot, and the topics show up on ros2 topic list. However, I'm not quite sure how to start reading and writing joint states, using this package.

Including the package in my diffbot_system.cpp

#include "topic_based_ros2_control/topic_based_system.hpp"

colcon build yields

fatal error: topic_based_ros2_control/topic_based_system.hpp: No such file or directory
   36 | #include "topic_based_ros2_control/topic_based_system.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

In my CMakeLists.txt:

# find dependencies
set(THIS_PACKAGE_INCLUDE_DEPENDS
  hardware_interface
  pluginlib
  rclcpp
  rclcpp_lifecycle
  topic_based_ros2_control
)

In my package.xml:

<depend>topic_based_ros2_control</depend>

Also tried

rosdep install --ignore-src --from-paths . -y
colcon build --symlink-install --event-handlers log-
source install/local_setup.bash 

@JafarAbdi I would greatly appreciate some pointers to correct my path.

JafarAbdi commented 11 months ago

You don't need to include this package in your system, this package will work with robots that uses topics to control the robot/publish its state, can you add more info about your system/robot?

Tagging @MarqRazz since he worked on something similar in the past!

MarqRazz commented 11 months ago

The only dependency you should need to list is in the package.xml <depend>topic_based_ros2_control</depend>.

After you get everything included you should see the hardware interfaces being configured when you bring up your robot and topics should be available on the names you specified in the ros2_control.xacro.

n0sc3tipsum commented 3 months ago

Hi, I have a very similar setup.

I was able to launch the controller manager, and I'm using the joint state broadcaster (joint_broad) and the differential drive controller (diff_cont). I can see the topics that I specified for the state and command interface yet when I try echo them I can't seem to get anything.

PHOTO-2024-06-13-16-39-41

The above pic shows the rqt_graph for my ROS2 system.

The way I understand it is that the diffDriveController will use the interfaces from the topic_based_ros2_control plugin which would relay the joint control commands onto the /joint_ctrl topic that I specified - yet when I use a teleop_twist_keyboard to send in command velocities onto the /manual_cmd_vel topic, I don't see anything on the /joint_ctrl topic, but I can see those command velocities being relayed to the /diff_cont/cmd_vel_unstamped topic.

Im not sure what I'm missing.

Thanks!