mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +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
@@ -6,17 +6,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#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 "potentiometer.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
|
||||
GZ_REGISTER_MODEL_PLUGIN(Potentiometer)
|
||||
|
||||
@@ -32,7 +31,7 @@ void Potentiometer::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("units")) {
|
||||
@@ -41,11 +40,12 @@ void Potentiometer::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
radians = true;
|
||||
}
|
||||
|
||||
gzmsg << "Initializing potentiometer: " << topic << " joint=" << joint->GetName()
|
||||
<< " radians=" << radians << std::endl;
|
||||
gzmsg << "Initializing potentiometer: " << topic
|
||||
<< " joint=" << joint->GetName() << " radians=" << radians << 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);
|
||||
@@ -53,10 +53,11 @@ void Potentiometer::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(&Potentiometer::Update, this, _1));
|
||||
updateConn = event::Events::ConnectWorldUpdateBegin(
|
||||
boost::bind(&Potentiometer::Update, this, _1));
|
||||
}
|
||||
|
||||
void Potentiometer::Update(const common::UpdateInfo &info) {
|
||||
void Potentiometer::Update(const common::UpdateInfo& info) {
|
||||
joint->GetAngle(0).Normalize();
|
||||
msgs::Float64 msg;
|
||||
if (radians) {
|
||||
|
||||
@@ -32,8 +32,8 @@ using namespace gazebo;
|
||||
* - `topic`: Optional. Message will be published as a gazebo.msgs.Float64.
|
||||
* - `units`: Optional. Defaults to radians.
|
||||
*/
|
||||
class Potentiometer: public ModelPlugin {
|
||||
public:
|
||||
class Potentiometer : public ModelPlugin {
|
||||
public:
|
||||
Potentiometer();
|
||||
~Potentiometer();
|
||||
|
||||
@@ -41,9 +41,9 @@ public:
|
||||
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
|
||||
/// \brief Sends out the potentiometer reading each timestep.
|
||||
void Update(const common::UpdateInfo &info);
|
||||
void Update(const common::UpdateInfo& info);
|
||||
|
||||
private:
|
||||
private:
|
||||
/// \brief Publish the angle on this topic.
|
||||
std::string topic;
|
||||
|
||||
@@ -53,9 +53,9 @@ private:
|
||||
/// \brief The joint that this potentiometer measures
|
||||
physics::JointPtr joint;
|
||||
|
||||
|
||||
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.
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user