ros-industrial / ros_canopen

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

When positon mode, driver run previous position instead of the current position set on 0x607A #373

Closed clm330 closed 4 years ago

clm330 commented 4 years ago

When I sent position command to driver in position mode, the motor always rotate to previous position set on 0x607A.

ros-canopen version: kinetic controller:joint_state_controller/JointStateController

Graph: See the graph. When 0x6040 rising delay, the driver always run to previous position. Screenshot from 2019-12-22 16-14-15

It seems when rising delay, the 0x607A still not update. I try to set a delay at the rising delay to solve this problem but it seems no effect.

cpp file: canopen_402/src/motor.cpp function: Motor402::handleWrite(LayerStatus &status, const LayerState &current_state)

            if(okay) {
                // --------add delay------------
                if(this->mode_id_ == 1){
                    sleep(0.1);
                }
                // --------add delay------------
                std::cout<<"~(1<<Command402::CW_Halt) : "<<std::hex << static_cast<int>(~(1<<Command402::CW_Halt))<<std::endl;
                control_word_ &= ~(1<<Command402::CW_Halt);
                std::cout<<"drive_id :"<<this->name<<" control word :"<<std::hex << static_cast<int>(control_word_)<<std::endl;
            }

Maybe I added the delay in the wrong place, can tell me where to add the delay. It may help debug. Thanks.

mathias-luedtke commented 4 years ago

See the graph

Are you sure that the motor does not just drive into the wrong direction? Could you prepare a graph that steps the position up?

I try to set a delay at the rising delay

If you add a delay to handleWrite, you prolong the communication cycle. These function should never block like this.

clm330 commented 4 years ago

@ipa-mdl

Are you sure that the motor does not just drive into the wrong direction? Could you prepare a graph that steps the position up?

See this gragp. I sent the position first time, but nothing happened. It can prove that the driver always goes to the previous position. Screenshot from 2019-12-23 09-40-05

This graph is candump -td about 401(mapping 0x607A), I sent 3.3(1487) to 0x607A. Does time affect the program?? Screenshot from 2019-12-23 17-16-44

This is graph is candump -ta about 401. Screenshot from 2019-12-23 17-45-45 This graph show sent control_word(201) less than one millisecond after sending position msg. According to the figure above, the total time to send the position is 98 ms. Can the driver receive the position correctly msg before running the command?

If you add a delay to handleWrite, you prolong the communication cycle. These function should never block like this.

About delay. Sometime I found 0x6040 rising delay before position cmd 0x607A changed. Screenshot from 2019-12-24 15-04-15

I think it may be that when the position information is rising delay(0x6064), 0x607A has not received the latest location information, so the driver always runs to the previous position. Can I add a delay to control_word (0x6040) for bebug ? If can add, where I should add a delay in source code?

clm330 commented 4 years ago

In velocity mode, I find similar phenomenon. I set interval_ms to 500. See the graph.

Screenshot from 2019-12-23 14-32-50

The actual velocity 0x606C begen to change from 0 after two time interval_ms, even if set interval_ms to shorter time interval.

Is this problem same with the above?

clm330 commented 4 years ago

Set the Transmission type to 255, it works normally.