mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
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:
committed by
Peter Johnson
parent
68690643d2
commit
e14e45da76
@@ -7,12 +7,12 @@
|
||||
|
||||
#include "external_limit_switch.h"
|
||||
|
||||
|
||||
ExternalLimitSwitch::ExternalLimitSwitch(sdf::ElementPtr sdf) {
|
||||
sensor = boost::dynamic_pointer_cast<sensors::ContactSensor>(
|
||||
sensors::get_sensor(sdf->Get<std::string>("sensor")));
|
||||
sensors::get_sensor(sdf->Get<std::string>("sensor")));
|
||||
|
||||
gzmsg << "\texternal limit switch: " << " sensor=" << sensor->GetName() << std::endl;
|
||||
gzmsg << "\texternal limit switch: "
|
||||
<< " sensor=" << sensor->GetName() << std::endl;
|
||||
}
|
||||
|
||||
ExternalLimitSwitch::~ExternalLimitSwitch() {}
|
||||
|
||||
@@ -10,23 +10,23 @@
|
||||
#include "switch.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Winsock2.h>
|
||||
#include <Winsock2.h>
|
||||
#endif
|
||||
|
||||
#include <gazebo/sensors/sensors.hh>
|
||||
#include <boost/pointer_cast.hpp>
|
||||
#include <gazebo/gazebo.hh>
|
||||
#include <gazebo/sensors/sensors.hh>
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
class ExternalLimitSwitch : public Switch {
|
||||
public:
|
||||
public:
|
||||
ExternalLimitSwitch(sdf::ElementPtr sdf);
|
||||
~ExternalLimitSwitch();
|
||||
|
||||
/// \brief Returns true when the switch is triggered.
|
||||
virtual bool Get();
|
||||
|
||||
private:
|
||||
private:
|
||||
sensors::ContactSensorPtr sensor;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
#include "internal_limit_switch.h"
|
||||
|
||||
InternalLimitSwitch::InternalLimitSwitch(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
InternalLimitSwitch::InternalLimitSwitch(physics::ModelPtr model,
|
||||
sdf::ElementPtr sdf) {
|
||||
joint = model->GetJoint(sdf->Get<std::string>("joint"));
|
||||
min = sdf->Get<double>("min");
|
||||
max = sdf->Get<double>("max");
|
||||
@@ -18,8 +19,9 @@ InternalLimitSwitch::InternalLimitSwitch(physics::ModelPtr model, sdf::ElementPt
|
||||
radians = true;
|
||||
}
|
||||
|
||||
gzmsg << "\tinternal limit switch: " << " type=" << joint->GetName()
|
||||
<< " range=[" << min << "," << max << "] radians=" << radians << std::endl;
|
||||
gzmsg << "\tinternal limit switch: "
|
||||
<< " type=" << joint->GetName() << " range=[" << min << "," << max
|
||||
<< "] radians=" << radians << std::endl;
|
||||
}
|
||||
|
||||
InternalLimitSwitch::~InternalLimitSwitch() {}
|
||||
|
||||
@@ -10,22 +10,22 @@
|
||||
#include "switch.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Winsock2.h>
|
||||
#include <Winsock2.h>
|
||||
#endif
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/gazebo.hh>
|
||||
#include <gazebo/physics/physics.hh>
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
class InternalLimitSwitch : public Switch {
|
||||
public:
|
||||
public:
|
||||
InternalLimitSwitch(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
~InternalLimitSwitch();
|
||||
|
||||
/// \brief Returns true when the switch is triggered.
|
||||
virtual bool Get();
|
||||
|
||||
private:
|
||||
private:
|
||||
physics::JointPtr joint;
|
||||
double min, max;
|
||||
bool radians;
|
||||
|
||||
@@ -20,11 +20,12 @@ void LimitSwitch::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();
|
||||
}
|
||||
std::string type = sdf->Get<std::string>("type");
|
||||
|
||||
gzmsg << "Initializing limit switch: " << topic << " type=" << type << std::endl;
|
||||
gzmsg << "Initializing limit switch: " << topic << " type=" << type
|
||||
<< std::endl;
|
||||
if (type == "internal") {
|
||||
ls = new InternalLimitSwitch(model, sdf);
|
||||
} else if (type == "external") {
|
||||
@@ -34,7 +35,8 @@ void LimitSwitch::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
}
|
||||
|
||||
// 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);
|
||||
@@ -42,10 +44,11 @@ void LimitSwitch::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(&LimitSwitch::Update, this, _1));
|
||||
updateConn = event::Events::ConnectWorldUpdateBegin(
|
||||
boost::bind(&LimitSwitch::Update, this, _1));
|
||||
}
|
||||
|
||||
void LimitSwitch::Update(const common::UpdateInfo &info) {
|
||||
void LimitSwitch::Update(const common::UpdateInfo& info) {
|
||||
msgs::Bool msg;
|
||||
msg.set_data(ls->Get());
|
||||
pub->Publish(msg);
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
|
||||
#include "switch.h"
|
||||
|
||||
#include "internal_limit_switch.h"
|
||||
#include "external_limit_switch.h"
|
||||
#include "internal_limit_switch.h"
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
@@ -66,8 +66,8 @@ using namespace gazebo;
|
||||
* External
|
||||
* - `sensor`: Name of the contact sensor that this limit switch uses.
|
||||
*/
|
||||
class LimitSwitch: public ModelPlugin {
|
||||
public:
|
||||
class LimitSwitch : public ModelPlugin {
|
||||
public:
|
||||
LimitSwitch();
|
||||
~LimitSwitch();
|
||||
|
||||
@@ -75,18 +75,18 @@ public:
|
||||
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
|
||||
/// \brief Sends out the limit switch reading each timestep.
|
||||
void Update(const common::UpdateInfo &info);
|
||||
void Update(const common::UpdateInfo& info);
|
||||
|
||||
private:
|
||||
private:
|
||||
/// \brief Publish the limit switch value on this topic.
|
||||
std::string topic;
|
||||
|
||||
/// \brief LimitSwitch object, currently internal or external.
|
||||
Switch* ls;
|
||||
|
||||
|
||||
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::PublisherPtr pub; ///< \brief Publisher 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::PublisherPtr pub; ///< \brief Publisher handle.
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
class Switch {
|
||||
public:
|
||||
public:
|
||||
virtual ~Switch() {}
|
||||
|
||||
/// \brief Returns true when the switch is triggered.
|
||||
|
||||
Reference in New Issue
Block a user