Didn’t realize it was an external package, thanks.
Your code works for me in simulation on Linux, though I haven’t exercised it more than just running it and switching between modes.
The segmentation faults that you’re experiencing are a result of python destroying an object that the underlying C++ code is trying to use. I fixed a bunch of them that your code triggered in robotpy-commands-v1 2020.2.2.3.
There are a variety of ways this error can occur. The most common pattern is creating an object and passing it directly to a function:
Instead, if you store the object somewhere:
self.command = Command()
Then python won’t destroy the object.
Obviously, RobotPy should be ‘doing the right thing’ and not destroying the underlying object. However, the design of the command framework makes this difficult at times – but I am trying to fix them as they come up. If you can give me specific ways to trigger the crashes (they’re usually fairly deterministic), I can fix them on our end. The python stack traces usually aren’t so helpful, as it’s happening underneath python.