Skip to content

Commit

Permalink
Merge pull request roboticsgroup#8 from roboticsgroup/formatting
Browse files Browse the repository at this point in the history
Formatting
  • Loading branch information
costashatz authored Mar 7, 2017
2 parents e6311c3 + 87cfc86 commit ad291e1
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 246 deletions.
49 changes: 23 additions & 26 deletions include/roboticsgroup_gazebo_plugins/disable_link_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ Redistribution and use in source and binary forms, with or without modification,
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/

Expand All @@ -35,33 +35,30 @@ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISE
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>

namespace gazebo
{
class DisableLinkPlugin : public ModelPlugin
{
namespace gazebo {
class DisableLinkPlugin : public ModelPlugin {
public:
DisableLinkPlugin();
~DisableLinkPlugin();
DisableLinkPlugin();
~DisableLinkPlugin();

void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);
void UpdateChild();
void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);
void UpdateChild();

private:
// Parameters
std::string link_name_;
// Parameters
std::string link_name_;

bool kill_sim;
bool kill_sim;

// Pointers to the joints
physics::LinkPtr link_;
// Pointers to the joints
physics::LinkPtr link_;

// Pointer to the model
physics::ModelPtr model_;
// Pointer to the model
physics::ModelPtr model_;

// Pointer to the world
physics::WorldPtr world_;

};
// Pointer to the world
physics::WorldPtr world_;
};
}

#endif
61 changes: 29 additions & 32 deletions include/roboticsgroup_gazebo_plugins/mimic_joint_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ Redistribution and use in source and binary forms, with or without modification,
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/

Expand All @@ -38,41 +38,38 @@ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISE
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>

namespace gazebo
{
class MimicJointPlugin : public ModelPlugin
{
namespace gazebo {
class MimicJointPlugin : public ModelPlugin {
public:
MimicJointPlugin();
~MimicJointPlugin();
MimicJointPlugin();
~MimicJointPlugin();

void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);
void UpdateChild();
void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);
void UpdateChild();

private:
// Parameters
std::string joint_name_, mimic_joint_name_, robot_namespace_;
double multiplier_, offset_, sensitiveness_, max_effort_;
bool has_pid_;
// Parameters
std::string joint_name_, mimic_joint_name_, robot_namespace_;
double multiplier_, offset_, sensitiveness_, max_effort_;
bool has_pid_;

bool kill_sim;
bool kill_sim;

// PID controller if needed
control_toolbox::Pid pid_;
// PID controller if needed
control_toolbox::Pid pid_;

// Pointers to the joints
physics::JointPtr joint_, mimic_joint_;
// Pointers to the joints
physics::JointPtr joint_, mimic_joint_;

// Pointer to the model
physics::ModelPtr model_;
// Pointer to the model
physics::ModelPtr model_;

// Pointer to the world
physics::WorldPtr world_;
// Pointer to the world
physics::WorldPtr world_;

// Pointer to the update event connection
event::ConnectionPtr updateConnection;

};
// Pointer to the update event connection
event::ConnectionPtr updateConnection;
};
}

#endif
76 changes: 38 additions & 38 deletions src/disable_link_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,59 @@ Redistribution and use in source and binary forms, with or without modification,
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/

#include <roboticsgroup_gazebo_plugins/disable_link_plugin.h>

namespace gazebo
{
namespace gazebo {

DisableLinkPlugin::DisableLinkPlugin()
{
kill_sim = false;
DisableLinkPlugin::DisableLinkPlugin()
{
kill_sim = false;

link_.reset();
}
link_.reset();
}

DisableLinkPlugin::~DisableLinkPlugin()
{
kill_sim = true;
}
DisableLinkPlugin::~DisableLinkPlugin()
{
kill_sim = true;
}

void DisableLinkPlugin::Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf )
{
model_ = _parent;
world_ = model_->GetWorld();
void DisableLinkPlugin::Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
{
model_ = _parent;
world_ = model_->GetWorld();

// Check for link element
if (!_sdf->HasElement("link"))
{
ROS_ERROR("No link element present. DisableLinkPlugin could not be loaded.");
return;
}

link_name_ = _sdf->GetElement("link")->Get<std::string>();
// Check for link element
if (!_sdf->HasElement("link")) {
ROS_ERROR("No link element present. DisableLinkPlugin could not be loaded.");
return;
}

// Get pointers to joints
link_ = model_->GetLink(link_name_);
if(link_)
link_->SetEnabled(false);
else
ROS_WARN("Link %s not found!", link_name_.c_str());
}
link_name_ = _sdf->GetElement("link")->Get<std::string>();

GZ_REGISTER_MODEL_PLUGIN(DisableLinkPlugin);
// Get pointers to joints
link_ = model_->GetLink(link_name_);
if (link_) {
link_->SetEnabled(false);
// Output some confirmation
ROS_INFO_STREAM("DisableLinkPlugin loaded! Link: \"" << link_name_);
}
else
ROS_ERROR_STREAM("Link" << link_name_ << " not found! DisableLinkPlugin could not be loaded.");
}

GZ_REGISTER_MODEL_PLUGIN(DisableLinkPlugin);
}
Loading

0 comments on commit ad291e1

Please sign in to comment.