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

@@ -22,7 +22,7 @@ void DCMotor::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();
}
if (sdf->HasElement("multiplier")) {
@@ -35,7 +35,8 @@ void DCMotor::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
<< " multiplier=" << multiplier << 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);
@@ -43,15 +44,19 @@ void DCMotor::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(&DCMotor::Update, this, _1));
updateConn = event::Events::ConnectWorldUpdateBegin(
boost::bind(&DCMotor::Update, this, _1));
}
void DCMotor::Update(const common::UpdateInfo &info) {
joint->SetForce(0, signal*multiplier);
void DCMotor::Update(const common::UpdateInfo& info) {
joint->SetForce(0, signal * multiplier);
}
void DCMotor::Callback(const msgs::ConstFloat64Ptr &msg) {
void DCMotor::Callback(const msgs::ConstFloat64Ptr& msg) {
signal = msg->data();
if (signal < -1) { signal = -1; }
else if (signal > 1) { signal = 1; }
if (signal < -1) {
signal = -1;
} else if (signal > 1) {
signal = 1;
}
}

View File

@@ -9,12 +9,9 @@
#include "simulation/gz_msgs/msgs.h"
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/transport/transport.hh>
#include <gazebo/gazebo.hh>
using namespace gazebo;
@@ -38,8 +35,8 @@ using namespace gazebo;
* - `topic`: Optional. Message type should be gazebo.msgs.Float64.
* - `multiplier`: Optional. Defaults to 1.
*/
class DCMotor: public ModelPlugin {
public:
class DCMotor : public ModelPlugin {
public:
DCMotor();
~DCMotor();
@@ -47,9 +44,9 @@ public:
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
/// \brief Update the torque on the joint from the dc motor each timestep.
void Update(const common::UpdateInfo &info);
void Update(const common::UpdateInfo& info);
private:
private:
/// \brief Topic to read control signal from.
std::string topic;
@@ -63,11 +60,11 @@ private:
physics::JointPtr joint;
/// \brief Callback for receiving msgs and storing the signal.
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.
};