Skip to content

Commit

Permalink
Don't crash if a wrong config was detected (#324) (#330)
Browse files Browse the repository at this point in the history
(cherry picked from commit ec1b958)

Co-authored-by: Christoph Fröhlich <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
3 people authored Jun 10, 2024
1 parent 37d48b2 commit df5a81f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ign_ros2_control/src/ign_ros2_control_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ IgnitionROS2ControlPlugin::IgnitionROS2ControlPlugin()
IgnitionROS2ControlPlugin::~IgnitionROS2ControlPlugin()
{
// Stop controller manager thread
if (!this->dataPtr->controller_manager_) {
return;
}
this->dataPtr->executor_->remove_node(this->dataPtr->controller_manager_);
this->dataPtr->executor_->cancel();
this->dataPtr->thread_executor_spin_.join();
Expand Down Expand Up @@ -483,6 +486,9 @@ void IgnitionROS2ControlPlugin::PreUpdate(
const ignition::gazebo::UpdateInfo & _info,
ignition::gazebo::EntityComponentManager & /*_ecm*/)
{
if (!this->dataPtr->controller_manager_) {
return;
}
static bool warned{false};
if (!warned) {
rclcpp::Duration gazebo_period(_info.dt);
Expand Down Expand Up @@ -517,6 +523,9 @@ void IgnitionROS2ControlPlugin::PostUpdate(
const ignition::gazebo::UpdateInfo & _info,
const ignition::gazebo::EntityComponentManager & /*_ecm*/)
{
if (!this->dataPtr->controller_manager_) {
return;
}
// Get the simulation time and period
rclcpp::Time sim_time_ros(std::chrono::duration_cast<std::chrono::nanoseconds>(
_info.simTime).count(), RCL_ROS_TIME);
Expand Down

0 comments on commit df5a81f

Please sign in to comment.