ros-controls / ros_controllers

Generic robotic controllers to accompany ros_control
http://wiki.ros.org/ros_control
BSD 3-Clause "New" or "Revised" License
560 stars 526 forks source link

joint_trajectory_controller setHoldPosition could lead to unexpected delay in RT loop when called from inside of RT thread #598

Open farshbafdoustar opened 2 years ago

farshbafdoustar commented 2 years ago

The curr_trajectorybox.set(hold_trajectoryptr); in setHoldPosition is putting the hold_trajectoryptr in the box. If the pointer already in the box, is the last pointer to the current trajectory, the memory pointed by the pointer will be released after the set function. This could lead to an unexpected delay if the current trajectory in the box is a big QuinticSplineSegment (ex. 500 points).

I encountered this delay when I tried to setHoldPosition in update method of my custom controller inherited from joint_trajectory_controller. Have I missed sth?

One workaround could be having a private extra pointer , pointing to the current trajectory in the box and resetting it in a non-RT thread (service call or goalCB). But then it is in opposite to the box concept. Any idea?