ros-industrial / ros2_canopen

CANopen driver framework for ROS2
https://ros-industrial.github.io/ros2_canopen/manual/rolling/
159 stars 71 forks source link

Building error humble - COB-ID not read correclty leads to 'NoneType' #327

Closed BatisteAll closed 1 month ago

BatisteAll commented 1 month ago

Description I am trying to control two ingenia NIX-10-48-C-C servo drives using ros2_canopen. The .eds file I use can be found here: link_to_eds. The error when building and the bus.yml can be found below.

It seems that the Cob-ids of the PDOs are not read and it results in NoneType error. I tried to set them manually in the bus.yml for each slave but I still get the same error. I don't know what is the exact mechanism behind the "auto" mode. Do you have an idea of what could be wrong?

Error Log Here is the log when building:

Starting >>> lab_canopen_config
--- stderr: lab_canopen_config                         
/home/user1/workspaces/ros2_ws/install/lely_core_libraries/lib/python3.10/site-packages/dcfgen/cli.py:187: UserWarning: invalid entry in [DeviceInfo]: Baudrate_100
  if not dcf.lint(cfg) and not no_strict:
Traceback (most recent call last):
  File "/home/user1/workspaces/ros2_ws/install/lely_core_libraries/bin/dcfgen", line 33, in <module>
    sys.exit(load_entry_point('dcf-tools==2.4.0', 'console_scripts', 'dcfgen')())
  File "/home/user1/workspaces/ros2_ws/install/lely_core_libraries/lib/python3.10/site-packages/dcfgen/cli.py", line 636, in main
    slave = Slave.from_config(name, cfg[name], options, args)
  File "/home/user1/workspaces/ros2_ws/install/lely_core_libraries/lib/python3.10/site-packages/dcfgen/cli.py", line 319, in from_config
    sdo = slave.__parse_pdo_config(
  File "/home/user1/workspaces/ros2_ws/install/lely_core_libraries/lib/python3.10/site-packages/dcfgen/cli.py", line 73, in __parse_pdo_config
    if "cob_id" in cfg:
TypeError: argument of type 'NoneType' is not iterable
gmake[2]: *** [CMakeFiles/demarlus_demo_bus.dir/build.make:75: demarlus_demo_bus] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:165: CMakeFiles/demarlus_demo_bus.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---
Failed   <<< lab_canopen_config [1.79s, exited with code 2]

Bus.yml Here is the bus.yml:

options:  # General options especially dcf_path
    dcf_path: "@BUS_CONFIG_PATH@" #directory to generated .bin at runtime. “@BUS_CONFIG_PATH@” for auto-generated by cmake.
master: # The configuration of the master
    node_id: 1
    driver: "ros2_canopen::MasterDriver"
    package: "canopen_master_driver"
    sync_period: 10000

defaults: # Defaults that apply to all slave nodes
    dcf: "0x26_0x29C_0x137.eds"
    driver: "ros2_canopen::Cia402Driver"
    package: "canopen_402_driver"
    period: 10
    heartbeat_producer: 1000
    switching_state: 2          # Switch in CiA402 State 2
    position_mode: 7            # Use interpolated position mode
    scale_pos_from_dev: 0.00001745329252
    scale_pos_to_dev: 57295.7795131
    sdo:
        - {index: 0x6081, sub_index: 0, value: 1000}
        - {index: 0x60C2, sub_index: 1, value: 10} # Interpolation time period at 10 ms matches the period.

    tpdo: # TPDO needed statusword, actual velocity, actual position, mode of operation
        1:
        enabled: true
        cob_id: "auto" #1B2 = 180 + 32
        transmission: 0x01
        mapping:
            - {index: 0x6064, sub_index: 0} # position actual value
            - {index: 0x606C, sub_index: 0} # velocity actual position
        2:
        enabled: true
        cob_id: "auto"
        transmission: 0x01
        mapping:
            - {index: 0x6041, sub_index: 0} # status word
            - {index: 0x603F, sub_index: 0} # error code
            - {index: 0x6061, sub_index: 0} # modes of operation display
            - {index: 0x6077, sub_index: 0} # torque actual value
        3:
        enabled: true
        cob_id: "auto"
        transmission: 0x01
        mapping:
            - {index: 0x2601, sub_index: 1} # [current d-q] current direct
            - {index: 0x2A03, sub_index: 0} # [analog inputs] analog input value
        4:
        enabled: true
        cob_id: "auto"
        transmission: 0x01
        mapping:
            - {index: 0x2611, sub_index: 1} # [voltage d-q] voltage direct
            - {index: 0x2611, sub_index: 2} # [voltage d-q] voltage quadrature
            - {index: 0x2601, sub_index: 2} # [Current d-q] current quadrature
    rpdo: # RPDO needed controlword, target position, target velocity, mode of operation
        1:
        enabled: true
        cob_id: "auto"  # 232 = 200 + 32
        mapping:
        - {index: 0x6040, sub_index: 0} # controlword
        2:
        enabled: true
        cob_id: "auto"
        mapping:
        - {index: 0x6040, sub_index: 0} # controlword
        - {index: 0x6060, sub_index: 0} # mode of operation
        3:
        enabled: true
        cob_id: "auto"
        mapping:
        - {index: 0x6040, sub_index: 0} # controlword
        - {index: 0x607A, sub_index: 0} # target position
        4:
        enabled: true
        cob_id: "auto"
        mapping:
        - {index: 0x6040, sub_index: 0} # controlword
        - {index: 0x60FF, sub_index: 0} # target velocity

nodes:  # Configurations for all slave nodes
    joint_2_3:
        node_id: 32
    joint_3_4:
        node_id: 33

Setup:

BatisteAll commented 1 month ago

It was just the indentation in the bus.yml that was wrong and there was no section recognized under tpdo and rpdo.