RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.17k stars 1.24k forks source link

Support a namedview workflow in C++ #12566

Open RussTedrake opened 4 years ago

RussTedrake commented 4 years ago

In #11191 we introduced this for python.
Possible related to #9171.

Specific need/request: Authoring systems is safer/easier if we can work with structured data (as opposed to a BasicVector). But requiring the port to be a structured type defeats many workflows. For instance, in my AcrobotGeometry PR (coming shortly, will link to this issue), I was fine wiring up the AcrobotPlant to the AcrobotGeometry system if the input port had type AcrobotState<double>, but then I could NOT easily wire up a trajectory playback to visualize the output of trajectory optimization (as done in run_swing_up_traj_optimization.cc.

I think a few sugar methods in the auto-generated *.named_vector workflow would be able to address this easily.

jwnimmer-tri commented 4 years ago

10520 might be a draft to start from.

RussTedrake commented 2 years ago

Note that the "State variables 2.0" doc in #9171, currently also includes the view concept:

// Returns the value of this numerical variable but overlaid with
// a struct to provide named access via members.
template <template<typename> Overlay>
const Overlay<T>& variable.value_overlay<Overlay>(const Context<T>&);

Let's keep these two ideas in sync!