-
Notifications
You must be signed in to change notification settings - Fork 262
Restructuring for example_2 #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
destogl
merged 20 commits into
ros-controls:new-structure-of-master
from
christophfroehlich:example_2
Feb 20, 2023
Merged
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
08fab3b
Initial restructuring for example_2
christophfroehlich 23362fa
Update readme markup and paths
christophfroehlich fbf35e1
Fix hardware_interface
christophfroehlich 80986ef
Fix trailing whitespace
christophfroehlich 7bcae46
Move header to include folders
christophfroehlich d8f9038
Update readme
christophfroehlich eef85c8
Fix wrong paths
christophfroehlich 5a81b83
Fix rst
christophfroehlich c2e96f0
Update copyright
christophfroehlich ddfacda
Update maintainer
christophfroehlich e451995
Cleanup remaining repo
christophfroehlich 05974a8
Update readme
christophfroehlich 2d55ccf
Add maintainer
christophfroehlich 180e537
Restructure cmakelists
christophfroehlich 8bc0bc2
Update example_2/package.xml
destogl 6f57d6d
Update maintainer
christophfroehlich 0801cf6
Fix trailing whitespace
christophfroehlich e1653df
Fix rviz display
christophfroehlich 6ecca96
Add image to readme
christophfroehlich ca71daa
Merge remote-tracking branch 'origin/new-structure-of-master' into ex…
christophfroehlich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| cmake_minimum_required(VERSION 3.5) | ||
| project(ros2_control_demo_example_2) | ||
destogl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Default to C++14 | ||
| if(NOT CMAKE_CXX_STANDARD) | ||
| set(CMAKE_CXX_STANDARD 14) | ||
| endif() | ||
|
|
||
| if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| add_compile_options(-Wall -Wextra) | ||
| endif() | ||
|
|
||
| # find dependencies | ||
| set(THIS_PACKAGE_INCLUDE_DEPENDS | ||
| hardware_interface | ||
| pluginlib | ||
| rclcpp | ||
| rclcpp_lifecycle | ||
| ) | ||
|
|
||
| # find dependencies | ||
| find_package(ament_cmake REQUIRED) | ||
| foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS}) | ||
| find_package(${Dependency} REQUIRED) | ||
| endforeach() | ||
|
|
||
|
|
||
| ## COMPILE | ||
| add_library( | ||
| ${PROJECT_NAME} | ||
| SHARED | ||
| hardware/diffbot_system.cpp | ||
| ) | ||
| target_include_directories( | ||
| ${PROJECT_NAME} | ||
| PRIVATE | ||
| hardware/include | ||
| ) | ||
| ament_target_dependencies( | ||
| ${PROJECT_NAME} | ||
| ${THIS_PACKAGE_INCLUDE_DEPENDS} | ||
| ) | ||
|
|
||
| # Causes the visibility macros to use dllexport rather than dllimport, | ||
| # which is appropriate when building the dll but not consuming it. | ||
| target_compile_definitions(${PROJECT_NAME} PRIVATE "ROS2_CONTROL_DEMO_EXAMPLE_2_BUILDING_DLL") | ||
|
|
||
| # Export hardware plugins | ||
| pluginlib_export_plugin_description_file(hardware_interface ros2_control_demo_example_2.xml) | ||
|
|
||
| # INSTALL | ||
| install( | ||
| TARGETS ${PROJECT_NAME} | ||
| DESTINATION lib | ||
| ) | ||
| install( | ||
| DIRECTORY hardware/include/ | ||
| DESTINATION include | ||
| ) | ||
| install( | ||
| DIRECTORY description/launch description/ros2_control description/urdf description/rviz | ||
| DESTINATION share/${PROJECT_NAME} | ||
| ) | ||
| install( | ||
| DIRECTORY bringup/launch bringup/config | ||
| DESTINATION share/${PROJECT_NAME} | ||
| ) | ||
|
|
||
| if(BUILD_TESTING) | ||
| find_package(ament_cmake_gtest REQUIRED) | ||
| endif() | ||
|
|
||
| ## EXPORTS | ||
| ament_export_include_directories( | ||
| include | ||
| ) | ||
| ament_export_libraries( | ||
| ${PROJECT_NAME} | ||
| ) | ||
| ament_export_dependencies( | ||
| ${THIS_PACKAGE_INCLUDE_DEPENDS} | ||
| ) | ||
| ament_package() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| ********* | ||
| DiffBot | ||
| ********* | ||
|
|
||
| *DiffBot*, or ''Differential Mobile Robot'', is a simple mobile base with differential drive. | ||
| The robot is basically a box moving according to differential drive kinematics. | ||
| The *DiffBot* URDF files can be found in ``description/urdf`` folder. | ||
|
|
||
| 1. To check that *DiffBot* description is working properly use following launch commands | ||
|
|
||
| .. code-block:: shell | ||
|
|
||
| ros2 launch ros2_control_demo_example_2 view_robot.launch.py | ||
christophfroehlich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .. warning:: | ||
| Getting the following output in terminal is OK: ``Warning: Invalid frame ID "odom" passed to canTransform argument target_frame - frame does not exist``. | ||
| This happens because ``joint_state_publisher_gui`` node need some time to start. | ||
|
|
||
| 2. To start *DiffBot* example open a terminal, source your ROS2-workspace and execute its launch file with | ||
|
|
||
| .. code-block:: shell | ||
|
|
||
| ros2 launch ros2_control_demo_example_2 diffbot.launch.py | ||
|
|
||
| The launch file loads and starts the robot hardware, controllers and opens *RViz*. | ||
| In the starting terminal you will see a lot of output from the hardware implementation showing its internal states. | ||
| This excessive printing is only added for demonstration. In general, printing to the terminal should be avoided as much as possible in a hardware interface implementation. | ||
|
|
||
| If you can see an orange box in *RViz* everything has started properly. | ||
| Still, to be sure, let's introspect the control system before moving *DiffBot*. | ||
|
|
||
| 3. Check if the hardware interface loaded properly, by opening another terminal and executing | ||
|
|
||
| .. code-block:: shell | ||
|
|
||
| ros2 control list_hardware_interfaces | ||
|
|
||
| You should get | ||
|
|
||
| .. code-block:: shell | ||
|
|
||
| command interfaces | ||
| left_wheel_joint/velocity [claimed] | ||
| right_wheel_joint/velocity [claimed] | ||
| state interfaces | ||
| left_wheel_joint/position | ||
| left_wheel_joint/velocity | ||
| right_wheel_joint/position | ||
| right_wheel_joint/velocity | ||
|
|
||
| The ``[claimed]`` marker on command interfaces means that a controller has access to command *DiffBot*. | ||
|
|
||
| 4. Check if controllers are running | ||
|
|
||
| .. code-block:: shell | ||
|
|
||
| ros2 control list_controllers | ||
|
|
||
| You should get | ||
|
|
||
| .. code-block:: shell | ||
|
|
||
| diffbot_base_controller[diff_drive_controller/DiffDriveController] active | ||
| joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active | ||
|
|
||
| 5. If everything is fine, now you can send a command to *Diff Drive Controller* using ros2 cli interface: | ||
|
|
||
| .. code-block:: shell | ||
|
|
||
| ros2 topic pub --rate 30 /diffbot_base_controller/cmd_vel_unstamped geometry_msgs/msg/Twist "linear: | ||
| x: 0.7 | ||
| y: 0.0 | ||
| z: 0.0 | ||
| angular: | ||
| x: 0.0 | ||
| y: 0.0 | ||
| z: 1.0" | ||
|
|
||
| You should now see an orange box circling in *RViz*. | ||
| Also, you should see changing states in the terminal where launch file is started. | ||
|
|
||
| .. code-block:: shell | ||
|
|
||
| [DiffBotSystemHardware]: Got command 43.33333 for 'left_wheel_joint'! | ||
| [DiffBotSystemHardware]: Got command 50.00000 for 'right_wheel_joint'! | ||
|
|
||
| Files used for this demos | ||
| ######################### | ||
|
|
||
| - Launch file: `diffbot.launch.py <bringup/launch/diffbot.launch.py>`__ | ||
christophfroehlich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - Controllers yaml: `diffbot_controllers.yaml <bringup/config/diffbot_controllers.yaml>`__ | ||
| - URDF file: `diffbot.urdf.xacro <description/urdf/diffbot.urdf.xacro>`__ | ||
|
|
||
| + Description: `diffbot_description.urdf.xacro <description/urdf/diffbot_description.urdf.xacro>`__ | ||
| + ``ros2_control`` tag: `diffbot.ros2_control.xacro <description/ros2_control/diffbot.ros2_control.xacro>`__ | ||
|
|
||
| - RViz configuration: `diffbot.rviz <description/rviz/diffbot.rviz>`__ | ||
|
|
||
| - Hardware interface plugin: `diffbot_system.cpp <hardware/diffbot_system.cpp>`__ | ||
|
|
||
|
|
||
| Controllers from this demo | ||
| ########################## | ||
|
|
||
| - ``Joint State Broadcaster`` (`*ros2_controllers* repository <https://github.com/ros-controls/ros2_controllers>`__): `doc <https://control.ros.org/master/doc/ros2_controllers/joint_state_broadcaster/doc/userdoc.html>`__ | ||
| - ``Diff Drive Controller`` (`*ros2_controllers* repository <https://github.com/ros-controls/ros2_controllers>`__): `doc <https://control.ros.org/master/doc/ros2_controllers/diff_drive_controller/doc/userdoc.html>`__ | ||
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.