From 3bac26710b1c524cd6a0453a5d0d1fafbd1b4894 Mon Sep 17 00:00:00 2001 From: the-snowwhite Date: Tue, 10 Jan 2023 10:07:57 +0100 Subject: [PATCH 1/6] Fix: new python module paths Signed-off-by: the-snowwhite --- hal_hw_interface/hal_hw_interface/hal_mgr.py | 4 ++-- hal_hw_interface/hal_hw_interface/hal_pin_attrs.py | 2 +- .../hal_hw_interface/launch/hal_ordered_action.py | 2 +- hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py | 3 ++- hal_hw_interface/hal_hw_interface/launch/hal_user_node.py | 2 +- hal_hw_interface/hal_hw_interface/loadrt_local.py | 4 ++-- hal_hw_interface/hal_hw_interface/ros_hal_component.py | 2 +- hal_hw_interface/hal_hw_interface/tests/test_hal_pin_attrs.py | 2 +- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hal_hw_interface/hal_hw_interface/hal_mgr.py b/hal_hw_interface/hal_hw_interface/hal_mgr.py index cd36c8e..fe84895 100644 --- a/hal_hw_interface/hal_hw_interface/hal_mgr.py +++ b/hal_hw_interface/hal_hw_interface/hal_mgr.py @@ -1,6 +1,6 @@ import os import subprocess -from machinekit import config +#from machinekit import config from .ros_hal_component import RosHalComponent # ROS @@ -52,7 +52,7 @@ def start_realtime(self): env = dict( DEBUG=d_lev, SYSLOG_TO_STDERR=d_out, - MACHINEKIT_INI=config.Config().MACHINEKIT_INI, + MACHINEKIT_INI="/etc/machinekit/hal/machinekit.ini", FASTRTPS_DEFAULT_PROFILES_FILE=fastrtps_profiles, **os.environ, ) diff --git a/hal_hw_interface/hal_hw_interface/hal_pin_attrs.py b/hal_hw_interface/hal_hw_interface/hal_pin_attrs.py index b9ab3dd..3a2693c 100644 --- a/hal_hw_interface/hal_hw_interface/hal_pin_attrs.py +++ b/hal_hw_interface/hal_hw_interface/hal_pin_attrs.py @@ -1,4 +1,4 @@ -import hal +import machinekit.hal.pyhal as hal class HalPinAttrBase(int): diff --git a/hal_hw_interface/hal_hw_interface/launch/hal_ordered_action.py b/hal_hw_interface/hal_hw_interface/launch/hal_ordered_action.py index b0b1011..f5053f2 100644 --- a/hal_hw_interface/hal_hw_interface/launch/hal_ordered_action.py +++ b/hal_hw_interface/hal_hw_interface/launch/hal_ordered_action.py @@ -14,7 +14,7 @@ from launch_ros.actions import Node -from machinekit import rtapi +from machinekit.hal.cyruntime import rtapi from .hal_ready import HalReady diff --git a/hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py b/hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py index da64435..a7b9a95 100644 --- a/hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py +++ b/hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py @@ -6,7 +6,8 @@ from launch.substitutions import PathJoinSubstitution from launch_ros.substitutions import FindPackagePrefix -from machinekit import rtapi, hal +from machinekit.hal.cyruntime import rtapi +import machinekit.hal.pyhal as hal from .hal_ordered_action import HalOrderedNode, HalThreadedReadyAction diff --git a/hal_hw_interface/hal_hw_interface/launch/hal_user_node.py b/hal_hw_interface/hal_hw_interface/launch/hal_user_node.py index 8a37b3c..2872a8c 100644 --- a/hal_hw_interface/hal_hw_interface/launch/hal_user_node.py +++ b/hal_hw_interface/hal_hw_interface/launch/hal_user_node.py @@ -1,5 +1,5 @@ import os -from machinekit import hal +import machinekit.hal.pyhal as hal from launch import logging from .hal_ordered_action import HalOrderedNode, HalAsyncReadyAction diff --git a/hal_hw_interface/hal_hw_interface/loadrt_local.py b/hal_hw_interface/hal_hw_interface/loadrt_local.py index c54b802..cf0fd63 100644 --- a/hal_hw_interface/hal_hw_interface/loadrt_local.py +++ b/hal_hw_interface/hal_hw_interface/loadrt_local.py @@ -1,7 +1,7 @@ import rclpy import os -from machinekit import rtapi, hal - +from machinekit.hal.cyruntime import rtapi +import machinekit.hal.pyhal as hal def loadrt_local(modname): """ diff --git a/hal_hw_interface/hal_hw_interface/ros_hal_component.py b/hal_hw_interface/hal_hw_interface/ros_hal_component.py index 1beb789..6de739c 100644 --- a/hal_hw_interface/hal_hw_interface/ros_hal_component.py +++ b/hal_hw_interface/hal_hw_interface/ros_hal_component.py @@ -5,7 +5,7 @@ """ import abc -import hal +import machinekit.hal.pyhal as hal import rclpy from .hal_obj_base import HalObjBase from .exception import HalHWInterfaceException diff --git a/hal_hw_interface/hal_hw_interface/tests/test_hal_pin_attrs.py b/hal_hw_interface/hal_hw_interface/tests/test_hal_pin_attrs.py index 5e82b3c..48585a8 100644 --- a/hal_hw_interface/hal_hw_interface/tests/test_hal_pin_attrs.py +++ b/hal_hw_interface/hal_hw_interface/tests/test_hal_pin_attrs.py @@ -1,5 +1,5 @@ import pytest -import hal +import machinekit.hal.pyhal as hal from hal_hw_interface.hal_pin_attrs import HalPinDir, HalPinType From aa38669c8272099f14c741a826bb1bb90e43ba6b Mon Sep 17 00:00:00 2001 From: the-snowwhite Date: Tue, 10 Jan 2023 10:26:53 +0100 Subject: [PATCH 2/6] fix hal include path Signed-off-by: the-snowwhite --- hal_hw_interface/cmake/FindHAL.cmake | 4 ++-- hal_hw_interface/include/hal_hw_interface/hal_ros_logging.hpp | 2 +- .../include/hal_hw_interface/hal_system_interface.hpp | 2 +- hal_hw_interface/src/hal_control_node.cpp | 2 +- hal_hw_interface/src/hal_system_interface.cpp | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hal_hw_interface/cmake/FindHAL.cmake b/hal_hw_interface/cmake/FindHAL.cmake index 19abcce..05f572c 100644 --- a/hal_hw_interface/cmake/FindHAL.cmake +++ b/hal_hw_interface/cmake/FindHAL.cmake @@ -24,8 +24,8 @@ set(MACHINEKIT_RIP_PATH # HAL_INCLUDE_PATH: Find HAL include directory find_path( - HAL_INCLUDE_PATH hal.h - PATH_SUFFIXES machinekit + HAL_INCLUDE_PATH hal/hal.h + PATH_SUFFIXES machinekit/hal PATHS ${MACHINEKIT_RIP_PATH}/include ) diff --git a/hal_hw_interface/include/hal_hw_interface/hal_ros_logging.hpp b/hal_hw_interface/include/hal_hw_interface/hal_ros_logging.hpp index f9270de..7127a1d 100644 --- a/hal_hw_interface/include/hal_hw_interface/hal_ros_logging.hpp +++ b/hal_hw_interface/include/hal_hw_interface/hal_ros_logging.hpp @@ -33,7 +33,7 @@ #define HAL_HW_INTERFACE__HAL_ROS_LOGGING_HPP_ // HAL -#include +#include // ROS #include diff --git a/hal_hw_interface/include/hal_hw_interface/hal_system_interface.hpp b/hal_hw_interface/include/hal_hw_interface/hal_system_interface.hpp index a3b2bb0..fba5b77 100644 --- a/hal_hw_interface/include/hal_hw_interface/hal_system_interface.hpp +++ b/hal_hw_interface/include/hal_hw_interface/hal_system_interface.hpp @@ -37,7 +37,7 @@ #endif // HAL -#include +#include #include #include diff --git a/hal_hw_interface/src/hal_control_node.cpp b/hal_hw_interface/src/hal_control_node.cpp index 9199a53..fc19716 100644 --- a/hal_hw_interface/src/hal_control_node.cpp +++ b/hal_hw_interface/src/hal_control_node.cpp @@ -32,7 +32,7 @@ #include #include // pthread_setname_np() #include // sleep() -#include // HAL public API decls +#include // HAL public API decls #include #include #include diff --git a/hal_hw_interface/src/hal_system_interface.cpp b/hal_hw_interface/src/hal_system_interface.cpp index 66fd44c..d8cd40e 100644 --- a/hal_hw_interface/src/hal_system_interface.cpp +++ b/hal_hw_interface/src/hal_system_interface.cpp @@ -32,8 +32,8 @@ // Disable warnings that need to be fixed in external headers #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wignored-qualifiers" -#include // HAL public API decls -#include // halpr_find_comp_by_name +#include // HAL public API decls +#include // halpr_find_comp_by_name #pragma GCC diagnostic pop #include From 576fbdbe8eeb057f08bf02db58c5524fe150e5d0 Mon Sep 17 00:00:00 2001 From: the-snowwhite Date: Tue, 10 Jan 2023 10:48:17 +0100 Subject: [PATCH 3/6] update readme Signed-off-by: the-snowwhite --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60b86d9..7d835d3 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,12 @@ start netting pins before the HAL components are loaded and ready. - A real-time kernel, either RT_PREEMPT or Xenomai - Required by Machinekit for low-latency control - See the `linux-image-rt-*` packages available in Debian Stretch. -- [`ros_control_boilerplate`][ros_control_boilerplate] +- [`ros2_control`][ros2_control] - Required by the `hal_hw_interface` - This may be installed in package form - Optional: The `ros2_control_demos` repo - Required to run the `hal_rrbot_control` demo + - This may also be installed in package form - Follow the notes in that project's README to install ----- From 28827d57abac09da3843d5e415a7cdcc9ec3f916 Mon Sep 17 00:00:00 2001 From: the-snowwhite Date: Tue, 10 Jan 2023 12:16:34 +0100 Subject: [PATCH 4/6] Differentiate between pyhal and cyhal Signed-off-by: the-snowwhite --- hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py | 2 +- hal_hw_interface/hal_hw_interface/launch/hal_user_node.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py b/hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py index a7b9a95..dbe62bb 100644 --- a/hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py +++ b/hal_hw_interface/hal_hw_interface/launch/hal_rt_node.py @@ -7,7 +7,7 @@ from launch_ros.substitutions import FindPackagePrefix from machinekit.hal.cyruntime import rtapi -import machinekit.hal.pyhal as hal +import machinekit.hal.cyhal as hal from .hal_ordered_action import HalOrderedNode, HalThreadedReadyAction diff --git a/hal_hw_interface/hal_hw_interface/launch/hal_user_node.py b/hal_hw_interface/hal_hw_interface/launch/hal_user_node.py index 2872a8c..dd39f4b 100644 --- a/hal_hw_interface/hal_hw_interface/launch/hal_user_node.py +++ b/hal_hw_interface/hal_hw_interface/launch/hal_user_node.py @@ -1,5 +1,5 @@ import os -import machinekit.hal.pyhal as hal +import machinekit.hal.cyhal as hal from launch import logging from .hal_ordered_action import HalOrderedNode, HalAsyncReadyAction From 3cba46ad3e8feff035b3330a75f625281fff9585 Mon Sep 17 00:00:00 2001 From: the-snowwhite Date: Wed, 11 Jan 2023 02:40:33 +0100 Subject: [PATCH 5/6] Add ros control demos link Signed-off-by: the-snowwhite --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7d835d3..2d38017 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ output pins with `std_msgs` publishers and subscribers, respectively. [machinekit]: http://machinekit.io [ros2_control]: https://github.com/ros-controls/ros2_control - +[ros2_control_demos]:https://github.com/ros-controls/ros2_control_demos ## The `hal_hw_interface` real-time component The `hal_control_node` HAL component runs a @@ -67,7 +67,7 @@ start netting pins before the HAL components are loaded and ready. - [`ros2_control`][ros2_control] - Required by the `hal_hw_interface` - This may be installed in package form -- Optional: The `ros2_control_demos` repo +- Optional: The [`ros2_control_demos`][ros2_control_demos] repo - Required to run the `hal_rrbot_control` demo - This may also be installed in package form - Follow the notes in that project's README to install From 531660915aefd8facab1c3f61bd47b8a21a4feae Mon Sep 17 00:00:00 2001 From: the-snowwhite Date: Wed, 11 Jan 2023 12:54:12 +0100 Subject: [PATCH 6/6] Fix typo in readme Signed-off-by: the-snowwhite --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2d38017..456d4a5 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Run the simulated hardware interface: ros2 launch hal_rrbot_control rrbot.launch.py # Debugging: append `hal_debug_output:=1 hal_debug_level:=5` # Trajectory controller: append - # `robot_controller:=position_trajectory_controller` + # `robot_controller:=joint_trajectory_position_controller` Run `halscope` to visualize HAL joint commands and feedback; in the GUI, set the "Run Mode" to "Roll" for continuous updating: @@ -96,8 +96,8 @@ The simulated trajectories are launched directly from the `ros2_control_demo_bringup` package: ros2 launch ros2_control_demo_bringup test_forward_position_controller.launch.py - # Or for robot_controller:=position_trajectory_controller: - ros2 launch ros2_control_demo_bringup test_joint_trajectory_controller.launch.py + # Or for robot_controller:=joint_trajectory_position_controller: + ros2 launch ros2_control_demo_bringup test_joint_trajectory_position_controller.launch.py Load and switch to the trajectory controller at run time: @@ -105,19 +105,19 @@ Load and switch to the trajectory controller at run time: ros2 service call \ /controller_manager/load_and_configure_controller \ controller_manager_msgs/srv/LoadConfigureController \ - '{name: "position_trajectory_controller"}' + '{name: "joint_trajectory_position_controller"}' # Switch to the trajectory controller ros2 service call \ /controller_manager/switch_controller \ controller_manager_msgs/srv/SwitchController \ - '{start_controllers: ["position_trajectory_controller"], + '{start_controllers: ["joint_trajectory_position_controller"], stop_controllers: ["forward_position_controller"], strictness: 1, start_asap: true, timeout: {sec: 0, nanosec: 10000000} }' - # Verify the switch: 'position_trajectory_controller' state='active' + # Verify the switch: 'joint_trajectory_position_controller' state='active' ros2 service call \ /controller_manager/list_controllers \ controller_manager_msgs/srv/ListControllers