Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with booting the device #225

Open
C-002 opened this issue Nov 10, 2023 · 3 comments
Open

Problem with booting the device #225

C-002 opened this issue Nov 10, 2023 · 3 comments
Labels
question Further information is requested

Comments

@C-002
Copy link

C-002 commented Nov 10, 2023

Describe the bug
Hello! I'm trying to control a motor with ros2_canopen, following the tutorials "How to create..." and "canopen_tests" packages. However, after launching the launch file, the process stopped at booting the device and it responded "False" while calling the init trigger.

Logs

launch file:

import os
from ament_index_python import get_package_share_directory
from launch import LaunchDescription
import launch 
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource

def generate_launch_description():
    kinco_eds_path = os.path.join(
        get_package_share_directory("kinco_node"),
        "config",
        "kinco_config",
        "kinco.eds"
    )

    ld = LaunchDescription()
    # slave_node_1 = IncludeLaunchDescription(
    #     PythonLaunchDescriptionSource(
    #         [
    #             os.path.join(get_package_share_directory("canopen_fake_slaves"), "launch"),
    #             "/cia402_slave.launch.py",
    #         ]
    #     ),
    #     launch_arguments={
    #         "node_id": "2",
    #         "node_name": "kinco_node_1",
    #         "slave_config": kinco_eds_path,
    #     }.items(),
    # )

    master_bin_path = os.path.join(
        get_package_share_directory("canopen_tests"),
        "config",
        "kinco_config",
        "master.bin",
    )
    if not os.path.exists(master_bin_path):
        master_bin_path = ""

    device_container = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            [
                os.path.join(get_package_share_directory("canopen_core"), "launch"),
                "/canopen.launch.py",
            ]
        ),
        launch_arguments={
            "master_config": os.path.join(
                get_package_share_directory("kinco_node"),
                "config",
                "kinco_config",
                "master.dcf",
            ),
            "master_bin": master_bin_path,
            "bus_config": os.path.join(
                get_package_share_directory("kinco_node"),
                "config",
                "kinco_config",
                "bus.yml",
            ),
            "can_interface_name": "can0",
        }.items(),
    )

    ld.add_action(device_container)
    # ld.add_action(slave_node_1)

    return ld

bus yml file:

options: 
  dcf_path: "@BUS_CONFIG_PATH@"

master:
  node_id: 1
  driver: "ros2_canopen::MasterDriver"
  package: "canopen_master_driver"
  sync_period: 10000
  baudrate: 500000
  vendor_id: 0x00000300
  product_code: 0x4644

defaults:
  dcf: "kinco.eds"
  driver: "ros2_canopen::Cia402Driver"
  package: "canopen_402_driver"
  # polling: false
  heartbeat_producer: 1000
  period: 10
  # switching_state: 2
  revision_number: 0
  sdo:
    - {index: 0x6060, sub_index: 0, value: 3}
  tpdo:
    1:
      enabled: true
      cob_id: "auto"
      transmission: 0x01
      mapping:
        - {index: 0x6041, sub_index: 0} # status word
        - {index: 0x6061, sub_index: 0} # mode of operation
    2:
      enabled: true
      cob_id: "auto"
      transmission: 0x01
      mapping:
        # - {index: 0x6064, sub_index: 0} # position actual value
        - {index: 0x606c, sub_index: 0} # velocity actual value
        - {index: 0x6077, sub_index: 0} # torque actual value
    3:
      enabled: false
    # 3:
    #   enabled: true
    #   cob_id: "auto"
    #   transmission: 0x01
    #   mapping:
    #     - {index: 0x6077, sub_index: 0} # torque actual value
    4:
      enabled: false
  rpdo:
    1:
      enabled: true
      cob_id: "auto"
      mapping:
        - {index: 0x6040, sub_index: 0} # control word
        - {index: 0x6060, sub_index: 0} # mode of operation
    2: 
      enabled: true
      cob_id: "auto"
      mapping:
        - {index: 0x607A, sub_index: 0} # target position
        - {index: 0x60FF, sub_index: 0} # target velocity
    3:
      enabled: false
    4:
      enabled: false

nodes: 
  joint_1:  # left wheel
    node_id: 2
  # joint_2:  # right wheel
  #   node_id: 3
  # joint_3:  # rolling
  #   node_id: 4

CMakeLists file:

cmake_minimum_required(VERSION 3.8)
project(kinco_node)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(canopen REQUIRED)
find_package(canopen_core REQUIRED)
find_package(canopen_interfaces REQUIRED)
find_package(canopen_402_driver REQUIRED)
find_package(lely_core_libraries REQUIRED)

cogen_dcf(kinco_config)

install(DIRECTORY
  launch 
  DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()

launch output:

user@user-Default-string:canopen_ws$ ros2 launch kinco_node test1_kinco.launch.py 
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2023-11-10-10-55-44-264407-user-Default-string-34388
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [launch.user]: /home/user/workSpace/canopen_ws/install/kinco_node/share/kinco_node/config/kinco_config/bus.yml
[INFO] [launch.user]: /home/user/workSpace/canopen_ws/install/kinco_node/share/kinco_node/config/kinco_config/master.dcf
[INFO] [launch.user]: 
[INFO] [launch.user]: can0
[INFO] [device_container_node-1]: process started with pid [34399]
[device_container_node-1] [INFO] [1699584944.424338068] [device_container_node]: Starting Device Container with:
[device_container_node-1] [INFO] [1699584944.424405381] [device_container_node]: 	 master_config /home/user/workSpace/canopen_ws/install/kinco_node/share/kinco_node/config/kinco_config/master.dcf
[device_container_node-1] [INFO] [1699584944.424411566] [device_container_node]: 	 bus_config /home/user/workSpace/canopen_ws/install/kinco_node/share/kinco_node/config/kinco_config/bus.yml
[device_container_node-1] [INFO] [1699584944.424416194] [device_container_node]: 	 can_interface_name can0
[device_container_node-1] [INFO] [1699584944.424977999] [device_container_node]: Loading Master Configuration.
[device_container_node-1] [INFO] [1699584944.425288488] [device_container_node]: Load Library: /home/user/workSpace/canopen_ws/install/canopen_master_driver/lib/libmaster_driver.so
[device_container_node-1] [INFO] [1699584944.427277402] [device_container_node]: Found class: rclcpp_components::NodeFactoryTemplate<ros2_canopen::MasterDriver>
[device_container_node-1] [INFO] [1699584944.427296970] [device_container_node]: Instantiate class: rclcpp_components::NodeFactoryTemplate<ros2_canopen::MasterDriver>
[device_container_node-1] [INFO] [1699584944.429403497] [master]: NodeCanopenBasicMaster
[device_container_node-1] [INFO] [1699584944.429489120] [device_container_node]: Load master component.
[device_container_node-1] [INFO] [1699584944.429533722] [device_container_node]: Added /master to executor
[device_container_node-1] [INFO] [1699584944.440258342] [device_container_node]: Loading Driver Configuration.
[device_container_node-1] [INFO] [1699584944.440344418] [device_container_node]: Found device joint_1 with driver ros2_canopen::Cia402Driver
[device_container_node-1] [INFO] [1699584944.440583862] [device_container_node]: Load Library: /home/user/workSpace/canopen_ws/install/canopen_402_driver/lib/libcia402_driver.so
[device_container_node-1] [INFO] [1699584944.445294062] [device_container_node]: Found class: rclcpp_components::NodeFactoryTemplate<ros2_canopen::Cia402Driver>
[device_container_node-1] [INFO] [1699584944.445331983] [device_container_node]: Instantiate class: rclcpp_components::NodeFactoryTemplate<ros2_canopen::Cia402Driver>
[device_container_node-1] [INFO] [1699584944.447789437] [device_container_node]: Load driver component.
[device_container_node-1] [INFO] [1699584944.447871402] [device_container_node]: Added /joint_1 to executor
[device_container_node-1] [ERROR] [1699584944.457004887] [joint_1]: Could not polling from config, setting to true.
[device_container_node-1] [ERROR] [1699584944.457112020] [joint_1]: Could not read enable diagnostics from config, setting to false.
[device_container_node-1] [INFO] [1699584944.457250646] [joint_1]: scale_pos_to_dev_ 1000.000000
[device_container_node-1] scale_pos_from_dev_ 0.001000
[device_container_node-1] scale_vel_to_dev_ 1000.000000
[device_container_node-1] scale_vel_from_dev_ 0.001000
[device_container_node-1] 
[device_container_node-1] [INFO] [1699584944.458165151] [joint_1]: eds file /home/user/workSpace/canopen_ws/install/kinco_node/share/kinco_node/config/kinco_config/kinco.eds
[device_container_node-1] [INFO] [1699584944.458185483] [joint_1]: bin file /home/user/workSpace/canopen_ws/install/kinco_node/share/kinco_node/config/kinco_config/joint_1.bin
[device_container_node-1] Found rpdo mapped object: index=6040 subindex=0
[device_container_node-1] Found rpdo mapped object: index=6060 subindex=0
[device_container_node-1] Found rpdo mapped object: index=6040 subindex=0
[device_container_node-1] Found rpdo mapped object: index=607a subindex=0
[device_container_node-1] Found rpdo mapped object: index=60ff subindex=0
[device_container_node-1] Found tpdo mapped object: index=6041 subindex=0
[device_container_node-1] Found tpdo mapped object: index=6061 subindex=0
[device_container_node-1] Found tpdo mapped object: index=6061 subindex=0
[device_container_node-1] Found tpdo mapped object: index=606c subindex=0
[device_container_node-1] Found tpdo mapped object: index=6077 subindex=0
[device_container_node-1] [WARN] [1699584944.461996910] [joint_1]: Wait for device to boot.
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[device_container_node-1] [INFO] [1699584971.897706201] [rclcpp]: signal_handler(signum=2)
[ERROR] [device_container_node-1]: process[device_container_node-1] failed to terminate '5' seconds after receiving 'SIGINT', escalating to 'SIGTERM'
[INFO] [device_container_node-1]: sending signal 'SIGTERM' to process[device_container_node-1]
[device_container_node-1] [INFO] [1699584977.425747645] [rclcpp]: signal_handler(signum=15)
[ERROR] [device_container_node-1]: process[device_container_node-1] failed to terminate '10.0' seconds after receiving 'SIGTERM', escalating to 'SIGKILL'
[INFO] [device_container_node-1]: sending signal 'SIGKILL' to process[device_container_node-1]
[ERROR] [device_container_node-1]: process has died [pid 34399, exit code -9, cmd '/home/user/workSpace/canopen_ws/install/canopen_core/lib/canopen_core/device_container_node --ros-args -r __node:=device_container_node -r __ns:=/ --params-file /tmp/launch_params_azbrn4yx --params-file /tmp/launch_params_is2xeotb --params-file /tmp/launch_params_kjf0sfkw --params-file /tmp/launch_params_zj0gunau'].

candump output:

(1699584944.440580) can0 701#00
(1699584944.440918) can0 000#8200
(1699584944.441634) can0 704#00
(1699584944.441637) can0 703#00
(1699584944.441639) can0 702#00
(1699584944.442136) can0 602#4000100000000000
(1699584944.442629) can0 582#4300100092010200
(1699584944.443041) can0 602#4018100100000000
(1699584944.443396) can0 582#4318100100030000
(1699584944.443855) can0 602#4018100200000000
(1699584944.444173) can0 582#4318100244460000
(1699584944.444189) can0 080#
(1699584944.453973) can0 080#
(1699584944.463994) can0 080#
(1699584944.473961) can0 080#
(1699584944.484004) can0 080#
(1699584944.493971) can0 080#
(1699584944.504032) can0 080#
(1699584944.513959) can0 080#
(1699584944.523973) can0 080#
(1699584944.533958) can0 080#
(1699584944.543960) can0 080#
(1699584944.553997) can0 080#
(1699584944.563964) can0 080#
(1699584944.573959) can0 080#
(1699584944.583958) can0 080#
(1699584944.593964) can0 080#
(1699584944.603961) can0 080#
(1699584944.613965) can0 080#
(1699584944.623959) can0 080#
(1699584944.633953) can0 080#

init result:

user@user-Default-string:~$ ros2 service call /joint_1/init std_srvs/srv/Trigger 
requester: making request: std_srvs.srv.Trigger_Request()

response:
std_srvs.srv.Trigger_Response(success=False, message='')

Setup:

  • Device: PC
  • OS: Ubuntu 22.04.3 LTS (6.2.0-36-generic)
  • ROS-Distro: Humble
  • Branch/Commit: humble

Additional context

The output shows the ros2_canopen process read the device info by 0x1000 and 0x1018 and then it stopped. I'm a fish leg to use CANOpen and it's difficult for me to locate the problem. Any hints or suggestions?

Thanks a lot!

@C-002 C-002 added the question Further information is requested label Nov 10, 2023
@jimowei
Copy link

jimowei commented Nov 13, 2023

[device_container_node-1] [WARN] [1699584944.461996910] [joint_1]: Wait for device to boot.
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)

Do not interrupt with ctrl-c. when ros2_canopen get "702#00",the process will continue.

@hellantos
Copy link
Member

hellantos commented Nov 14, 2023

@C-002 seems there is no error happening in sdo communication. But it could be that the value of 1018sub2 in eds does not match what is actually on the device.

You can disable that check by adding product_code: 0 for the device in bus.yml.

@glaciercoder
Copy link

Have you solved the problem now? I'm meeting the same problem with you. I'm anxious now. @C-002

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants