Skip to content

Commit

Permalink
[drake_ros] Use new Drake v1.20 systems::Event API
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnimmer-tri committed Aug 14, 2023
1 parent 656bbc7 commit 81b9743
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
6 changes: 1 addition & 5 deletions drake_ros/core/ros_publisher_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ RosPublisherSystem::RosPublisherSystem(

if (publish_triggers.find(drake::systems::TriggerType::kPerStep) !=
publish_triggers.end()) {
DeclarePerStepEvent(drake::systems::PublishEvent<double>(
[this](const drake::systems::Context<double>& context,
const drake::systems::PublishEvent<double>&) {
PublishInput(context);
}));
this->DeclarePerStepPublishEvent(&RosPublisherSystem::PublishInput);
}
// ^^^ Mostly copied from LcmPublisherSystem ^^^
}
Expand Down
28 changes: 14 additions & 14 deletions drake_ros/core/ros_subscriber_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,20 @@ void RosSubscriberSystem::DoCalcNextUpdateTime(

// Create a unrestricted event and tie the handler to the corresponding
// function.
drake::systems::UnrestrictedUpdateEvent<double>::UnrestrictedUpdateCallback
callback = [this, serialized_message{std::move(message)}](
const drake::systems::Context<double>&,
const drake::systems::UnrestrictedUpdateEvent<double>&,
drake::systems::State<double>* state) {
// Deserialize the message and store it in the abstract state on the
// context
drake::systems::AbstractValues& abstract_state =
state->get_mutable_abstract_state();
auto& abstract_value =
abstract_state.get_mutable_value(impl_->message_state_index);
impl_->serializer->Deserialize(*serialized_message, &abstract_value);
return drake::systems::EventStatus::Succeeded();
};
auto callback = [this, serialized_message{std::move(message)}](
const drake::systems::System<double>&,
const drake::systems::Context<double>&,
const drake::systems::UnrestrictedUpdateEvent<double>&,
drake::systems::State<double>* state) {
// Deserialize the message and store it in the abstract state on the
// context.
drake::systems::AbstractValues& abstract_state =
state->get_mutable_abstract_state();
auto& abstract_value =
abstract_state.get_mutable_value(impl_->message_state_index);
impl_->serializer->Deserialize(*serialized_message, &abstract_value);
return drake::systems::EventStatus::Succeeded();
};

// Schedule an update event at the current time.
*time = context.get_time();
Expand Down
6 changes: 3 additions & 3 deletions drake_ros/drake.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DRAKE_SUGGESTED_VERSION = struct(
url = "https://github.com/RobotLocomotion/drake/archive/refs/tags/v1.13.0.tar.gz", # noqa
sha256 = "6fec96a7ffeab586754f1721d21380519edfab2a8a6d2f045d6b92bd30fae6be", # noqa,
strip_prefix = "drake-1.13.0",
url = "https://github.com/RobotLocomotion/drake/archive/refs/tags/v1.20.0.tar.gz", # noqa
sha256 = "0000000000000000000000000000000000000000000000000000000000000000", # noqa,
strip_prefix = "drake-1.20.0",
)

0 comments on commit 81b9743

Please sign in to comment.