mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Fixed FRCSim artf2619, and misc reformatting.
Change-Id: I7133f46f88f7e2cb2451c2a6714daa8f3f368b40
This commit is contained in:
@@ -10,43 +10,42 @@ using namespace gazebo;
|
||||
class MainNode {
|
||||
public:
|
||||
static MainNode* GetInstance() {
|
||||
if (instance == NULL) {
|
||||
if (instance == NULL) {
|
||||
instance = new MainNode();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
template<typename M>
|
||||
static transport::PublisherPtr Advertise(const std::string &topic,
|
||||
template<typename M>
|
||||
static transport::PublisherPtr Advertise(const std::string &topic,
|
||||
unsigned int _queueLimit = 10,
|
||||
bool _latch = false) {
|
||||
return GetInstance()->main->Advertise<M>(topic, _queueLimit, _latch);
|
||||
return GetInstance()->main->Advertise<M>(topic, _queueLimit, _latch);
|
||||
}
|
||||
|
||||
template<typename M, typename T>
|
||||
static transport::SubscriberPtr Subscribe(const std::string &topic,
|
||||
template<typename M, typename T>
|
||||
static transport::SubscriberPtr Subscribe(const std::string &topic,
|
||||
void(T::*fp)(const boost::shared_ptr<M const> &), T *obj,
|
||||
bool _latching = false) {
|
||||
return GetInstance()->main->Subscribe(topic, fp, obj, _latching);
|
||||
return GetInstance()->main->Subscribe(topic, fp, obj, _latching);
|
||||
}
|
||||
|
||||
template<typename M>
|
||||
static transport::SubscriberPtr Subscribe(const std::string &topic,
|
||||
template<typename M>
|
||||
static transport::SubscriberPtr Subscribe(const std::string &topic,
|
||||
void(*fp)(const boost::shared_ptr<M const> &),
|
||||
bool _latching = false) {
|
||||
return GetInstance()->main->Subscribe(topic, fp, _latching);
|
||||
}
|
||||
return GetInstance()->main->Subscribe(topic, fp, _latching);
|
||||
}
|
||||
|
||||
transport::NodePtr main;
|
||||
transport::NodePtr main;
|
||||
private:
|
||||
static MainNode* instance;
|
||||
|
||||
MainNode() {
|
||||
gazebo::transport::init();
|
||||
main = transport::NodePtr(new transport::Node());
|
||||
main->Init("frc");
|
||||
gazebo::transport::run();
|
||||
gazebo::transport::init();
|
||||
main = transport::NodePtr(new transport::Node());
|
||||
main->Init("frc");
|
||||
gazebo::transport::run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "simulation/msgs/msgs.h"
|
||||
#include <gazebo/transport/transport.hh>
|
||||
#include <gazebo/common/Time.hh>
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
@@ -12,20 +13,20 @@ class SimEncoder {
|
||||
public:
|
||||
SimEncoder(std::string topic);
|
||||
|
||||
void Reset();
|
||||
void Start();
|
||||
void Stop();
|
||||
double GetPosition();
|
||||
double GetVelocity();
|
||||
|
||||
void Reset();
|
||||
void Start();
|
||||
void Stop();
|
||||
double GetPosition();
|
||||
double GetVelocity();
|
||||
|
||||
private:
|
||||
void sendCommand(std::string cmd);
|
||||
|
||||
double position, velocity;
|
||||
transport::SubscriberPtr posSub, velSub;
|
||||
transport::PublisherPtr commandPub;
|
||||
void positionCallback(const msgs::ConstFloat64Ptr &msg);
|
||||
void velocityCallback(const msgs::ConstFloat64Ptr &msg);
|
||||
void sendCommand(std::string cmd);
|
||||
|
||||
double position, velocity;
|
||||
transport::SubscriberPtr posSub, velSub;
|
||||
transport::PublisherPtr commandPub;
|
||||
void positionCallback(const msgs::ConstFloat64Ptr &msg);
|
||||
void velocityCallback(const msgs::ConstFloat64Ptr &msg);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user