Skip to content

Commit

Permalink
Prefer block commented variable over [[maybe_unused]] attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Oct 18, 2023
1 parent 1689567 commit 24a24ec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
12 changes: 5 additions & 7 deletions mujoco_ros/include/mujoco_ros/plugin_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MujocoPlugin
* @param[in] model pointer to mjModel.
* @param[in] data pointer to mjData.
*/
virtual void controlCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data){};
virtual void controlCallback(mjModelPtr model, mjDataPtr data){};

/**
* @brief Override this function to compute and apply custom passive (i.e. non-controlled) forces.
Expand All @@ -104,7 +104,7 @@ class MujocoPlugin
* @param[in] model pointer to mjModel.
* @param[in] data pointer to mjData.
*/
virtual void passiveCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data){};
virtual void passiveCallback(mjModelPtr model, mjDataPtr data){};

/**
* @brief Override this callback to add custom visualisations to the scene.
Expand All @@ -113,8 +113,7 @@ class MujocoPlugin
* @param[in] data pointer to mjData.
* @param[in] scene pointer to mjvScene.
*/
virtual void renderCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data,
[[maybe_unused]] mjvScene *scene){};
virtual void renderCallback(mjModelPtr model, mjDataPtr data, mjvScene *scene){};

/**
* @brief Override this callback to add custom behavior at the end of a mujoco_ros simulation step.
Expand All @@ -124,7 +123,7 @@ class MujocoPlugin
* @param[in] model pointer to mjModel.
* @param[in] data pointer to mjData.
*/
virtual void lastStageCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data){};
virtual void lastStageCallback(mjModelPtr model, mjDataPtr data){};

/**
* @brief Override this callback to add custom behavior when a geom has been changed in the model.
Expand All @@ -133,8 +132,7 @@ class MujocoPlugin
* @param[in] data pointer to mjData.
* @param[in] geom_id id of the geom thas has been changed.
*/
virtual void onGeomChanged([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data,
[[maybe_unused]] const int geom_id){};
virtual void onGeomChanged(mjModelPtr model, mjDataPtr data, const int geom_id){};

protected:
/**
Expand Down
5 changes: 2 additions & 3 deletions mujoco_ros/src/callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ bool MujocoEnv::setPauseCB(mujoco_ros_msgs::SetPause::Request &req, mujoco_ros_m
return true;
}

bool MujocoEnv::shutdownCB([[maybe_unused]] std_srvs::Empty::Request &req,
[[maybe_unused]] std_srvs::Empty::Response &res)
bool MujocoEnv::shutdownCB(std_srvs::Empty::Request & /*req*/, std_srvs::Empty::Response & /*res*/)
{
ROS_DEBUG("Shutdown requested");
settings_.exit_request.store(1);
Expand Down Expand Up @@ -195,7 +194,7 @@ bool MujocoEnv::reloadCB(mujoco_ros_msgs::Reload::Request &req, mujoco_ros_msgs:
return true;
}

bool MujocoEnv::resetCB([[maybe_unused]] std_srvs::Empty::Request &req, [[maybe_unused]] std_srvs::Empty::Response &res)
bool MujocoEnv::resetCB(std_srvs::Empty::Request & /*req*/, std_srvs::Empty::Response & /*res*/)
{
ROS_DEBUG("Reset requested");
settings_.reset_request.store(1);
Expand Down
12 changes: 5 additions & 7 deletions mujoco_ros/test/test_plugin/test_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,27 @@ void TestPlugin::reset()
ran_reset.store(true);
}

void TestPlugin::controlCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data)
void TestPlugin::controlCallback(mjModelPtr /*model*/, mjDataPtr /*data*/)
{
ran_control_cb.store(true);
}

void TestPlugin::passiveCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data)
void TestPlugin::passiveCallback(mjModelPtr /*model*/, mjDataPtr /*data*/)
{
ran_passive_cb.store(true);
}

void TestPlugin::renderCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data,
[[maybe_unused]] mjvScene *scene)
void TestPlugin::renderCallback(mjModelPtr /*model*/, mjDataPtr /*data*/, mjvScene * /*scene*/)
{
ran_render_cb.store(true);
}

void TestPlugin::lastStageCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data)
void TestPlugin::lastStageCallback(mjModelPtr /*model*/, mjDataPtr /*data*/)
{
ran_last_cb.store(true);
}

void TestPlugin::onGeomChanged([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data,
[[maybe_unused]] const int geom_id)
void TestPlugin::onGeomChanged(mjModelPtr /*model*/, mjDataPtr /*data*/, const /*int*/ geom_id)
{
ran_on_geom_changed_cb.store(true);
}
Expand Down
12 changes: 5 additions & 7 deletions mujoco_ros/test/test_plugin/test_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ class TestPlugin : public MujocoPlugin
virtual ~TestPlugin() {}
virtual bool load(mjModelPtr m, mjDataPtr d) override;
virtual void reset() override;
virtual void controlCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data) override;
virtual void passiveCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data) override;
virtual void renderCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data,
[[maybe_unused]] mjvScene *scene) override;
virtual void lastStageCallback([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data) override;
virtual void onGeomChanged([[maybe_unused]] mjModelPtr model, [[maybe_unused]] mjDataPtr data,
[[maybe_unused]] const int geom_id) override;
virtual void controlCallback(mjModelPtr model, mjDataPtr data) override;
virtual void passiveCallback(mjModelPtr model, mjDataPtr data) override;
virtual void renderCallback(mjModelPtr model, mjDataPtr data, mjvScene *scene) override;
virtual void lastStageCallback(mjModelPtr model, mjDataPtr data) override;
virtual void onGeomChanged(mjModelPtr model, mjDataPtr data, const int geom_id) override;

mjModelPtr m_;
mjDataPtr d_;
Expand Down

0 comments on commit 24a24ec

Please sign in to comment.