Skip to content

Commit

Permalink
Restructuring of the repository for better overview.
Browse files Browse the repository at this point in the history
  • Loading branch information
destogl committed Feb 2, 2023
1 parent f2d8825 commit a8959bb
Show file tree
Hide file tree
Showing 17 changed files with 265 additions and 368 deletions.
191 changes: 68 additions & 123 deletions README.md

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions example_1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
cmake_minimum_required(VERSION 3.5)
project(ros2_control_demo_hardware)

# 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
find_package(ament_cmake REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)


## COMPILE
add_library(
${PROJECT_NAME}
SHARED
hardware/rrbot.cpp
)
target_include_directories(
${PROJECT_NAME}
PRIVATE
include
)
ament_target_dependencies(
${PROJECT_NAME}
hardware_interface
pluginlib
rclcpp
rclcpp_lifecycle
)

# 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_HARDWARE_BUILDING_DLL")

# Export hardware pligins
pluginlib_export_plugin_description_file(hardware_interface ros2_control_demo_hardware.xml)

# INSTALL
install(
TARGETS ${PROJECT_NAME}
DESTINATION lib
)
install(
DIRECTORY include/
DESTINATION include
)

if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
endif()

## EXPORTS
ament_export_include_directories(
include
)
ament_export_libraries(
${PROJECT_NAME}
)
ament_export_dependencies(
hardware_interface
pluginlib
rclcpp
rclcpp_lifecycle
)
ament_package()
98 changes: 98 additions & 0 deletions example_1/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@


TODO(destogl): This is not adjusted yet!!


*RRBot*, or ''Revolute-Revolute Manipulator Robot'', is a simple 3-linkage, 2-joint arm that we will use to demonstrate various features.
It is essentially a double inverted pendulum and demonstrates some fun control concepts within a simulator and was originally introduced for Gazebo tutorials.
The *RRBot* URDF files can be found in the `urdf` folder of `rrbot_description` package.

1. To check that *RRBot* descriptions are working properly use following launch commands:

*RRBot*
```
ros2 launch rrbot_description view_robot.launch.py
```
**NOTE**: 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.
The `joint_state_publisher_gui` provides a GUI to generate a random configuration for rrbot. It is immediately displayed in `Rviz`.


1. To check that *RRBot* descriptions are working properly use following launch commands:

*RRBot*
```
ros2 launch rrbot_description view_robot.launch.py
```
**NOTE**: 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.
The `joint_state_publisher_gui` provides a GUI to generate a random configuration for rrbot. It is immediately displayed in `Rviz`.


1. To start *RRBot* example open a terminal, source your ROS2-workspace and execute its launch file with:
```
ros2 launch ros2_control_demo_bringup rrbot.launch.py
```
The launch file loads and starts the robot hardware, controllers and opens `RViz`.
In starting terminal you will see a lot of output from the hardware implementation showing its internal states.
This is only of exemplary purposes and should be avoided as much as possible in a hardware interface implementation.

If you can see two orange and one yellow rectangle in in `RViz` everything has started properly.
Still, to be sure, let's introspect the control system before moving *RRBot*.

1. Check if the hardware interface loaded properly, by opening another terminal and executing:
```
ros2 control list_hardware_interfaces
```
You should get:
```
command interfaces
joint1/position [claimed]
joint2/position [claimed]
state interfaces
joint1/position
joint2/position
```
Marker `[claimed]` by command interfaces means that a controller has access to command *RRBot*.

1. Check is controllers are running:
```
ros2 control list_controllers
```
You should get:
```
joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active
forward_position_controller[forward_command_controller/ForwardCommandController] active
```

1. If you get output from above you can send commands to *Forward Command Controller*, either:

a. Manually using ros2 cli interface:
```
ros2 topic pub /position_commands std_msgs/msg/Float64MultiArray "data:
- 0.5
- 0.5"
```
B. Or you can start a demo node which sends two goals every 5 seconds in a loop:
```
ros2 launch ros2_control_demo_bringup test_forward_position_controller.launch.py
```
You should now see orange and yellow blocks moving in `RViz`.
Also, you should see changing states in the terminal where launch file is started.


Files used for this demos:
- Launch file: [rrbot.launch.py](ros2_control_demo_bringup/launch/rrbot.launch.py)
- Controllers yaml: [rrbot_controllers.yaml](ros2_control_demo_bringup/config/rrbot_controllers.yaml)
- URDF file: [rrbot.urdf.xacro](ros2_control_demo_description/rrbot_description/urdf/rrbot.urdf.xacro)
- Description: [rrbot_description.urdf.xacro](ros2_control_demo_description/rrbot_description/urdf/rrbot_description.urdf.xacro)
- `ros2_control` tag: [rrbot.ros2_control.xacro](ros2_control_demo_description/rrbot_description/ros2_control/rrbot.ros2_control.xacro)
- RViz configuration: [rrbot.rviz](ros2_control_demo_description/rrbot_description/config/rrbot.rviz)

- Hardware interface plugin: [rrbot_system_position_only.cpp](ros2_control_demo_hardware/src/rrbot_system_position_only.cpp)


Controllers from this demo:
- `Joint State Broadcaster` ([`ros2_controllers` repository](https://github.com/ros-controls/ros2_controllers)): [doc](https://ros-controls.github.io/control.ros.org/ros2_controllers/joint_state_broadcaster/doc/userdoc.html)
- `Forward Command Controller` ([`ros2_controllers` repository](https://github.com/ros-controls/ros2_controllers)): [doc](https://ros-controls.github.io/control.ros.org/ros2_controllers/forward_command_controller/doc/userdoc.html)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "ros2_control_demo_hardware/rrbot_system_position_only.hpp"
#include "ros2_control_demos_example_1/hardware/rrbot.hpp"

#include <chrono>
#include <cmath>
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions example_1/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ros2_control_demo_hardware</name>
<version>0.0.0</version>
<description>Demo package of `ros2_control` Hardware. This package provides example on how to define hardware of your own robot for ROS2 control. The package is used with `ros2_control_demo_bringup` from package `rrbot_description` and `diffbot_description`.</description>

<maintainer email="denis@stogl.de">Denis Štogl</maintainer>

<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>hardware_interface</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>

<test_depend>ament_cmake_gtest</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
21 changes: 0 additions & 21 deletions ros2_control_test_nodes/package.xml

This file was deleted.

Empty file.
13 changes: 0 additions & 13 deletions ros2_control_test_nodes/ros2_control_test_nodes/__init__.py

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions ros2_control_test_nodes/setup.cfg

This file was deleted.

Loading

0 comments on commit a8959bb

Please sign in to comment.