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

[jtc] Required time for controller update increases over the course of trajectory #1293

Open
RobertWilbrandt opened this issue Sep 24, 2024 · 3 comments · May be fixed by #1297
Open

[jtc] Required time for controller update increases over the course of trajectory #1293

RobertWilbrandt opened this issue Sep 24, 2024 · 3 comments · May be fixed by #1297
Labels

Comments

@RobertWilbrandt
Copy link
Contributor

Describe the bug
When executing very long trajectories (order: >100.000 points), the time jtc spends in update() rises over the course of execution. This gradually decreases the time spent spent sleeping in the control node until the control loop can no longer keep up and the control frequency drops.

After being pointed to the Trajectory::sample() function by @fmauch i was able to confirm that this is the cause for the observed issue. In every control cycle, the trajectory is traversed linearly until the relevant trajectory points for sampling at the current time step are found.

To Reproduce
Steps to reproduce the behavior:

  1. Take any system running a JTC and send a very long trajectory to it.
  2. Monitor the time spent in the jtc update() function

Expected behavior
The time spent in update() should stay at a constant level from the start to the end of trajectory execution.

Screenshots

The problem became evident when working on a new hardware interface and executing a trajectory of ~220.000 points over ~900 seconds. While the execution starts correctly, after some time the update rate decreases to a level at which not every control cycle for the communication thread can get a command from the hardware interface, leading to excessive vibrations.

Using lttng, i traced the calls to the hardware interface write() functions and could plot the following progression:

jtc_timing_before

The large spike seen at ~120s is the start of the trajectory. At ~290s all headroom in the control loop is exhausted and the control frequency starts dropping. At ~375s i had to stop the robot as i did not want to damage any joints.

Environment (please complete the following information):

  • OS: Ubuntu 24.04 noble
  • Version: Current master branch, built from source

Additional context
I will post a PR that uses binary search for finding the currently relevant trajectory points and could solve this problem for me. As other options could be lower overhead than that (e.g. keeping track of the current index in the trajectory during execution), i went ahead and created this issue first.

I am aware that this is probably not a common use case for the JTC, but this could also pose problems on more ressource constrained systems or when running multiple different controllers side-by-side.

@gavanderhoorn
Copy link
Contributor

#474?

@RobertWilbrandt
Copy link
Contributor Author

Thanks, i only looked at issues before and didn't see that pr.

As discussed in the WG meeting today, it makes more sense to go with a solution like that as there is no need to ever access a trajectory in a not monotonically increasing manner.

@jodle001
Copy link

jodle001 commented Sep 25, 2024

I can confirm this issue is happening for a trajectory that I am running. CPU usage climbs as a very long trajectory is executing.

@RobertWilbrandt RobertWilbrandt linked a pull request Sep 26, 2024 that will close this issue
@christophfroehlich christophfroehlich linked a pull request Sep 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants