ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Control single Maxon motor after successful ros_canopen initialization

asked 2021-05-17 16:10:53 -0500

martinlucan gravatar image

Hello there,

I do have some decent experience with ROS, but I am quite a newbie in CANopen topic. My goal is to control a single Maxon EC-40 motor with EPOS 50/5 CAN controller through CANopen interface. From a hardware point of view, I communicate from the laptop to the EPOS controller through PEAK USB-CAN interface. I have basically followed steps (here) and set up all the required files. DCF file was exported directly from EPOS Studio.

CANopen bus layer:

bus:
  device: can0
  baudrate: 500K  
  diagnostic_period: 10
sync:
  interval_ms: 10
  overflow: 0
#heartbeat: # simple heartbeat producer, optional!
#  rate: 20 # heartbeat rate
#  msg: "1#05" # message to send, cansend format: heartbeat of node 127 with status 5=Started

ROS layer:

name: steering_motor

defaults:
  eds_pkg: maxon_canopen
  eds_file: "config/steering_config_3.dcf"

  #the following scaling is due to 16bit value range limitation of velocity command in vl mode (2)
  vel_to_device: "rint(rad2deg(vel)*250)"
  #dcf_overlay:  "ObjectID": "ParameterValue" (both as strings)
  #  "606B": "1" # vl dimension factor numerator
  #  "606C": "24000" # vl dimension factor denominator
 # list of objects to be published (one topic per node)
  publish: ["607A!"]

nodes:
  arm_1_joint:
    id: 1

Launch file

?xml version="1.0"?>

<launch>  

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find maxon_canopen)/urdf/robot.urdf'" />
  <node ns="steering_motor" name="driver" pkg="canopen_motor_node" type="canopen_motor_node" output="screen" clear_params="true"  required="true" launch-prefix=""> 
     <rosparam command="load" file="$(find maxon_canopen)/config/can0.yaml" />
     <rosparam command="load" file="$(find maxon_canopen)/config/maxon_driver.yaml" />
  </node>


</launch>

Unfortunately, it still does not allow me to control the motor. I am currently able to successfully initialize the motor by rosservice call steering_motor/driver/init, although with a few error messages received:

SUMMARY
========

CLEAR PARAMETERS
 * /steering_motor/driver/

PARAMETERS
 * /robot_description: <?xml version="1....
 * /rosdistro: melodic
 * /rosversion: 1.14.10
 * /steering_motor/driver/bus/baudrate: 500K
 * /steering_motor/driver/bus/device: can0
 * /steering_motor/driver/bus/diagnostic_period: 10
 * /steering_motor/driver/defaults/eds_file: config/steering_c...
 * /steering_motor/driver/defaults/eds_pkg: maxon_canopen
 * /steering_motor/driver/defaults/publish: ['607A!']
 * /steering_motor/driver/defaults/vel_to_device: rint(rad2deg(vel)...
 * /steering_motor/driver/name: steering_motor
 * /steering_motor/driver/nodes/arm_1_joint/id: 1
 * /steering_motor/driver/sync/interval_ms: 10
 * /steering_motor/driver/sync/overflow: 0

NODES
  /steering_motor/
    driver (canopen_motor_node/canopen_motor_node)

auto-starting new master
process[master]: started with pid [30268]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to d947f37c-b72e-11eb-9f66-58961d164e50
process[rosout-1]: started with pid [30290]
started core service [/rosout]
process[steering_motor/driver-2]: started with pid [30297]
[ INFO] [1621269741.800681492]: Using fixed control period: 0.010000000
[ INFO] [1621269746.541325278]: Initializing...
[ INFO] [1621269746.541768368]: Current state: 1 device error: system:0 internal_error: 0 (OK)
[ INFO] [1621269746.542097004]: Current state: 2 device error: system:0 internal_error: 0 (OK)
[ERROR] [1621269746.545863050]: Received error frame: 20000004#0000000000000000
[ERROR] [1621269746.546110144]: Received error frame: 20000004#0020000000000000
[ERROR] [1621269746.549603030]: Received error frame: 20000004#0008000000000000
[ERROR] [1621269747.550652964]: Did not receive a response message
[ WARN] [1621269747.550928842]: discarded message 
[ERROR] [1621269748.065201756]: EMCY received: 81#0000000000000000
[ INFO] [1621269748.065908210]: Initializing successful

But I am fairly unsure about the next step. Is it sufficient to simply publish required ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2021-07-05 11:32:10 -0500

martinlucan gravatar image

Hi @Cyril_J, sure, please check the following launch file, and controllers configuration. The rest of the files remains the same as posted in the original question. The DCF file is way too long, and I am not able to share it as an attachment, I may send it to you directly. Also, the error messages posted in the original question, appearing after the init service remains the same. The URDF files were picked over from a different project, anyways, that should not affect this issue. At this point, I am not sure how to push commands to a motor. I do see a controller topic, where I am supposed to publish data, but it does not work so far. Am I supposed to write my own hardware interface to connect ros_control with Maxon motor? Thank you.

Launch file

<?xml version="1.0"?>

<launch>  

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find maxon_canopen)/urdf/robot.urdf'" />
  <node ns="steering_motor" name="driver" pkg="canopen_motor_node" type="canopen_motor_node" output="screen" clear_params="true"  required="true" launch-prefix=""> 
     <rosparam command="load" file="$(find maxon_canopen)/config/can0.yaml" />
     <rosparam command="load" file="$(find maxon_canopen)/config/maxon_driver.yaml" />
  </node>

  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="$(find maxon_canopen)/config/controllers.yaml" command="load" ns="/steering_motor"/> 

  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="controller_manager" respawn="false"
      output="screen" ns="/steering_motor" args="spawn
                                                joint_state_controller
                                                arm_1_joint_position_controller"/>

</launch>

Controllers configuration

joint_state_controller:
    type: joint_state_controller/JointStateController
    joints: [arm_1_joint]
    publish_rate: 50
    required_drive_mode: 1

arm_1_joint_position_controller:
  type: position_controllers/JointPositionController
  joints: [arm_1_joint]
  required_drive_mode: 1
edit flag offensive delete link more
0

answered 2021-05-19 06:37:51 -0500

Mathias Lüdtke gravatar image

although with a few error messages received:

You should try to fix them.. At first you should decode the error frames to see what's the issue with your CAN bus. The diagnostics topic might be helpful as well. Some are errors are harmless, other are not. Normally with a PEAK USB you should not get any.

Is it sufficient to simply publish required data (e.g. target velocity) to a corresponding topic, following the .dcf configuration without any ros_control entity?

No. canopen_motor_node implements the ros_control interface and needs the controllers to interface the motor with ROS. Even more: If no controller is running ros_canopen with halt all motions and prevent any other interaction with the motor sub-system.

But I am fairly unsure about the next step.

I would start with a joint state "controller" to test the overall connection and double check your unit conversions. And finally you should set up other controllers that annually drive the motor. E.g. a simple velocity controller that reads the target velocity from a topic.

Please do not forget setting the required_drive_mode parameter!

edit flag offensive delete link more

Comments

Thank you @Mathias Lüdtke for the answer. I have managed to successfully set up JointStateController and JointPositionController and I am able to see the actual joint values. Unfortunately, when I publish a target position value on joint_position_controller/command topic, the motor does not move. So far, errors during initialization remains the same, I was not able to decode them. Diagnostic topic says that "Motor operation is not enabled". May you please give some advice on how to enable the motor?

header: 
  seq: 3441
  stamp: 
    secs: 1625238340
    nsecs: 545974526
  frame_id: ''
status: 
  - 
    level: 0
    name: "steering_motor/driver: chain"
    message: ''
    hardware_id: "none"
    values: []
  - 
    level: 1
    name: "steering_motor/driver: arm_1_joint"
    message: "Motor operation is not enabled"
    hardware_id: "none"
    values: []

Thank You.

martinlucan gravatar image martinlucan  ( 2021-07-02 10:09:09 -0500 )edit

Hi martinlucan, are you able to share all your configuration files or update your question to see where the problem could come from ? Like your controller configuration, URDF, new launch file, and potentially your DCF file.

Cyril Jourdan gravatar image Cyril Jourdan  ( 2021-07-05 03:13:15 -0500 )edit

Hi @Cyril_J, I answered in a separate answer, since the message did not meet comment limits.

martinlucan gravatar image martinlucan  ( 2021-07-05 12:59:25 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2021-05-17 16:10:53 -0500

Seen: 341 times

Last updated: Jul 05 '21