1

I'm trying to do trajectory optimization for a custom robot I've specified with an sdf file.

I'd like to use direct collocation, but when I try to create the MultibodyPlant with time_step=0.0 I fail with a segfault. It works just fine when I use discrete time (e.g. Multibodyplant(time_step=.005).

However, if I use discrete time, the state is no longer continuous so I can't use direct collocation. So I tried to use direct transcription and I get the error

SystemExit: Failure at bazel-out/k8-opt/bin/systems/framework/_virtual_includes/context/drake/systems/framework/context.h:111 in num_total_states(): condition 'num_abstract_states() == 0' failed.

I think the reason is that DirectTranscription does not have a assume_non_continuous_states_are_fixed, the same issue as in this question: direct transcription for compass gait. So maybe the easiest solution to my problem is to request this feature..

Deirdre
  • 11
  • 2
  • 1
    > but when I try to create the MultibodyPlant with time_step=0.0 I fail with a segfault. That sounds real bad. Would it be possible to have a minimum snippet that reproduces the problem and open an issue on Github? either we have a bug, or at least we should be reporting a better error message? unless the bug is on the client code – Alejandro Jul 14 '20 at 02:10
  • Sure, here's an issue I opened with a code snippet: https://github.com/RobotLocomotion/drake/issues/13678 – Deirdre Jul 14 '20 at 18:32
  • Looks like the code declares the MultibodyPlant to be continuous but then tries to access discrete state variables (which there aren't any). Try accessing the continuous state variables instead. – Sherm Jul 14 '20 at 21:10
  • Ah I understand. Thanks for getting back to me so quickly. – Deirdre Jul 14 '20 at 21:37
  • I also agree that asking for `assume_non_continuous_states_are_fixed` to be implemented in `DirectTranscription` is a completely reasonable request, and may be needed here. Please do open a drake issue about it if you need it. – Russ Tedrake Jul 23 '20 at 10:23

1 Answers1

0

I recommended above that we do add that assume_non_continuous_states_are_fixed to DirectTranscription. But the reason that this option was not implemented already is a little subtle, so I’ll add it here.

It’s not actually MultibodyPlant that is adding the abstract state, but SceneGraph. For dynamics/planning, you only need SceneGraph if you are relying on contact forces in your dynamics. For acrobots / cart-poles, etc, you can already use a MultibodyPlant with DirectTranscription by passing the MBP only (no SceneGraph) to the optimization. And for systems that do make and break contact, I would have said that DirectTranscription might not be the algorithm you want; although there are no hard and fast rules saying it won’t work. It’s just that you’ll end up with stiff differential equations which are hard to transcribe in a reasonable trajectory optimization that doesn’t reason explicitly about the contact.

I think I know your application, which involves wheels that are in contact and stay in contact. That means that you do need SceneGraph. That might be a case were this currently missing combination makes perfect sense, and we should add it.

Russ Tedrake
  • 4,703
  • 1
  • 7
  • 10