Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save david-german-tri/c9093c9be532fcd70f1dbb82c6431148 to your computer and use it in GitHub Desktop.
Save david-german-tri/c9093c9be532fcd70f1dbb82c6431148 to your computer and use it in GitHub Desktop.
HandlePublish
auto diagram_context = dynamic_cast<const DiagramContext<T>*>(&context);
DRAKE_DEMAND(diagram_context != nullptr);
for (const auto& action : sub_actions) {
const int index = action.first;
const UpdateActions<T>& action_details = action.second;
DRAKE_DEMAND(index >= 0 && index < num_subsystems());
const Context<T>* subcontext =
diagram_context->GetSubsystemContext(index);
DRAKE_DEMAND(subcontext != nullptr);
for (const DiscreteEvent<T>& event : action_details.events) {
if (event.action == DiscreteEvent<T>::kPublishAction) {
sorted_systems_[index]->Publish(*subcontext, event);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment