ros-industrial / ros2_canopen

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

please help me look this config right or not?very thanks! #252

Open zouzhe1 opened 8 months ago

zouzhe1 commented 8 months ago

1,Describe the bug

I am a reference tutorial https://ros-industrial.github.io/ros2_canopen/manual/rolling/application/trinamic.html

I just want the motor to start running first, any mode is fine.

1,When I follow the tutorial to operate _ros2 service call /motor1_node/init stdsrvs/srv/Trigger log error:

[device_container_node-1] [INFO] [1705888066.762046931] [canopen_402_driver]: Init: Read State
[device_container_node-1] [INFO] [1705888066.762298951] [canopen_402_driver]: Init: Enable
[device_container_node-1] [INFO] [1705888066.767579770] [canopen_402_driver]: Fault reset
[device_container_node-1] [INFO] [1705888071.762750181] [canopen_402_driver]: Transition timed out.
[device_container_node-1] Could not enable motor

2,When I follow the tutorial to operate _ros2 service call /motor1_node/position_mode stdsrvs/srv/Trigger log error:

[device_container_node-1] [INFO] [1705888105.692606530] [canopen_402_driver]: Transition timed out.

3,When I follow the tutorial to operate _ros2 service call /motor1_node/target canopeninterfaces/srv/COTargetDouble "{ target: 10.0 }" log error:

The passed service type is invalid

2,Logs

launch log

[INFO] [launch]: All log files can be found below /home/b/.ros/log/2024-01-22-09-44-32-395270-b-liuwan-rpicm4-9130
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [launch.user]: /home/b/mycode/canopen/240120/install/motiong240120/share/motiong240120/config/motionG/bus.yml
[INFO] [launch.user]: /home/b/mycode/canopen/240120/install/motiong240120/share/motiong240120/config/motionG/master.dcf
[INFO] [launch.user]: /home/b/mycode/canopen/240120/install/motiong240120/share/motiong240120/config/motionG/master.bin
[INFO] [launch.user]: can0
[INFO] [device_container_node-1]: process started with pid [9150]
[device_container_node-1] [INFO] [1705887873.326679563] [device_container_node]: Starting Device Container with:
[device_container_node-1] [INFO] [1705887873.327363010] [device_container_node]:         master_config /home/b/mycode/canopen/240120/install/motiong240120/share/motiong240120/config/motionG/master.dcf
[device_container_node-1] [INFO] [1705887873.327492622] [device_container_node]:         bus_config /home/b/mycode/canopen/240120/install/motiong240120/share/motiong240120/config/motionG/bus.yml
[device_container_node-1] [INFO] [1705887873.327566900] [device_container_node]:         can_interface_name can0
[device_container_node-1] [INFO] [1705887873.330392412] [device_container_node]: Loading Master Configuration.
[device_container_node-1] [INFO] [1705887873.332799848] [device_container_node]: Load Library: /home/b/mycode/canopen/240120/install/canopen_master_driver/lib/libmaster_driver.so
[device_container_node-1] [INFO] [1705887873.352313541] [device_container_node]: Found class: rclcpp_components::NodeFactoryTemplate<ros2_canopen::MasterDriver>
[device_container_node-1] [INFO] [1705887873.354475143] [device_container_node]: Instantiate class: rclcpp_components::NodeFactoryTemplate<ros2_canopen::MasterDriver>
[device_container_node-1] [INFO] [1705887873.388133081] [master]: NodeCanopenBasicMaster
[device_container_node-1] [INFO] [1705887873.391143965] [device_container_node]: Load master component.
[device_container_node-1] [INFO] [1705887873.391452281] [device_container_node]: Added /master to executor
[device_container_node-1] [INFO] [1705887873.455037919] [device_container_node]: Loading Driver Configuration.
[device_container_node-1] [INFO] [1705887873.456025146] [device_container_node]: Found device motor1_node with driver ros2_canopen::Cia402Driver
[device_container_node-1] [INFO] [1705887873.458590731] [device_container_node]: Load Library: /home/b/mycode/canopen/240120/install/canopen_402_driver/lib/libcia402_driver.so
[device_container_node-1] [INFO] [1705887873.497668062] [device_container_node]: Found class: rclcpp_components::NodeFactoryTemplate<ros2_canopen::Cia402Driver>
[device_container_node-1] [INFO] [1705887873.497830933] [device_container_node]: Instantiate class: rclcpp_components::NodeFactoryTemplate<ros2_canopen::Cia402Driver>
[device_container_node-1] [INFO] [1705887873.555009286] [device_container_node]: Load driver component.
[device_container_node-1] [INFO] [1705887873.555683270] [device_container_node]: Added /motor1_node to executor
[device_container_node-1] [ERROR] [1705887873.632262816] [motor1_node]: Could not read enable diagnostics from config, setting to false.
[device_container_node-1] [INFO] [1705887873.633218246] [motor1_node]: 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] [1705887873.639276253] [motor1_node]: eds file /home/b/mycode/canopen/240120/install/motiong240120/share/motiong240120/config/motionG/motionG.eds
[device_container_node-1] [INFO] [1705887873.639422939] [motor1_node]: bin file /home/b/mycode/canopen/240120/install/motiong240120/share/motiong240120/config/motionG/motor1_node.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=607a subindex=0
[device_container_node-1] Found rpdo mapped object: index=6081 subindex=0
[device_container_node-1] Found rpdo mapped object: index=6083 subindex=0
[device_container_node-1] Found rpdo mapped object: index=607a subindex=0
[device_container_node-1] Found rpdo mapped object: index=6081 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=6064 subindex=0
[device_container_node-1] Found tpdo mapped object: index=606c subindex=0
[device_container_node-1] Found tpdo mapped object: index=6064 subindex=0
[device_container_node-1] Found tpdo mapped object: index=606c subindex=0
[device_container_node-1] [WARN] [1705887873.682942437] [motor1_node]: Wait for device to boot.
[device_container_node-1] [INFO] [1705887874.474374852] [motor1_node]: Driver booted and ready.
[device_container_node-1] [INFO] [1705887874.476823474] [motor1_node]: Starting with event mode.
[device_container_node-1] [INFO] [1705887874.481457308] [canopen_402_driver]: Fault reset
[device_container_node-1] [INFO] [1705887875.475123485] [motor1_node]: Slave 0x6: Switched NMT state to START

3,Setup:


4,Additional context

1,bus.yml

options:
  dcf_path: "@BUS_CONFIG_PATH@"

master:
  node_id: 1
  driver: "ros2_canopen::MasterDriver"
  package: "canopen_master_driver"
  sync_period: 10000 # us #20000

defaults:
  dcf: "motionG.eds"
  driver: "ros2_canopen::Cia402Driver"
  package: "canopen_402_driver"
  polling: false
  heartbeat_producer: 1000 # Heartbeat every 1000 ms
  switching_state: 2
  sdo: # SDO executed during config
    - {index: 0x6081, sub_index: 0, value: 10922} # Set velocity
    - {index: 0x6083, sub_index: 0, value: 21845} # Set acceleration
    - {index: 0x6084, sub_index: 0, value: 21845} # Set deceleration
    - {index: 0x6085, sub_index: 0, value: 1000000} # Set quickstop deceleration
    - {index: 0x6098, sub_index: 0, value: 35} # Set default homing mode to 35
    - {index: 0x60C2, sub_index: 1, value: 1} # Set interpolation time for cyclic modes to 50 ms
    - {index: 0x60C2, sub_index: 2, value: -3} # Set base 10-3s
    - {index: 0x6060, sub_index: 0, value: 1} # pos mode
  tpdo: # TPDO needed statusword, actual velocity, actual position, mode of operation
    1:
      enabled: true
      cob_id: "auto"
      transmission: 0x01
      mapping:
        - {index: 0x6041, sub_index: 0} # status word
        - {index: 0x6061, sub_index: 0} # mode of operaiton display
        - {index: 0x6064, sub_index: 0} # position actual value
        - {index: 0x606c, sub_index: 0} # velocity actual position
  rpdo: # RPDO needed controlword, target position, target velocity, mode of operation
    1:
      enabled: true
      cob_id: "auto"
      mapping:
      - {index: 0x6040, sub_index: 0} # controlword
      - {index: 0x6060, sub_index: 0} # mode of operation
      - {index: 0x607A, sub_index: 0} # target position
      - {index: 0x6081, sub_index: 0} # Profile Velocity
      - {index: 0x6083, sub_index: 0} # Profile Acceleration
nodes:
  motor1_node:
    node_id: 6

2,launch

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))  # noqa
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "launch"))  # noqa

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

def generate_launch_description():
    ld = LaunchDescription()

    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("motiong240120"),
                "config",
                "motionG",
                "master.dcf",
            ),
            "master_bin": os.path.join(
                get_package_share_directory("motiong240120"),
                "config",
                "motionG",
                "master.bin",
            ),
            "bus_config": os.path.join(
                get_package_share_directory("motiong240120"),
                "config",
                "motionG",
                "bus.yml",
            ),
            "can_interface_name": "can0",
        }.items(),
    )

    ld.add_action(device_container)

    return ld

some picture

image image image