0

Working from the tutorials I wanted to try PID-controlling a second order linear system. I'm running into segfaults when simulating the closed loop. I've put my code over on Gist. It is mostly identical to the example in the dynamical systems tutorial.

Here's what works

  • Simulating a diagram containing only the second order system
  • Dropping in PendulumPlant for the second order system and using the controller
  • Every step up to simulator.AdvanceTo - that's where the segfault occurs

I'm sure I am missing something obvious here. Does anyone with more experience see what's wrong?

pgorczak
  • 31
  • 2

2 Answers2

1

Thanks for reporting this. I didn't see anything on quick inspection. I ran your code (both on linux and mac) and was able to reproduce. Absolutely you should never see a silent segfault, so this is a real issue.

I've escalated it here: https://github.com/RobotLocomotion/drake/issues/12497

FTR - I've also opened a PR to improve the PidController documentation. https://github.com/robotlocomotion/drake/pull/12496

Russ Tedrake
  • 4,703
  • 1
  • 7
  • 10
  • Thanks! I've subscribed to the issue and will be following there. I also checked the PR and can confirm that feedback and reference including velocity wasn't immediately clear when I first used it with the current docs. – pgorczak Dec 18 '19 at 16:23
1

I'm investigating this now -- I've also successfully reproduced the bug locally using the provided python, but I've also reproduced it directly in C++. [Reproduced in now defunct branch]

I'll update when I have something concrete.


Update 1: You've got an algebraic loop in these two systems (one that does not exist for the PendulumPlant as its derivatives and output are expressed in terms of its state and not its inputs). In this case, both systems' outputs depend directly on their inputs so, kablooie! The bug, in this case, is figuring out why that isn't communicated to you right up front.

Presumably, you'd also like to know what the right version of this program is that doesn't have an algebraic loop. Stay tuned.


Final update

A patch has gone through to correct the underlying bug. Depending on how you're accessing Drake, it's immediately available in master, or you can wait for the next binary (as to your taste).

Thanks for bringing this issue to our attention.

Sean Curtis
  • 1,425
  • 7
  • 8
  • Thanks for the hint! Working from `PendulumPlant`, I re-created the same system by inheriting from `LeafSystem` and that one works. I put that on [Gist](https://gist.github.com/pgorczak/0e648b1a827ac4fe5678429a87bf0bf1) too. I'd still be really interested in whether this is a good way to do it, so looking forward to your version! – pgorczak Dec 19 '19 at 16:01