ros-industrial / ros_canopen

CANopen driver framework for ROS (http://wiki.ros.org/ros_canopen)
GNU Lesser General Public License v3.0
328 stars 267 forks source link

Unable to initialise controller with ICH Motion servo motors #444

Closed stefano8302 closed 2 years ago

stefano8302 commented 2 years ago

Hi everyone, I am trying to integrate ICH Motion servo motors using ros_canopen with MoveIt on ROS Noetic running on Ubuntu 20.04, but I am unable to initialise the controllers to command a movement. I will try to explain here below with more details what I am trying to do and how I have set everything up. The motors I am employing aim at building a robotic arm that can be controlled by a PC running MoveIt on ROS. The motors are 3-phase 24V brushless DC with a 17 bit multi turn absolute encoder and rotor brake (then the motor will be coupled with a gearbox). The motor can be controlled by a driver which has also been provided by ICH Motion. The communication for the closed loop between the encoder and the driver is done via RS-485, while the connection between the driver and the controller/PC can be done via CANopen, RS-485, digital I/O, analog I/O and also USB if the manufacturer's diagnostics GUI is used. Using the PC, the connection between the PC and the driver is done with a QinHeng Electronics HL-340 USB-Serial adapter (instructions to set it up found on https://github.com/alexmohr/usb-can). The servo motors are not the ones advertised on ROS Wiki which are fully compatible and supported to be used with ROS using ros_canopen, but I believe that I have managed to adjust most of the settings to be able to control them, although I still have not managed to do it. The only controller (which I understand is not able to send commands) I have managed to initialise is the "joint_state_controller" and I can see the motor movements on RViz when I send commands form another source (the manufacture's GUI provided). When I try to initialise any controller that is meant to send commands to the motor/robotic arm, I get the error that says it could not find the joint/joints in 'hardware_interface::EffortJointInterface' (this happens also if I try to initialise a PositionJointInterface or a VelocityJointInterface controller); so it fails to initialise/start the controller. The actual message is: [ERROR] [1631696760.273566588, 554.016000000]: Could not find joint 'eje1_joint' in 'hardware_interface::EffortJointInterface'. [ERROR] [1631696760.273651160, 554.016000000]: Failed to initialize the controller [ERROR] [1631696760.274138060, 554.016000000]: Initializing controller 'joint_trajectory_controller' failed [ERROR] [1631696760.274720584, 554.017000000]: Could not start controller with name 'joint_trajectory_controller' because no controller with this name exists.

I have followed these steps:

  1. Socketcan is working
  2. The URDF is OK `

    1000.0 1000.0 1.0 1.0 Gazebo/Green 1000.0 1000.0 1.0 1.0 Gazebo/Yellow transmission_interface/SimpleTransmission hardware_interface/EffortJointInterface hardware_interface/EffortJointInterface 1 `

stick3.txt

  1. The .eds file has been provided by the manufacturer, but I had to revise and change it to make it work. Now I manage to initialise the driver with the ros_canopen using canopen_motor_node.
  2. The driver config for 1 motor/joint is as follows: ` bus: device: can0 # socketcan network loopback: false # socket should loop back messages driver_plugin: can::SocketCANInterface master_allocator: canopen::SimpleMaster::Allocator sync: interval_ms: 10 #100Hz # set to 0 to disable sync; COD ID 080 overflow: 0 # overflow sync counter at value or do not set it (0, default)

    defaults: # optional, all defaults can be overwritten per node

    canopen_chain_node settings ..

    eds_pkg: cantest
    eds_file: "/config/Canopen_V3.0.eds"
    motor_allocator: canopen::Motor402::Allocator # select allocator for motor layer
    motor_layer: settings passed to motor layer (plugin-specific)
    switching_state: 5 # (Operation_Enable), state for mode switching
    pos_to_device: "rint(rad2deg(pos)*364.088)" # rad -> 364.088*deg --- (rad -> mdeg)
    pos_from_device: "deg2rad((obj6064)/364.088)" # actual position [364.088*deg] -> rad --- ([mdeg] -> rad)
    vel_to_device: "rint(rad2deg(vel)*60/360)" # rad/s -> rpm --- (rad/s -> mdeg/s)
    vel_from_device: "deg2rad((obj606C)/60*360)" # actual velocity rpm -> rad/s --- ([mdeg/s] -> rad/s)
    eff_to_device: "rint(eff)" # just round to integer
    eff_from_device: "0" # unset

    nodes: eje1_joint: id: 6`

canconfig_stick3.txt

  1. list of controllers:

ros_controllers.txt

  1. The launchfile for canopen_motor_node: `

    `

stick_can_ros_controllers.txt

When I use the launcher it seems to be correct and when I execute: rosservice call /driver/init I get a successful initialisation and I can see the CAN traffic in the candump.

If the controllers have not been loaded automatically, I use rqt controller manager (rosrun rqt_controller_manager rqt_controller_manager) to load and unload them for ease of use when debugging. When I try to load and start the joint_state_controller it is all good, but when I try to load the joint_trajectory_controller or eje1_joint_position_controller I get the error message above.

Please review my message and let me know if I have missed something that is useful to make you all understand the issue.

Thank you very much regards, Stefano

stefano8302 commented 2 years ago

Hi all, I have done some more research and I wonder if there is a problem with the USB to CAN adapter (QinHeng Electronics HL-340 USB-Serial adapter). I have reviewed the list of tested USB to CAN adapters on the page: http://wiki.ros.org/socketcan_interface?distro=noetic and thought that maybe the adapter I am using is not 100% compatible with socketcan_interface; possibly it is not able to work as a "master" but only as "slave"? I am saying this also because I can only start the "joint_state_controller" which shows the joint position in real time on RViz, but any other "master" controller that sends orders to the motor cannot be loaded nor started. Thanks.

Regards, Stefano

stefano8302 commented 2 years ago

Hi again, this is a quick update as I have also tried to reproduce the same issue using Ubuntu 18.04 and ROS Melodic (previously Ubuntu 20.04 and ROS Noetic), but unfortunately I get the same error message "Could not find joint 'eje1_joint' in 'hardware_interface::EffortJointInterface'". Thanks.

Regards, Stefano

mathias-luedtke commented 2 years ago

It looks like your drive does not support the torque modes (4 or 10) or it does not report the support properly. And in addition your configuration configures mode 1 (profiled position) or mode 7 (interpolated position) for your effort_controllers/* controllers.


This is clearly a wrong configuration and there does not seem to be any issue with ros_canopen, so I will close this now. For more support, please try https://answers.ros.org/.

stefano8302 commented 2 years ago

Hi Mathias, firstly thanks for your reply. Secondly, after reading your answer, I would like to comment that the driver's supported modes are: 1, 3, 4, 6 and 8. So I understand that, as mode 10 is not supported (only one of the 2 torque/effort modes), then the error is produced. Please confirm. Also, I have tried modifying effort_controllers/ into position_controllers/

Controllers file:

`eje1_joint_position_controller: type: position_controllers/JointPositionController joints:

URDF file:

`

transmission_interface/SimpleTransmission
<joint name="eje1_joint">
    <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="motor1">
    <hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
    <mechanicalReduction>1</mechanicalReduction>
</actuator>

`

in accordance to the mode 1 called up in the configuration, but I get another error message saying: "No joint given (namespace: /eje1_joint_position_controller)" which is the controller with the required drive mode 1.

Before closing this issue completely, please confirm:

Thanks a lot.

Regards, Stefano

mathias-luedtke commented 2 years ago

if my statement about not having just one of the two torque driver modes supported, generates the error and

As long as one torque mode is supported, ros_canopen will register the effort interface. The URDF settings are only relevant for Gazebo..

if the other error message I received is due to a wrong configuration or structure of the files in the package.

Wrong configuration. https://github.com/ros-controls/ros_controllers/search?q=No+joint+given Please note that the single-joint controller have a different config structure from the multi-joints one.

stefano8302 commented 2 years ago

Hi all, for the users that could be interested in the solution I have found, I would like to share the following that finally made the driver work: just refer to the issue #257 https://github.com/ros-industrial/ros_canopen/issues/257 and add/modify the parameter 6502 in the .eds file with the default value that suits you best. Thanks.

Regards, Stefano