Add format script which invokes clang-format on the C++ source code (#41)

On Windows machines, clang-format.exe must be in the PATH environment variable.
This commit is contained in:
Tyler Veness
2016-05-20 17:30:37 -07:00
committed by Peter Johnson
parent 68690643d2
commit e14e45da76
383 changed files with 13787 additions and 13198 deletions

View File

@@ -6,9 +6,9 @@
/*----------------------------------------------------------------------------*/
#ifdef _WIN32
// Ensure that Winsock2.h is included before Windows.h, which can get
// pulled in by anybody (e.g., Boost).
#include <Winsock2.h>
// Ensure that Winsock2.h is included before Windows.h, which can get
// pulled in by anybody (e.g., Boost).
#include <Winsock2.h>
#endif
#include "pneumatic_piston.h"
@@ -31,23 +31,25 @@ void PneumaticPiston::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
if (sdf->HasElement("topic")) {
topic = sdf->Get<std::string>("topic");
} else {
topic = "~/"+sdf->GetAttribute("name")->GetAsString();
topic = "~/" + sdf->GetAttribute("name")->GetAsString();
}
forward_force = sdf->Get<double>("forward-force");
reverse_force = sdf->Get<double>("reverse-force");
if (sdf->HasElement("direction") && sdf->Get<std::string>("direction") == "reversed") {
if (sdf->HasElement("direction") &&
sdf->Get<std::string>("direction") == "reversed") {
forward_force = -forward_force;
reverse_force = -reverse_force;
}
gzmsg << "Initializing piston: " << topic << " joint=" << joint->GetName()
<< " forward_force=" << forward_force
<< " reverse_force=" << reverse_force<< std::endl;
<< " reverse_force=" << reverse_force << std::endl;
// Connect to Gazebo transport for messaging
std::string scoped_name = model->GetWorld()->GetName()+"::"+model->GetScopedName();
std::string scoped_name =
model->GetWorld()->GetName() + "::" + model->GetScopedName();
boost::replace_all(scoped_name, "::", "/");
node = transport::NodePtr(new transport::Node());
node->Init(scoped_name);
@@ -55,14 +57,18 @@ void PneumaticPiston::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
// Connect to the world update event.
// This will trigger the Update function every Gazebo iteration
updateConn = event::Events::ConnectWorldUpdateBegin(boost::bind(&PneumaticPiston::Update, this, _1));
updateConn = event::Events::ConnectWorldUpdateBegin(
boost::bind(&PneumaticPiston::Update, this, _1));
}
void PneumaticPiston::Update(const common::UpdateInfo &info) {
void PneumaticPiston::Update(const common::UpdateInfo& info) {
joint->SetForce(0, signal);
}
void PneumaticPiston::Callback(const msgs::ConstFloat64Ptr &msg) {
if (msg->data() < -0.001) { signal = -reverse_force; }
else if (msg->data() > 0.001) { signal = forward_force; }
void PneumaticPiston::Callback(const msgs::ConstFloat64Ptr& msg) {
if (msg->data() < -0.001) {
signal = -reverse_force;
} else if (msg->data() > 0.001) {
signal = forward_force;
}
}

View File

@@ -47,8 +47,8 @@ using namespace gazebo;
*
* \todo Signal should probably be made a tri-state message.
*/
class PneumaticPiston: public ModelPlugin {
public:
class PneumaticPiston : public ModelPlugin {
public:
PneumaticPiston();
~PneumaticPiston();
@@ -56,9 +56,9 @@ public:
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
/// \brief Updat the force the piston applies on the joint.
void Update(const common::UpdateInfo &info);
void Update(const common::UpdateInfo& info);
private:
private:
/// \brief Topic to read control signal from.
std::string topic;
@@ -72,11 +72,11 @@ private:
physics::JointPtr joint;
/// \brief Callback for receiving msgs and updating the torque.
void Callback(const msgs::ConstFloat64Ptr &msg);
void Callback(const msgs::ConstFloat64Ptr& msg);
physics::ModelPtr model; ///< \brief The model that this is attached to.
event::ConnectionPtr updateConn; ///< \brief Pointer to the world update function.
transport::NodePtr node; ///< \brief The node we're advertising on.
transport::SubscriberPtr sub; ///< \brief Subscriber handle.
physics::ModelPtr model; ///< \brief The model that this is attached to.
event::ConnectionPtr
updateConn; ///< \brief Pointer to the world update function.
transport::NodePtr node; ///< \brief The node we're advertising on.
transport::SubscriberPtr sub; ///< \brief Subscriber handle.
};