ZebraDevs / robot_controllers

Robot control infrastructure
92 stars 79 forks source link

Cannot start controller after stopping controller manually #72

Closed tkmtnt7000 closed 2 years ago

tkmtnt7000 commented 2 years ago

Hi. When I used https://github.com/fetchrobotics/robot_controllers/blob/010855f0e6a8e058a1cbd2ad69c324cd97f0d815/robot_controllers_interface/scripts/stop_controller.py to stop a controller and tried to start the controller by using https://github.com/fetchrobotics/robot_controllers/blob/010855f0e6a8e058a1cbd2ad69c324cd97f0d815/robot_controllers_interface/scripts/start_controller.py, I got the following error and did not start the controller.

fetch@fetch1075:~/ros/melodic/src/fetchrobotics/robot_controllers/robot_controllers_interface$ rosrun robot_controllers_interface stop_controller.py arm_controller/follow_joint_trajectory
[INFO] [WallTime: 1636960585.632305] [node:/stop_robot_controllers] [func:<module>]: Connecting to /query_controller_states...
[INFO] [WallTime: 1636960585.794209] [node:/stop_robot_controllers] [func:<module>]: Done.
[INFO] [WallTime: 1636960585.795474] [node:/stop_robot_controllers] [func:<module>]: Requesting that arm_controller/follow_joint_trajectory be stopped...
[INFO] [WallTime: 1636960585.797601] [node:/stop_robot_controllers] [func:<module>]: Done.
fetch@fetch1075:~/ros/melodic/src/fetchrobotics/robot_controllers/robot_controllers_interface$ rosrun robot_controllers_interface start_controller.py arm_controller/follow_joint_trajectory 
[INFO] [WallTime: 1636960615.499979] [node:/start_robot_controllers] [func:<module>]: Connecting to /query_controller_states...
[INFO] [WallTime: 1636960615.754447] [node:/start_robot_controllers] [func:<module>]: Done.
[INFO] [WallTime: 1636960615.756414] [node:/start_robot_controllers] [func:<module>]: Requesting that arm_controller/follow_joint_trajectory be started...
[ERROR] [WallTime: 1636960615.759133] [node:/start_robot_controllers] [func:<module>]: Unable to start arm_controller/follow_joint_trajectory

/var/log/ros/robot.log output

[ERROR] [1636960615.757763468] [/robot_driver:ros.robot_controllers.FollowJointTrajectoryController]: Unable to start, action server is not active.

https://github.com/fetchrobotics/robot_controllers/blob/010855f0e6a8e058a1cbd2ad69c324cd97f0d815/robot_controllers/src/follow_joint_trajectory.cpp#L145-L150 I wonder if checking isActive() is proper when starting contollers. I think isActive() shows status whether an active goal already exists or not. https://github.com/ros/actionlib/blob/10025114a28d94581b6fac68bd391eb2a1bc3d32/include/actionlib/server/simple_action_server_imp.h#L227-L236

Cc:@708yamaguchi @knorth55

mikeferguson commented 2 years ago

This is actually the expected behavior:

Some other controllers really should keep running all the time (base controller for instance publishes odometry, and you want that all the time, so the controller runs all the time) and so they can actually be started via script without commanding a goal.

tkmtnt7000 commented 2 years ago

Thank you for your prompt response. I understand this is the expected behavior. I learned a lot.

What I was trying to do is moving freely from gravity compensation mode to position control mode and vice versa via script. I wondered why opposite commands do not start the controller and sending a trajectory is needed to start the controller, but now I clearly understand the reason.

Thanks a lot !