ros-controls / ros2_control_demos

This repository aims at providing examples to illustrate ros2_control and ros2_controllers
https://control.ros.org
Apache License 2.0
412 stars 187 forks source link

ros2_control with ethercat_driver_ros2 errors when running ros2_control demo with ethercat driver plugin #251

Closed NamanMo97 closed 1 year ago

NamanMo97 commented 1 year ago

I am trying to find a way to have a connection between ros2_control and ethercat_driver. the master is Activated but still get the error even when defining the ec_module as a plugin, the module is uploaded but still got the same error I defined the ethercat driver as a plugin in a new description file which is system_description.ros2_control.xacro and called it from the main rrbot_system_multi_interface.urdf.xacro description file, what I am trying to do is to make a description file with ethercat driver and ethercat module plugins in order to be launched from the rrbot_system_multi_interface.launch.py in the demos package, is there any specified informations about how to use ros2_control with ethercat_driver? here are the error I get and the decription files and the launch file that I am using:

Errors:

neuermann@NeuerMann:~/neuer_ws$ ros2 launch ros2_control_demo_bringup rrbot_system_multi_interface.launch.py 
[INFO] [launch]: All log files can be found below /home/neuermann/.ros/log/2023-03-08-12-51-51-385572-NeuerMann-59622
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ros2_control_node-1]: process started with pid [59625]
[INFO] [robot_state_publisher-2]: process started with pid [59627]
[INFO] [spawner-3]: process started with pid [59629]
[robot_state_publisher-2] [INFO] [1678276311.750691953] [kdl_parser]: Link base_link had 1 children.
[robot_state_publisher-2] [INFO] [1678276311.750750874] [kdl_parser]: Link link1 had 1 children.
[robot_state_publisher-2] [INFO] [1678276311.750764032] [kdl_parser]: Link link2 had 3 children.
[robot_state_publisher-2] [INFO] [1678276311.750773490] [kdl_parser]: Link camera_link had 1 children.
[robot_state_publisher-2] [INFO] [1678276311.750781411] [kdl_parser]: Link camera_link_optical had 0 children.
[robot_state_publisher-2] [INFO] [1678276311.750788491] [kdl_parser]: Link hokuyo_link had 0 children.
[robot_state_publisher-2] [INFO] [1678276311.750792754] [kdl_parser]: Link tool_link had 0 children.
[robot_state_publisher-2] [INFO] [1678276311.750803883] [robot_state_publisher]: got segment base_link
[robot_state_publisher-2] [INFO] [1678276311.750863830] [robot_state_publisher]: got segment camera_link
[robot_state_publisher-2] [INFO] [1678276311.750878151] [robot_state_publisher]: got segment camera_link_optical
[robot_state_publisher-2] [INFO] [1678276311.750891010] [robot_state_publisher]: got segment hokuyo_link
[robot_state_publisher-2] [INFO] [1678276311.750901565] [robot_state_publisher]: got segment link1
[robot_state_publisher-2] [INFO] [1678276311.750911720] [robot_state_publisher]: got segment link2
[robot_state_publisher-2] [INFO] [1678276311.750921985] [robot_state_publisher]: got segment tool_link
[robot_state_publisher-2] [INFO] [1678276311.750932184] [robot_state_publisher]: got segment world
[ros2_control_node-1] [INFO] [1678276311.770708495] [resource_manager]: Loading hardware 'mySystem' 
[ros2_control_node-1] [INFO] [1678276311.773001396] [resource_manager]: Initialize hardware 'mySystem' 
[ros2_control_node-1] [INFO] [1678276311.773114993] [EthercatDriver]: Got 0 modules
[ros2_control_node-1] [INFO] [1678276311.773125696] [resource_manager]: Successful initialization of hardware 'mySystem'
[ros2_control_node-1] [INFO] [1678276311.773195915] [resource_manager]: Loading hardware 'RRBotSystemMultiInterface' 
[ros2_control_node-1] [INFO] [1678276311.774376919] [resource_manager]: Initialize hardware 'RRBotSystemMultiInterface' 
[ros2_control_node-1] [INFO] [1678276311.774678245] [resource_manager]: Successful initialization of hardware 'RRBotSystemMultiInterface'
[ros2_control_node-1] [INFO] [1678276311.775018473] [resource_manager]: 'configure' hardware 'mySystem' 
[ros2_control_node-1] [INFO] [1678276311.775045117] [resource_manager]: Successful 'configure' of hardware 'mySystem'
[ros2_control_node-1] [INFO] [1678276311.775051937] [resource_manager]: 'activate' hardware 'mySystem' 
[ros2_control_node-1] [INFO] [1678276311.775058338] [EthercatDriver]: Starting ...please wait...
[ros2_control_node-1] [INFO] [1678276311.775375730] [EthercatDriver]: Activated EcMaster!
[ros2_control_node-1] Stack trace (most recent call last):
[ros2_control_node-1] #31   Object "", at 0xffffffffffffffff, in 
[ros2_control_node-1] #30   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fbd864, in _start
[ros2_control_node-1] #29   Source "../csu/libc-start.c", line 392, in __libc_start_main_impl [0x7fa400c29e3f]
[ros2_control_node-1] #28   Source "../sysdeps/nptl/libc_start_call_main.h", line 58, in __libc_start_call_main [0x7fa400c29d8f]
[ros2_control_node-1] #27   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fbe23c, in main
[ros2_control_node-1] #26   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fc0068, in std::shared_ptr<controller_manager::ControllerManager> std::make_shared<controller_manager::ControllerManager, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
[ros2_control_node-1] #25   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fc0cba, in std::shared_ptr<controller_manager::ControllerManager> std::allocate_shared<controller_manager::ControllerManager, std::allocator<controller_manager::ControllerManager>, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(std::allocator<controller_manager::ControllerManager> const&, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
[ros2_control_node-1] #24   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fc15a0, in std::shared_ptr<controller_manager::ControllerManager>::shared_ptr<std::allocator<controller_manager::ControllerManager>, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(std::_Sp_alloc_shared_tag<std::allocator<controller_manager::ControllerManager> >, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
[ros2_control_node-1] #23   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fc1a65, in std::__shared_ptr<controller_manager::ControllerManager, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<controller_manager::ControllerManager>, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(std::_Sp_alloc_shared_tag<std::allocator<controller_manager::ControllerManager> >, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
[ros2_control_node-1] #22   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fc1d50, in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<controller_manager::ControllerManager, std::allocator<controller_manager::ControllerManager>, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(controller_manager::ControllerManager*&, std::_Sp_alloc_shared_tag<std::allocator<controller_manager::ControllerManager> >, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
[ros2_control_node-1] #21   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fc23d2, in std::_Sp_counted_ptr_inplace<controller_manager::ControllerManager, std::allocator<controller_manager::ControllerManager>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(std::allocator<controller_manager::ControllerManager>, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
[ros2_control_node-1] #20   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fc2839, in void std::allocator_traits<std::allocator<controller_manager::ControllerManager> >::construct<controller_manager::ControllerManager, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(std::allocator<controller_manager::ControllerManager>&, controller_manager::ControllerManager*, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
[ros2_control_node-1] #19   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node", at 0x55f336fc2ce5, in void __gnu_cxx::new_allocator<controller_manager::ControllerManager>::construct<controller_manager::ControllerManager, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(controller_manager::ControllerManager*, std::shared_ptr<rclcpp::Executor>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
[ros2_control_node-1] #18   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/libcontroller_manager.so", at 0x7fa401a7aba1, in controller_manager::ControllerManager::ControllerManager(std::shared_ptr<rclcpp::Executor>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rclcpp::NodeOptions const&)
[ros2_control_node-1] #17   Object "/home/neuermann/neuer_ws/install/controller_manager/lib/libcontroller_manager.so", at 0x7fa401a7bed4, in controller_manager::ControllerManager::init_resource_manager(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
[ros2_control_node-1] #16   Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b74dff, in hardware_interface::ResourceManager::activate_all_components()
[ros2_control_node-1] #15   Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b730d8, in hardware_interface::ResourceManager::set_component_state(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rclcpp_lifecycle::State&)
[ros2_control_node-1] #14   Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b7281e, in auto hardware_interface::ResourceManager::set_component_state(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rclcpp_lifecycle::State&)::{lambda(auto:1, auto:2&)#1}::operator()<std::_Bind<bool (hardware_interface::ResourceStorage::*(hardware_interface::ResourceStorage*, std::_Placeholder<1>, std::_Placeholder<2>))(hardware_interface::System&, rclcpp_lifecycle::State const&)>, std::vector<hardware_interface::System, std::allocator<hardware_interface::System> > >(std::_Bind<bool (hardware_interface::ResourceStorage::*(hardware_interface::ResourceStorage*, std::_Placeholder<1>, std::_Placeholder<2>))(hardware_interface::System&, rclcpp_lifecycle::State const&)>, std::vector<hardware_interface::System, std::allocator<hardware_interface::System> >&) const
[ros2_control_node-1] #13   Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b8137a, in bool std::_Bind<bool (hardware_interface::ResourceStorage::*(hardware_interface::ResourceStorage*, std::_Placeholder<1>, std::_Placeholder<2>))(hardware_interface::System&, rclcpp_lifecycle::State const&)>::operator()<hardware_interface::System&, rclcpp_lifecycle::State&, bool>(hardware_interface::System&, rclcpp_lifecycle::State&)
[ros2_control_node-1] #12   Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b8ce2a, in bool std::_Bind<bool (hardware_interface::ResourceStorage::*(hardware_interface::ResourceStorage*, std::_Placeholder<1>, std::_Placeholder<2>))(hardware_interface::System&, rclcpp_lifecycle::State const&)>::__call<bool, hardware_interface::System&, rclcpp_lifecycle::State&, 0ul, 1ul, 2ul>(std::tuple<hardware_interface::System&, rclcpp_lifecycle::State&>&&, std::_Index_tuple<0ul, 1ul, 2ul>)
[ros2_control_node-1] #11   Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b96864, in std::__invoke_result<bool (hardware_interface::ResourceStorage::*&)(hardware_interface::System&, rclcpp_lifecycle::State const&), hardware_interface::ResourceStorage*&, hardware_interface::System&, rclcpp_lifecycle::State&>::type std::__invoke<bool (hardware_interface::ResourceStorage::*&)(hardware_interface::System&, rclcpp_lifecycle::State const&), hardware_interface::ResourceStorage*&, hardware_interface::System&, rclcpp_lifecycle::State&>(bool (hardware_interface::ResourceStorage::*&)(hardware_interface::System&, rclcpp_lifecycle::State const&), hardware_interface::ResourceStorage*&, hardware_interface::System&, rclcpp_lifecycle::State&)
[ros2_control_node-1] #10   Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b9ecfb, in bool std::__invoke_impl<bool, bool (hardware_interface::ResourceStorage::*&)(hardware_interface::System&, rclcpp_lifecycle::State const&), hardware_interface::ResourceStorage*&, hardware_interface::System&, rclcpp_lifecycle::State&>(std::__invoke_memfun_deref, bool (hardware_interface::ResourceStorage::*&)(hardware_interface::System&, rclcpp_lifecycle::State const&), hardware_interface::ResourceStorage*&, hardware_interface::System&, rclcpp_lifecycle::State&)
[ros2_control_node-1] #9    Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b80fa1, in bool hardware_interface::ResourceStorage::set_component_state<hardware_interface::System>(hardware_interface::System&, rclcpp_lifecycle::State const&)
[ros2_control_node-1] #8    Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b8ca6c, in bool hardware_interface::ResourceStorage::activate_hardware<hardware_interface::System>(hardware_interface::System&)
[ros2_control_node-1] #7    Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b8b83a, in auto hardware_interface::trigger_and_print_hardware_state_transition::{lambda(auto:1, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<char> const&, unsigned char const&)#1}::operator()<std::_Bind<rclcpp_lifecycle::State const& (hardware_interface::System::*(std::_Bind*))()> >(hardware_interface::trigger_and_print_hardware_state_transition, std::allocator<char>, std::allocator<char> const, unsigned char const) const
[ros2_control_node-1] #6    Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b9670e, in rclcpp_lifecycle::State const& std::_Bind<rclcpp_lifecycle::State const& (hardware_interface::System::*(hardware_interface::System*))()>::operator()<, rclcpp_lifecycle::State const&>()
[ros2_control_node-1] #5    Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400b9eb96, in rclcpp_lifecycle::State const& std::_Bind<rclcpp_lifecycle::State const& (hardware_interface::System::*(hardware_interface::System*))()>::__call<rclcpp_lifecycle::State const&, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>)
[ros2_control_node-1] #4    Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400ba7ccc, in std::__invoke_result<rclcpp_lifecycle::State const& (hardware_interface::System::*&)(), hardware_interface::System*&>::type std::__invoke<rclcpp_lifecycle::State const& (hardware_interface::System::*&)(), hardware_interface::System*&>(rclcpp_lifecycle::State const& (hardware_interface::System::*&)(), hardware_interface::System*&)
[ros2_control_node-1] #3    Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400bab6a1, in rclcpp_lifecycle::State const& std::__invoke_impl<rclcpp_lifecycle::State const&, rclcpp_lifecycle::State const& (hardware_interface::System::*&)(), hardware_interface::System*&>(std::__invoke_memfun_deref, rclcpp_lifecycle::State const& (hardware_interface::System::*&)(), hardware_interface::System*&)
[ros2_control_node-1] #2    Object "/home/neuermann/neuer_ws/install/hardware_interface/lib/libhardware_interface.so", at 0x7fa400bb6579, in hardware_interface::System::activate()
[ros2_control_node-1] #1    Object "/home/neuermann/neuer_ws/install/ethercat_driver/lib/libethercat_driver.so", at 0x7fa3f8db3a75, in ethercat_driver::EthercatDriver::on_activate(rclcpp_lifecycle::State const&)
[ros2_control_node-1] #0    Object "/home/neuermann/neuer_ws/install/ethercat_interface/lib/libethercat_interface.so", at 0x7fa3f8cbae04, in ethercat_interface::EcMaster::update(unsigned int)
[ros2_control_node-1] Segmentation fault (Address not mapped to object [(nil)])
[ERROR] [ros2_control_node-1]: process has died [pid 59625, exit code -11, cmd '/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/ros2_control_node --ros-args --params-file /tmp/launch_params_x97067h1 --params-file /home/neuermann/neuer_ws/install/ros2_control_demo_bringup/share/ros2_control_demo_bringup/config/rrbot_multi_interface_forward_controllers.yaml'].
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[robot_state_publisher-2] [INFO] [1678276313.429870794] [rclcpp]: signal_handler(signum=2)
[spawner-3] Traceback (most recent call last):
[spawner-3]   File "/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/spawner", line 33, in <module>
[spawner-3]     sys.exit(load_entry_point('controller-manager==3.9.0', 'console_scripts', 'spawner')())
[spawner-3]   File "/home/neuermann/neuer_ws/install/controller_manager/local/lib/python3.10/dist-packages/controller_manager/spawner.py", line 211, in main
[spawner-3]     if not wait_for_controller_manager(
[spawner-3]   File "/home/neuermann/neuer_ws/install/controller_manager/local/lib/python3.10/dist-packages/controller_manager/spawner.py", line 117, in wait_for_controller_manager
[spawner-3]     return wait_for_value_or(
[spawner-3]   File "/home/neuermann/neuer_ws/install/controller_manager/local/lib/python3.10/dist-packages/controller_manager/spawner.py", line 66, in wait_for_value_or
[spawner-3]     time.sleep(0.2)
[spawner-3] KeyboardInterrupt
[ERROR] [spawner-3]: process has died [pid 59629, exit code -2, cmd '/home/neuermann/neuer_ws/install/controller_manager/lib/controller_manager/spawner joint_state_broadcaster --controller-manager /controller_manager --ros-args'].
[INFO] [robot_state_publisher-2]: process has finished cleanly [pid 59627]
neuermann@NeuerMann:~/neuer_ws$ 

rrbot_system_multi_interface.urdf.xacro

<?xml version="1.0"?>
<!-- Revolute-Revolute Manipulator -->
<!--
Copied and modified from ROS1 example -
https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_description/urdf/rrbot.xacro
-->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="2dof_robot">
  <xacro:arg name="use_gazebo" default="false" />

  <!-- Enable setting arguments from the launch file -->
  <xacro:arg name="use_fake_hardware" default="false" />
  <xacro:arg name="mock_sensor_commands" default="false" />
  <xacro:arg name="prefix" default="" />
  <xacro:arg name="slowdown" default="100.0" />

  <!-- Import RRBot macro -->
  <xacro:include filename="$(find rrbot_description)/urdf/rrbot_description.urdf.xacro" />

  <!-- Import all Gazebo-customization elements, including Gazebo colors -->
  <xacro:include filename="$(find rrbot_description)/gazebo/rrbot.gazebo.xacro" />

  <!-- Import Rviz colors -->
  <xacro:include filename="$(find rrbot_description)/gazebo/rrbot.materials.xacro" />

  <!-- Import RRBot ros2_control description -->
  <xacro:include filename="$(find rrbot_description)/ros2_control/rrbot_system_multi_interface.ros2_control.xacro" />
  <xacro:include filename="$(find rrbot_description)/ros2_control/system_description.ros2_control.xacro" />

  <!-- Used for fixing robot -->
  <link name="world"/>
  <gazebo reference="world">
    <static>true</static>
  </gazebo>

  <xacro:rrbot parent="world" prefix="$(arg prefix)">
    <origin xyz="0 0 0" rpy="0 0 0" />
  </xacro:rrbot>

  <xacro:rrbot_gazebo prefix="$(arg prefix)" />

  <xacro:rrbot_system_multi_interface
    name="RRBotSystemMultiInterface" prefix="$(arg prefix)"
    use_fake_hardware="$(arg use_fake_hardware)"
    mock_sensor_commands="$(arg mock_sensor_commands)"
    slowdown="$(arg slowdown)" />

</robot>

system_description.ros2_control.xacro

<?xml version="1.0"?>
<!-- Revolute-Revolute Manipulator -->
<!--
Copied and modified from ROS1 example -
https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_description/urdf/rrbot.xacro
-->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="2dof_robot">

  <ros2_control name="mySystem" type="system">
    <hardware>
        <plugin>ethercat_driver/EthercatDriver</plugin>
        <param name="master_id">0</param>
        <param name="control_frequency">100</param>
    </hardware>
  </ros2_control> 

</robot>

rrbot_system_multi_interface.launch.py

# Copyright 2021 Department of Engineering Cybernetics, NTNU.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, ThisLaunchFileDir

def generate_launch_description():
    # Declare arguments
    declared_arguments = []
    declared_arguments.append(
        DeclareLaunchArgument(
            "prefix",
            default_value='""',
            description="Prefix of the joint names, useful for \
        multi-robot setup. If changed than also joint names in the controllers' configuration \
        have to be updated.",
        )
    )
    declared_arguments.append(
        DeclareLaunchArgument(
            "slowdown", default_value="50.0", description="Slowdown factor of the RRbot."
        )
    )
    declared_arguments.append(
        DeclareLaunchArgument(
            "robot_controller",
            default_value="forward_velocity_controller",
            description="Robot controller to start.",
        )
    )

    # Initialize Arguments
    prefix = LaunchConfiguration("prefix")
    slowdown = LaunchConfiguration("slowdown")
    robot_controller = LaunchConfiguration("robot_controller")

    base_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([ThisLaunchFileDir(), "/rrbot_base.launch.py"]),
        launch_arguments={
            "controllers_file": "rrbot_multi_interface_forward_controllers.yaml",
            "description_file": "rrbot_system_multi_interface.urdf.xacro",
            "prefix": prefix,
            "use_fake_hardware": "false",
            "mock_sensor_commands": "false",
            "slowdown": slowdown,
            "robot_controller": robot_controller,
        }.items(),
    )

    return LaunchDescription(declared_arguments + [base_launch])
christophfroehlich commented 1 year ago

Hi! I never worked with ethercat and ros2, but as written in its readme it is designed for ros2_control -> there has to be a way to get that running and I don't think its an issue of the demo in this repository. But maybe @mcbed can give you an answer here.

NamanMo97 commented 1 year ago

Hello @christophfroehlich

I have managed to fix the previous problems and after some modifications in ros2_control description file, I'm able now to run the ethercat master and its ethercat drivers as plugins in the ros2_control.xacro file of the related launch file in the ros2_control_demos package (rrbot_modular_actuators.launch.py), so now I have a connection between ros2_control, ros2_controllers (I added gpio_command_controller to the ros2_controllers package), ros2_control_demos and ethercat_driver_ros2. I can write digital input on the driver using ethercat driver as a plugin (Beckhoff_EL2124), but still didn't figure out how to send position or velocity commands to the driver.

I want to ask you if you have used the ros2_control_demos package to have an implementation of ros2_control on a real robot?

mcbed commented 1 year ago

Hi @NamanMo97, As you probably already did, you need to add to the ros2_control urdf description the ec_module that you want to use for each joint/gpio component using:

<joint name="myJoint">
  <command_interface name="xxx"/>
  <state_interface name="xxx"/>
  <ec_module name="ECModule">
    <plugin>ethercat_plugins/ECModule</plugin>
    <param name="alias">xx</param>
    <param name="position">xx</param>
  </ec_module>
</joint>

I would need some more info about your setup to help you out setting it up. I suggest we move this topic to the ethercat_driver_ros2 repo.

christophfroehlich commented 1 year ago

I want to ask you if you have used the ros2_control_demos package to have an implementation of ros2_control on a real robot?

What do you mean exactly? Yes, I used these hardware interfaces as templates for a real robot.

mcbed commented 1 year ago

I want to ask you if you have used the ros2_control_demos package to have an implementation of ros2_control on a real robot?

What do you mean exactly? Yes, I used these hardware interfaces as templates for a real robot.

Same for us, new ros2_control hardware integration mostly starts from this repo.

NamanMo97 commented 1 year ago

@christophfroehlich @mcbed For my question I just wanted to check if I'm starting my integration correctly. I will move this topic to the ethercat_driver_ros2 repo with more details as @mcbed suggested.

christophfroehlich commented 1 year ago

Ok. I'll close this here, feel free to reopen if something related to this repo comes up.