mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
Removed modules from the simulation infrastructure and refactored FRCPlugin.
Pneumatics still have CAN modules. The refactored code is now eight plugins for sensors and actuators. There is some code reuse that should be refactored out, but that level of abstraction will wait until we figure out how these plugins are integrating with gazebo proper. Change-Id: I357e695ef05af6dda83a39ba60380686bd57d11a Closes: artf2610, artf2623
This commit is contained in:
committed by
Alex Henning
parent
3b4718fc92
commit
8ae64a12ea
3
simulation/frc_gazebo_plugins/.gitignore
vendored
Normal file
3
simulation/frc_gazebo_plugins/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
plugins/
|
||||
build/
|
||||
docs/
|
||||
48
simulation/frc_gazebo_plugins/Makefile
Normal file
48
simulation/frc_gazebo_plugins/Makefile
Normal file
@@ -0,0 +1,48 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
.PHONY : all build copy-plugins clean docs clean-docs
|
||||
|
||||
all: build copy-plugins
|
||||
|
||||
build:
|
||||
cd msgs && make
|
||||
cd dc_motor && make
|
||||
cd pneumatic_piston && make
|
||||
cd potentiometer && make
|
||||
cd rangefinder && make
|
||||
cd encoder && make
|
||||
cd gyro && make
|
||||
cd limit_switch && make
|
||||
cd clock && make
|
||||
|
||||
copy-plugins:
|
||||
mkdir -p plugins
|
||||
cp dc_motor/build/libgz_dc_motor.so plugins
|
||||
cp pneumatic_piston/build/libgz_pneumatic_piston.so plugins
|
||||
cp potentiometer/build/libgz_potentiometer.so plugins
|
||||
cp rangefinder/build/libgz_rangefinder.so plugins
|
||||
cp encoder/build/libgz_encoder.so plugins
|
||||
cp gyro/build/libgz_gyro.so plugins
|
||||
cp limit_switch/build/libgz_limit_switch.so plugins
|
||||
cp clock/build/libgz_clock.so plugins
|
||||
|
||||
clean: clean-docs
|
||||
cd msgs && make clean
|
||||
cd dc_motor && make clean
|
||||
cd pneumatic_piston && make clean
|
||||
cd potentiometer && make clean
|
||||
cd rangefinder && make clean
|
||||
cd encoder && make clean
|
||||
cd gyro && make clean
|
||||
cd limit_switch && make clean
|
||||
cd clock && make clean
|
||||
-rm -r plugins
|
||||
|
||||
docs:
|
||||
doxygen frc_gazebo_plugins.doxy
|
||||
|
||||
clean-docs:
|
||||
-rm -r docs
|
||||
17
simulation/frc_gazebo_plugins/clock/CMakeLists.txt
Normal file
17
simulation/frc_gazebo_plugins/clock/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(gz_clock)
|
||||
|
||||
include (FindPkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GAZEBO gazebo)
|
||||
endif()
|
||||
|
||||
find_package(gazebo REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp)
|
||||
file(GLOB_RECURSE MSG_FILES ../msgs/src/*.cc)
|
||||
include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src)
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${MSG_FILES})
|
||||
|
||||
link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build)
|
||||
target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES})
|
||||
15
simulation/frc_gazebo_plugins/clock/Makefile
Normal file
15
simulation/frc_gazebo_plugins/clock/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
all:
|
||||
mkdir -p $(build.dir)
|
||||
cd ${build.dir} && cmake .. && make
|
||||
|
||||
clean:
|
||||
rm -rf $(build.dir)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(plugin.dir)
|
||||
install $(build.dir)/libgz_clock.so $(DESTDIR)$(plugin.dir)
|
||||
42
simulation/frc_gazebo_plugins/clock/src/clock.cpp
Normal file
42
simulation/frc_gazebo_plugins/clock/src/clock.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "clock.h"
|
||||
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
|
||||
#include "msgs/msgs.h"
|
||||
|
||||
GZ_REGISTER_MODEL_PLUGIN(Clock)
|
||||
|
||||
Clock::Clock() {}
|
||||
|
||||
Clock::~Clock() {}
|
||||
|
||||
void Clock::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
this->model = model;
|
||||
|
||||
// Parse SDF properties
|
||||
if (sdf->HasElement("topic")) {
|
||||
topic = sdf->Get<std::string>("topic");
|
||||
} else {
|
||||
topic = "~/"+sdf->GetAttribute("name")->GetAsString();
|
||||
}
|
||||
|
||||
gzmsg << "Initializing clock: " << topic << std::endl;
|
||||
|
||||
// Connect to Gazebo transport for messaging
|
||||
std::string scoped_name = model->GetWorld()->GetName()+"::"+model->GetScopedName();
|
||||
boost::replace_all(scoped_name, "::", "/");
|
||||
node = transport::NodePtr(new transport::Node());
|
||||
node->Init(scoped_name);
|
||||
pub = node->Advertise<msgs::Float64>(topic);
|
||||
|
||||
// Connect to the world update event.
|
||||
// This will trigger the Update function every Gazebo iteration
|
||||
updateConn = event::Events::ConnectWorldUpdateBegin(boost::bind(&Clock::Update, this, _1));
|
||||
}
|
||||
|
||||
void Clock::Update(const common::UpdateInfo &info) {
|
||||
msgs::Float64 msg;
|
||||
msg.set_data(info.simTime.Double());
|
||||
pub->Publish(msg);
|
||||
}
|
||||
42
simulation/frc_gazebo_plugins/clock/src/clock.h
Normal file
42
simulation/frc_gazebo_plugins/clock/src/clock.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
/**
|
||||
* \brief Plugin for publishing the simulation time.
|
||||
*
|
||||
* This plugin publishes the simualtaion time in seconds every physics
|
||||
* update.
|
||||
*
|
||||
* To add a clock to your robot, add the following XML to your robot
|
||||
* model:
|
||||
*
|
||||
* <plugin name="my_clock" filename="libgz_clock.so">
|
||||
* <topic>~/my/topic</topic>
|
||||
* </plugin>
|
||||
*
|
||||
* - `topic`: Optional. Message will be published as a gazebo.msgs.Float64.
|
||||
*
|
||||
* \todo Make WorldPlugin?
|
||||
*/
|
||||
class Clock: public ModelPlugin {
|
||||
public:
|
||||
Clock();
|
||||
~Clock();
|
||||
|
||||
/// \brief Load the clock and configures it according to the sdf.
|
||||
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
|
||||
/// \brief Sends out time each timestep.
|
||||
void Update(const common::UpdateInfo &info);
|
||||
|
||||
private:
|
||||
std::string topic; ///< \brief Publish the time on this topic.
|
||||
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.
|
||||
};
|
||||
|
||||
17
simulation/frc_gazebo_plugins/dc_motor/CMakeLists.txt
Normal file
17
simulation/frc_gazebo_plugins/dc_motor/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(gz_dc_motor)
|
||||
|
||||
include (FindPkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GAZEBO gazebo)
|
||||
endif()
|
||||
|
||||
find_package(gazebo REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp)
|
||||
file(GLOB_RECURSE MSG_FILES ../msgs/src/*.cc)
|
||||
include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src)
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${MSG_FILES})
|
||||
|
||||
link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build)
|
||||
target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES})
|
||||
15
simulation/frc_gazebo_plugins/dc_motor/Makefile
Normal file
15
simulation/frc_gazebo_plugins/dc_motor/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
all:
|
||||
mkdir -p $(build.dir)
|
||||
cd ${build.dir} && cmake .. && make
|
||||
|
||||
clean:
|
||||
rm -rf $(build.dir)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(plugin.dir)
|
||||
install $(build.dir)/libgz_dc_motor.so $(DESTDIR)$(plugin.dir)
|
||||
53
simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.cpp
Normal file
53
simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "dc_motor.h"
|
||||
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
|
||||
GZ_REGISTER_MODEL_PLUGIN(DCMotor)
|
||||
|
||||
DCMotor::DCMotor() {}
|
||||
|
||||
DCMotor::~DCMotor() {}
|
||||
|
||||
void DCMotor::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
this->model = model;
|
||||
signal = 0;
|
||||
|
||||
// Parse SDF properties
|
||||
joint = model->GetJoint(sdf->Get<std::string>("joint"));
|
||||
if (sdf->HasElement("topic")) {
|
||||
topic = sdf->Get<std::string>("topic");
|
||||
} else {
|
||||
topic = "~/"+sdf->GetAttribute("name")->GetAsString();
|
||||
}
|
||||
|
||||
if (sdf->HasElement("multiplier")) {
|
||||
multiplier = sdf->Get<double>("multiplier");
|
||||
} else {
|
||||
multiplier = 1;
|
||||
}
|
||||
|
||||
gzmsg << "Initializing motor: " << topic << " joint=" << joint->GetName()
|
||||
<< " multiplier=" << multiplier << std::endl;
|
||||
|
||||
// Connect to Gazebo transport for messaging
|
||||
std::string scoped_name = model->GetWorld()->GetName()+"::"+model->GetScopedName();
|
||||
boost::replace_all(scoped_name, "::", "/");
|
||||
node = transport::NodePtr(new transport::Node());
|
||||
node->Init(scoped_name);
|
||||
sub = node->Subscribe(topic, &DCMotor::Callback, this);
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
void DCMotor::Update(const common::UpdateInfo &info) {
|
||||
joint->SetForce(0, signal*multiplier);
|
||||
}
|
||||
|
||||
void DCMotor::Callback(const msgs::ConstFloat64Ptr &msg) {
|
||||
signal = msg->data();
|
||||
if (signal < -1) { signal = -1; }
|
||||
else if (signal > 1) { signal = 1; }
|
||||
}
|
||||
61
simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.h
Normal file
61
simulation/frc_gazebo_plugins/dc_motor/src/dc_motor.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
#include "msgs/msgs.h"
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
/**
|
||||
* \brief Plugin for controlling a joint with a DC motor.
|
||||
*
|
||||
* This plugin subscribes to a topic to get a signal in the range
|
||||
* [-1,1]. Every physics update the joint's torque is set as
|
||||
* multiplier*signal.
|
||||
*
|
||||
* To add a DC motor to your robot, add the following XML to your
|
||||
* robot model:
|
||||
*
|
||||
* <plugin name="my_motor" filename="libgz_dc_motor.so">
|
||||
* <joint>Joint Name</joint>
|
||||
* <topic>~/my/topic</topic>
|
||||
* <multiplier>Number</multiplier>
|
||||
* </plugin>
|
||||
*
|
||||
* - `joint`: Name of the joint this Dc motor is attached to.
|
||||
* - `topic`: Optional. Message type should be gazebo.msgs.Float64.
|
||||
* - `multiplier`: Optional. Defaults to 1.
|
||||
*/
|
||||
class DCMotor: public ModelPlugin {
|
||||
public:
|
||||
DCMotor();
|
||||
~DCMotor();
|
||||
|
||||
/// \brief Load the dc motor and configures it according to the sdf.
|
||||
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);
|
||||
|
||||
private:
|
||||
/// \brief Topic to read control signal from.
|
||||
std::string topic;
|
||||
|
||||
/// \brief The pwm signal limited to the range [-1,1].
|
||||
double signal;
|
||||
|
||||
/// \brief The magic torque multiplier. torque=multiplier*signal
|
||||
double multiplier;
|
||||
|
||||
/// \brief The joint that this dc motor drives.
|
||||
physics::JointPtr joint;
|
||||
|
||||
/// \brief Callback for receiving msgs and storing the signal.
|
||||
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.
|
||||
};
|
||||
17
simulation/frc_gazebo_plugins/encoder/CMakeLists.txt
Normal file
17
simulation/frc_gazebo_plugins/encoder/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(gz_encoder)
|
||||
|
||||
include (FindPkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GAZEBO gazebo)
|
||||
endif()
|
||||
|
||||
find_package(gazebo REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp)
|
||||
file(GLOB_RECURSE MSG_FILES ../msgs/src/*.cc)
|
||||
include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src)
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${MSG_FILES})
|
||||
|
||||
link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build)
|
||||
target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES})
|
||||
15
simulation/frc_gazebo_plugins/encoder/Makefile
Normal file
15
simulation/frc_gazebo_plugins/encoder/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
all:
|
||||
mkdir -p $(build.dir)
|
||||
cd ${build.dir} && cmake .. && make
|
||||
|
||||
clean:
|
||||
rm -rf $(build.dir)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(plugin.dir)
|
||||
install $(build.dir)/libgz_encoder.so $(DESTDIR)$(plugin.dir)
|
||||
94
simulation/frc_gazebo_plugins/encoder/src/encoder.cpp
Normal file
94
simulation/frc_gazebo_plugins/encoder/src/encoder.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
#include "encoder.h"
|
||||
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
|
||||
GZ_REGISTER_MODEL_PLUGIN(Encoder)
|
||||
|
||||
Encoder::Encoder() {}
|
||||
|
||||
Encoder::~Encoder() {}
|
||||
|
||||
void Encoder::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
this->model = model;
|
||||
|
||||
// Parse SDF properties
|
||||
joint = model->GetJoint(sdf->Get<std::string>("joint"));
|
||||
if (sdf->HasElement("topic")) {
|
||||
topic = sdf->Get<std::string>("topic");
|
||||
} else {
|
||||
topic = "~/"+sdf->GetAttribute("name")->GetAsString();
|
||||
}
|
||||
|
||||
if (sdf->HasElement("units")) {
|
||||
radians = sdf->Get<std::string>("units") != "degrees";
|
||||
} else {
|
||||
radians = true;
|
||||
}
|
||||
zero = GetAngle();
|
||||
stopped = true;
|
||||
stop_value = 0;
|
||||
|
||||
gzmsg << "Initializing encoder: " << topic << " joint=" << joint->GetName()
|
||||
<< " radians=" << radians << std::endl;
|
||||
|
||||
// Connect to Gazebo transport for messaging
|
||||
std::string scoped_name = model->GetWorld()->GetName()+"::"+model->GetScopedName();
|
||||
boost::replace_all(scoped_name, "::", "/");
|
||||
node = transport::NodePtr(new transport::Node());
|
||||
node->Init(scoped_name);
|
||||
command_sub = node->Subscribe(topic+"/control", &Encoder::Callback, this);
|
||||
pos_pub = node->Advertise<msgs::Float64>(topic+"/position");
|
||||
vel_pub = node->Advertise<msgs::Float64>(topic+"/velocity");
|
||||
|
||||
// Connect to the world update event.
|
||||
// This will trigger the Update function every Gazebo iteration
|
||||
updateConn = event::Events::ConnectWorldUpdateBegin(boost::bind(&Encoder::Update, this, _1));
|
||||
}
|
||||
|
||||
void Encoder::Update(const common::UpdateInfo &info) {
|
||||
msgs::Float64 pos_msg, vel_msg;
|
||||
if (stopped) {
|
||||
pos_msg.set_data(stop_value);
|
||||
pos_pub->Publish(pos_msg);
|
||||
vel_msg.set_data(0);
|
||||
vel_pub->Publish(vel_msg);
|
||||
} else {
|
||||
pos_msg.set_data(GetAngle() - zero);
|
||||
pos_pub->Publish(pos_msg);
|
||||
vel_msg.set_data(GetVelocity());
|
||||
vel_pub->Publish(vel_msg);
|
||||
}
|
||||
}
|
||||
|
||||
void Encoder::Callback(const msgs::ConstStringPtr &msg) {
|
||||
std::string command = msg->data();
|
||||
if (command == "reset") {
|
||||
zero = GetAngle();
|
||||
} else if (command == "start") {
|
||||
stopped = false;
|
||||
zero = (GetAngle() - stop_value);
|
||||
} else if (command == "stop") {
|
||||
stopped = true;
|
||||
stop_value = GetAngle();
|
||||
} else {
|
||||
gzerr << "WARNING: Encoder got unknown command '" << command << "'." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
double Encoder::GetAngle() {
|
||||
if (radians) {
|
||||
return joint->GetAngle(0).Radian();
|
||||
} else {
|
||||
return joint->GetAngle(0).Degree();
|
||||
}
|
||||
}
|
||||
|
||||
double Encoder::GetVelocity() {
|
||||
if (radians) {
|
||||
return joint->GetVelocity(0);
|
||||
} else {
|
||||
return joint->GetVelocity(0) * (180.0 / M_PI);
|
||||
}
|
||||
}
|
||||
|
||||
81
simulation/frc_gazebo_plugins/encoder/src/encoder.h
Normal file
81
simulation/frc_gazebo_plugins/encoder/src/encoder.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
#include "msgs/msgs.h"
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
/**
|
||||
* \brief Plugin for reading the speed and relative angle of a joint.
|
||||
*
|
||||
* This plugin publishes the angle since last reset and the speed of a
|
||||
* given joint to subtopics of the given topic every physics
|
||||
* update. There is also a control subtopic that takes three commands:
|
||||
* "start", "stop" and "reset":
|
||||
*
|
||||
* - "start": Start counting ticks from the current count.
|
||||
* - "stop": Stop counting ticks, pauses updates.
|
||||
* - "reset": Set the current angle to zero.
|
||||
*
|
||||
* To add a encoder to your robot, add the following XML to your
|
||||
* robot model:
|
||||
*
|
||||
* <plugin name="my_encoder" filename="libgz_encoder.so">
|
||||
* <joint>Joint Name</joint>
|
||||
* <topic>~/my/topic</topic>
|
||||
* <units>{degrees, radians}</units>
|
||||
* </plugin>
|
||||
*
|
||||
* - `joint`: Name of the joint this encoder is attached to.
|
||||
* - `topic`: Optional. Used as the root for subtopics. `topic`/position (gazebo.msgs.Float64),
|
||||
* `topic`/velocity (gazebo.msgs.Float64), `topic`/control (gazebo.msgs.String)
|
||||
* - `units`: Optional. Defaults to radians.
|
||||
*/
|
||||
class Encoder: public ModelPlugin {
|
||||
public:
|
||||
Encoder();
|
||||
~Encoder();
|
||||
|
||||
/// \brief Load the encoder and configures it according to the sdf.
|
||||
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
|
||||
/// \brief Sends out the encoder reading each timestep.
|
||||
void Update(const common::UpdateInfo &info);
|
||||
|
||||
private:
|
||||
/// \brief Root topic for subtopics on this topic.
|
||||
std::string topic;
|
||||
|
||||
/// \brief Whether or not this encoder measures radians or degrees.
|
||||
bool radians;
|
||||
|
||||
/// \brief Whether or not the encoder has been stopped.
|
||||
bool stopped;
|
||||
|
||||
/// \brief The zero value of the encoder.
|
||||
double zero;
|
||||
|
||||
/// \brief The value the encoder stopped counting at
|
||||
double stop_value;
|
||||
|
||||
/// \brief The joint that this encoder measures
|
||||
physics::JointPtr joint;
|
||||
|
||||
/// \brief Callback for handling control data
|
||||
void Callback(const msgs::ConstStringPtr &msg);
|
||||
|
||||
/// \brief Gets the current angle, taking into account whether to
|
||||
/// return radians or degrees.
|
||||
double GetAngle();
|
||||
|
||||
/// \brief Gets the current velocity, taking into account whether to
|
||||
/// return radians/second or degrees/second.
|
||||
double GetVelocity();
|
||||
|
||||
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 command_sub; ///< \brief Subscriber handle.
|
||||
transport::PublisherPtr pos_pub, vel_pub; ///< \brief Publisher handles.
|
||||
};
|
||||
2303
simulation/frc_gazebo_plugins/frc_gazebo_plugins.doxy
Normal file
2303
simulation/frc_gazebo_plugins/frc_gazebo_plugins.doxy
Normal file
File diff suppressed because it is too large
Load Diff
17
simulation/frc_gazebo_plugins/gyro/CMakeLists.txt
Normal file
17
simulation/frc_gazebo_plugins/gyro/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(gz_gyro)
|
||||
|
||||
include (FindPkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GAZEBO gazebo)
|
||||
endif()
|
||||
|
||||
find_package(gazebo REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp)
|
||||
file(GLOB_RECURSE MSG_FILES ../msgs/src/*.cc)
|
||||
include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src)
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${MSG_FILES})
|
||||
|
||||
link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build)
|
||||
target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES})
|
||||
15
simulation/frc_gazebo_plugins/gyro/Makefile
Normal file
15
simulation/frc_gazebo_plugins/gyro/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
all:
|
||||
mkdir -p $(build.dir)
|
||||
cd ${build.dir} && cmake .. && make
|
||||
|
||||
clean:
|
||||
rm -rf $(build.dir)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(plugin.dir)
|
||||
install $(build.dir)/libgz_gyro.so $(DESTDIR)$(plugin.dir)
|
||||
100
simulation/frc_gazebo_plugins/gyro/src/gyro.cpp
Normal file
100
simulation/frc_gazebo_plugins/gyro/src/gyro.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#include "gyro.h"
|
||||
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
|
||||
GZ_REGISTER_MODEL_PLUGIN(Gyro)
|
||||
|
||||
Gyro::Gyro() {}
|
||||
|
||||
Gyro::~Gyro() {}
|
||||
|
||||
void Gyro::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
this->model = model;
|
||||
|
||||
// Parse SDF properties
|
||||
link = model->GetLink(sdf->Get<std::string>("link"));
|
||||
if (sdf->HasElement("topic")) {
|
||||
topic = sdf->Get<std::string>("topic");
|
||||
} else {
|
||||
topic = "~/"+sdf->GetAttribute("name")->GetAsString();
|
||||
}
|
||||
|
||||
std::string axisString = sdf->Get<std::string>("axis");
|
||||
if (axisString == "roll") axis = Roll;
|
||||
if (axisString == "pitch") axis = Pitch;
|
||||
if (axisString == "yaw") axis = Yaw;
|
||||
|
||||
if (sdf->HasElement("units")) {
|
||||
radians = sdf->Get<std::string>("units") != "degrees";
|
||||
} else {
|
||||
radians = true;
|
||||
}
|
||||
zero = GetAngle();
|
||||
|
||||
gzmsg << "Initializing gyro: " << topic << " link=" << link->GetName()
|
||||
<< " axis=" << axis << " radians=" << radians << std::endl;
|
||||
|
||||
// Connect to Gazebo transport for messaging
|
||||
std::string scoped_name = model->GetWorld()->GetName()+"::"+model->GetScopedName();
|
||||
boost::replace_all(scoped_name, "::", "/");
|
||||
node = transport::NodePtr(new transport::Node());
|
||||
node->Init(scoped_name);
|
||||
command_sub = node->Subscribe(topic+"/control", &Gyro::Callback, this);
|
||||
pos_pub = node->Advertise<msgs::Float64>(topic+"/position");
|
||||
vel_pub = node->Advertise<msgs::Float64>(topic+"/velocity");
|
||||
|
||||
// Connect to the world update event.
|
||||
// This will trigger the Update function every Gazebo iteration
|
||||
updateConn = event::Events::ConnectWorldUpdateBegin(boost::bind(&Gyro::Update, this, _1));
|
||||
}
|
||||
|
||||
void Gyro::Update(const common::UpdateInfo &info) {
|
||||
msgs::Float64 pos_msg, vel_msg;
|
||||
pos_msg.set_data(Limit(GetAngle() - zero));
|
||||
pos_pub->Publish(pos_msg);
|
||||
vel_msg.set_data(GetVelocity());
|
||||
vel_pub->Publish(vel_msg);
|
||||
}
|
||||
|
||||
void Gyro::Callback(const msgs::ConstStringPtr &msg) {
|
||||
std::string command = msg->data();
|
||||
if (command == "reset") {
|
||||
zero = GetAngle();
|
||||
} else {
|
||||
gzerr << "WARNING: Gyro got unknown command '" << command << "'." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
double Gyro::GetAngle() {
|
||||
if (radians) {
|
||||
return link->GetWorldCoGPose().rot.GetAsEuler()[axis];
|
||||
} else {
|
||||
return link->GetWorldCoGPose().rot.GetAsEuler()[axis] * (180.0 / M_PI);
|
||||
}
|
||||
}
|
||||
|
||||
double Gyro::GetVelocity() {
|
||||
if (radians) {
|
||||
return link->GetRelativeAngularVel()[axis];
|
||||
} else {
|
||||
return link->GetRelativeAngularVel()[axis] * (180.0 / M_PI);
|
||||
}
|
||||
}
|
||||
|
||||
double Gyro::Limit(double value) {
|
||||
if (radians) {
|
||||
while (true) {
|
||||
if (value < -M_PI) value += 2*M_PI;
|
||||
else if (value > M_PI) value -= 2*M_PI;
|
||||
else break;
|
||||
}
|
||||
} else {
|
||||
while (true) {
|
||||
if (value < -180) value += 360;
|
||||
else if (value > 180) value -= 360;
|
||||
else break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
81
simulation/frc_gazebo_plugins/gyro/src/gyro.h
Normal file
81
simulation/frc_gazebo_plugins/gyro/src/gyro.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
#include "msgs/msgs.h"
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
/// \brief The axis about which to measure rotation.
|
||||
typedef enum {Roll /*X*/, Pitch /*Y*/, Yaw /*Z*/} ROTATION;
|
||||
|
||||
/**
|
||||
* \brief Plugin for reading the speed and relative angle of a link.
|
||||
*
|
||||
* This plugin publishes the angle since last reset and the speed
|
||||
* which a link is rotating about some axis to subtopics of the given
|
||||
* topic every physics update. There is also a control topic that
|
||||
* takes one command: "reset", which sets the current angle as zero.
|
||||
*
|
||||
* To add a gyro to your robot, add the following XML to your robot
|
||||
* model:
|
||||
*
|
||||
* <plugin name="my_gyro" filename="libgz_gyro.so">
|
||||
* <link>Joint Name</link>
|
||||
* <topic>~/my/topic</topic>
|
||||
* <units>{degrees, radians}</units>
|
||||
* </plugin>
|
||||
*
|
||||
* - `link`: Name of the link this potentiometer is attached to.
|
||||
* - `topic`: Optional. Used as the root for subtopics. `topic`/position (gazebo.msgs.Float64),
|
||||
* `topic`/velocity (gazebo.msgs.Float64), `topic`/control (gazebo.msgs.String)
|
||||
* - `units`; Optional, defaults to radians.
|
||||
*/
|
||||
class Gyro: public ModelPlugin {
|
||||
public:
|
||||
Gyro();
|
||||
~Gyro();
|
||||
|
||||
/// \brief Load the gyro and configures it according to the sdf.
|
||||
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
|
||||
/// \brief Sends out the gyro reading each timestep.
|
||||
void Update(const common::UpdateInfo &info);
|
||||
|
||||
private:
|
||||
/// \brief Publish the angle on this topic.
|
||||
std::string topic;
|
||||
|
||||
/// \brief Whether or not this gyro measures radians or degrees.
|
||||
bool radians;
|
||||
|
||||
/// \brief The axis to measure rotation about.
|
||||
ROTATION axis;
|
||||
|
||||
/// \brief The zero value of the gyro.
|
||||
double zero;
|
||||
|
||||
/// \brief The link that this gyro measures
|
||||
physics::LinkPtr link;
|
||||
|
||||
/// \brief Callback for handling control data
|
||||
void Callback(const msgs::ConstStringPtr &msg);
|
||||
|
||||
/// \brief Gets the current angle, taking into account whether to
|
||||
/// return radians or degrees.
|
||||
double GetAngle();
|
||||
|
||||
/// \brief Gets the current velocity, taking into account whether to
|
||||
/// return radians/second or degrees/second.
|
||||
double GetVelocity();
|
||||
|
||||
/// \brief Limit the value to either [-180,180] or [-PI,PI]
|
||||
/// depending on whether or radians or degrees are being used.
|
||||
double Limit(double value);
|
||||
|
||||
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 command_sub; ///< \brief Subscriber handle.
|
||||
transport::PublisherPtr pos_pub, vel_pub; ///< \brief Publisher handles.
|
||||
};
|
||||
17
simulation/frc_gazebo_plugins/limit_switch/CMakeLists.txt
Normal file
17
simulation/frc_gazebo_plugins/limit_switch/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(gz_limit_switch)
|
||||
|
||||
include (FindPkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GAZEBO gazebo)
|
||||
endif()
|
||||
|
||||
find_package(gazebo REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp)
|
||||
file(GLOB_RECURSE MSG_FILES ../msgs/src/*.cc)
|
||||
include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src)
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${MSG_FILES})
|
||||
|
||||
link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build)
|
||||
target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES})
|
||||
15
simulation/frc_gazebo_plugins/limit_switch/Makefile
Normal file
15
simulation/frc_gazebo_plugins/limit_switch/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
all:
|
||||
mkdir -p $(build.dir)
|
||||
cd ${build.dir} && cmake .. && make
|
||||
|
||||
clean:
|
||||
rm -rf $(build.dir)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(plugin.dir)
|
||||
install $(build.dir)/libgz_limit_switch.so $(DESTDIR)$(plugin.dir)
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "external_limit_switch.h"
|
||||
|
||||
#include <gazebo/sensors/sensors.hh>
|
||||
#include <boost/pointer_cast.hpp>
|
||||
|
||||
ExternalLimitSwitch::ExternalLimitSwitch(sdf::ElementPtr sdf) {
|
||||
sensor = boost::dynamic_pointer_cast<sensors::ContactSensor>(
|
||||
sensors::get_sensor(sdf->Get<std::string>("sensor")));
|
||||
|
||||
gzmsg << "\texternal limit switch: " << " sensor=" << sensor->GetName() << std::endl;
|
||||
}
|
||||
|
||||
ExternalLimitSwitch::~ExternalLimitSwitch() {}
|
||||
|
||||
bool ExternalLimitSwitch::Get() {
|
||||
return sensor->GetContacts().contact().size() > 0;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
#include "switch.h"
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
class ExternalLimitSwitch : public Switch {
|
||||
public:
|
||||
ExternalLimitSwitch(sdf::ElementPtr sdf);
|
||||
~ExternalLimitSwitch();
|
||||
|
||||
/// \brief Returns true when the switch is triggered.
|
||||
virtual bool Get();
|
||||
|
||||
private:
|
||||
sensors::ContactSensorPtr sensor;
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "internal_limit_switch.h"
|
||||
|
||||
#include <gazebo/physics/physics.hh>
|
||||
|
||||
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");
|
||||
|
||||
if (sdf->HasElement("units")) {
|
||||
radians = sdf->Get<std::string>("units") != "degrees";
|
||||
} else {
|
||||
radians = true;
|
||||
}
|
||||
|
||||
gzmsg << "\tinternal limit switch: " << " type=" << joint->GetName()
|
||||
<< " range=[" << min << "," << max << "] radians=" << radians << std::endl;
|
||||
}
|
||||
|
||||
InternalLimitSwitch::~InternalLimitSwitch() {}
|
||||
|
||||
bool InternalLimitSwitch::Get() {
|
||||
double value;
|
||||
joint->GetAngle(0).Normalize();
|
||||
if (radians) {
|
||||
value = joint->GetAngle(0).Radian();
|
||||
} else {
|
||||
value = joint->GetAngle(0).Degree();
|
||||
}
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
#include "switch.h"
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
class InternalLimitSwitch : public Switch {
|
||||
public:
|
||||
InternalLimitSwitch(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
~InternalLimitSwitch();
|
||||
|
||||
/// \brief Returns true when the switch is triggered.
|
||||
virtual bool Get();
|
||||
|
||||
private:
|
||||
physics::JointPtr joint;
|
||||
double min, max;
|
||||
bool radians;
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "limit_switch.h"
|
||||
#include "internal_limit_switch.h"
|
||||
#include "external_limit_switch.h"
|
||||
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
|
||||
#include "msgs/msgs.h"
|
||||
|
||||
GZ_REGISTER_MODEL_PLUGIN(LimitSwitch)
|
||||
|
||||
LimitSwitch::LimitSwitch() {}
|
||||
|
||||
LimitSwitch::~LimitSwitch() {}
|
||||
|
||||
void LimitSwitch::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
this->model = model;
|
||||
|
||||
// Parse SDF properties
|
||||
if (sdf->HasElement("topic")) {
|
||||
topic = sdf->Get<std::string>("topic");
|
||||
} else {
|
||||
topic = "~/"+sdf->GetAttribute("name")->GetAsString();
|
||||
}
|
||||
std::string type = sdf->Get<std::string>("type");
|
||||
|
||||
gzmsg << "Initializing limit switch: " << topic << " type=" << type << std::endl;
|
||||
if (type == "internal") {
|
||||
ls = new InternalLimitSwitch(model, sdf);
|
||||
} else if (type == "external") {
|
||||
ls = new ExternalLimitSwitch(sdf);
|
||||
} else {
|
||||
gzerr << "WARNING: unsupported limit switch type " << type;
|
||||
}
|
||||
|
||||
// Connect to Gazebo transport for messaging
|
||||
std::string scoped_name = model->GetWorld()->GetName()+"::"+model->GetScopedName();
|
||||
boost::replace_all(scoped_name, "::", "/");
|
||||
node = transport::NodePtr(new transport::Node());
|
||||
node->Init(scoped_name);
|
||||
pub = node->Advertise<msgs::Bool>(topic);
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
void LimitSwitch::Update(const common::UpdateInfo &info) {
|
||||
msgs::Bool msg;
|
||||
msg.set_data(ls->Get());
|
||||
pub->Publish(msg);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
#include "switch.h"
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
/**
|
||||
* \brief Plugin for reading limit switches.
|
||||
*
|
||||
* This plugin publishes whether or not the limit switch has been
|
||||
* triggered every physics update. There are two types of limit switches:
|
||||
*
|
||||
* - Internal: Measure joint limits. Triggerd if the joint is within
|
||||
* some range.
|
||||
* - External: Measure interactions with the outside world. Triggerd
|
||||
* if some link is in collision.
|
||||
*
|
||||
* To add a limit swithch to your robot, add the following XML to your
|
||||
* robot model.
|
||||
*
|
||||
* Internal:
|
||||
*
|
||||
* <plugin name="my_limit_switch" filename="libgz_limit_switch.so">
|
||||
* <topic>~/my/topic</topic>
|
||||
* <type>internal</type>
|
||||
* <joint>Joint Name</joint>
|
||||
* <units>{degrees, radians}</units>
|
||||
* <min>Number</min>
|
||||
* <max>Number</max>
|
||||
* </plugin>
|
||||
*
|
||||
* External:
|
||||
*
|
||||
* <plugin name="my_limit_switch" filename="libgz_limit_switch.so">
|
||||
* <topic>~/my/topic</topic>
|
||||
* <type>external</type>
|
||||
* <sensor>Sensor Name</sensor>
|
||||
* </plugin>
|
||||
*
|
||||
* Common:
|
||||
* - `topic`: Optional. Message will be published as a gazebo.msgs.Float64.
|
||||
* - `type`: Required. The type of limit switch that this is
|
||||
*
|
||||
* Internal
|
||||
* - `joint`: Name of the joint this potentiometer is attached to.
|
||||
* - `units`: Optional. Defaults to radians.
|
||||
* - `min`: Minimum angle considered triggered.
|
||||
* - `max`: Maximum angle considered triggered.
|
||||
*
|
||||
* External
|
||||
* - `sensor`: Name of the contact sensor that this limit switch uses.
|
||||
*/
|
||||
class LimitSwitch: public ModelPlugin {
|
||||
public:
|
||||
LimitSwitch();
|
||||
~LimitSwitch();
|
||||
|
||||
/// \brief Load the limit switch and configures it according to the sdf.
|
||||
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
|
||||
/// \brief Sends out the limit switch reading each timestep.
|
||||
void Update(const common::UpdateInfo &info);
|
||||
|
||||
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.
|
||||
};
|
||||
9
simulation/frc_gazebo_plugins/limit_switch/src/switch.h
Normal file
9
simulation/frc_gazebo_plugins/limit_switch/src/switch.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
class Switch {
|
||||
public:
|
||||
virtual ~Switch() {}
|
||||
|
||||
/// \brief Returns true when the switch is triggered.
|
||||
virtual bool Get() = 0;
|
||||
};
|
||||
16
simulation/frc_gazebo_plugins/msgs/CMakeLists.txt
Normal file
16
simulation/frc_gazebo_plugins/msgs/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(gz_msgs)
|
||||
|
||||
include (FindPkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GAZEBO gazebo)
|
||||
endif()
|
||||
|
||||
find_package(gazebo REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.cc)
|
||||
include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS})
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
|
||||
|
||||
link_directories(${GAZEBO_LIBRARY_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES})
|
||||
15
simulation/frc_gazebo_plugins/msgs/Makefile
Normal file
15
simulation/frc_gazebo_plugins/msgs/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
all:
|
||||
mkdir -p $(build.dir)
|
||||
cd ${build.dir} && cmake .. && make
|
||||
|
||||
clean:
|
||||
rm -rf $(build.dir)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(plugin.dir)
|
||||
install $(build.dir)/libgz_msgs.so $(DESTDIR)$(plugin.dir)
|
||||
15
simulation/frc_gazebo_plugins/msgs/proto/bool.proto
Normal file
15
simulation/frc_gazebo_plugins/msgs/proto/bool.proto
Normal file
@@ -0,0 +1,15 @@
|
||||
package gazebo.msgs;
|
||||
|
||||
/// \ingroup gazebo_msgs
|
||||
/// \interface Bool
|
||||
/// \brief A message for boolean data
|
||||
/// \verbatim
|
||||
|
||||
option java_outer_classname = "GzBool";
|
||||
|
||||
message Bool
|
||||
{
|
||||
required bool data = 1;
|
||||
}
|
||||
|
||||
/// \endverbatim
|
||||
@@ -0,0 +1,21 @@
|
||||
package gazebo.msgs;
|
||||
|
||||
/// \ingroup gazebo_msgs
|
||||
/// \interface DriverStation
|
||||
/// \brief A message for DriverStation data
|
||||
/// \verbatim
|
||||
|
||||
option java_outer_classname = "GzDriverStation";
|
||||
|
||||
message DriverStation
|
||||
{
|
||||
required bool enabled = 1;
|
||||
enum State {
|
||||
AUTO = 0;
|
||||
TELEOP = 1;
|
||||
TEST = 2;
|
||||
}
|
||||
required State state = 2;
|
||||
}
|
||||
|
||||
/// \endverbatim
|
||||
15
simulation/frc_gazebo_plugins/msgs/proto/float64.proto
Normal file
15
simulation/frc_gazebo_plugins/msgs/proto/float64.proto
Normal file
@@ -0,0 +1,15 @@
|
||||
package gazebo.msgs;
|
||||
|
||||
/// \ingroup gazebo_msgs
|
||||
/// \interface Float64
|
||||
/// \brief A message for floating point data
|
||||
/// \verbatim
|
||||
|
||||
option java_outer_classname = "GzFloat64";
|
||||
|
||||
message Float64
|
||||
{
|
||||
required double data = 1;
|
||||
}
|
||||
|
||||
/// \endverbatim
|
||||
16
simulation/frc_gazebo_plugins/msgs/proto/joystick.proto
Normal file
16
simulation/frc_gazebo_plugins/msgs/proto/joystick.proto
Normal file
@@ -0,0 +1,16 @@
|
||||
package gazebo.msgs;
|
||||
|
||||
/// \ingroup gazebo_msgs
|
||||
/// \interface Joystick
|
||||
/// \brief A message for joystick data
|
||||
/// \verbatim
|
||||
|
||||
option java_outer_classname = "GzJoystick";
|
||||
|
||||
message Joystick
|
||||
{
|
||||
repeated double axes = 1;
|
||||
repeated bool buttons = 2;
|
||||
}
|
||||
|
||||
/// \endverbatim
|
||||
310
simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.cc
Normal file
310
simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.cc
Normal file
@@ -0,0 +1,310 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: msgs/bool.proto
|
||||
|
||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
||||
#include "msgs/bool.pb.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/stubs/once.h>
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/wire_format_lite_inl.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/generated_message_reflection.h>
|
||||
#include <google/protobuf/reflection_ops.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace gazebo {
|
||||
namespace msgs {
|
||||
|
||||
namespace {
|
||||
|
||||
const ::google::protobuf::Descriptor* Bool_descriptor_ = NULL;
|
||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
||||
Bool_reflection_ = NULL;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void protobuf_AssignDesc_msgs_2fbool_2eproto() {
|
||||
protobuf_AddDesc_msgs_2fbool_2eproto();
|
||||
const ::google::protobuf::FileDescriptor* file =
|
||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
||||
"msgs/bool.proto");
|
||||
GOOGLE_CHECK(file != NULL);
|
||||
Bool_descriptor_ = file->message_type(0);
|
||||
static const int Bool_offsets_[1] = {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, data_),
|
||||
};
|
||||
Bool_reflection_ =
|
||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
||||
Bool_descriptor_,
|
||||
Bool::default_instance_,
|
||||
Bool_offsets_,
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, _has_bits_[0]),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, _unknown_fields_),
|
||||
-1,
|
||||
::google::protobuf::DescriptorPool::generated_pool(),
|
||||
::google::protobuf::MessageFactory::generated_factory(),
|
||||
sizeof(Bool));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
||||
inline void protobuf_AssignDescriptorsOnce() {
|
||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
||||
&protobuf_AssignDesc_msgs_2fbool_2eproto);
|
||||
}
|
||||
|
||||
void protobuf_RegisterTypes(const ::std::string&) {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
||||
Bool_descriptor_, &Bool::default_instance());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void protobuf_ShutdownFile_msgs_2fbool_2eproto() {
|
||||
delete Bool::default_instance_;
|
||||
delete Bool_reflection_;
|
||||
}
|
||||
|
||||
void protobuf_AddDesc_msgs_2fbool_2eproto() {
|
||||
static bool already_here = false;
|
||||
if (already_here) return;
|
||||
already_here = true;
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||
"\n\017msgs/bool.proto\022\013gazebo.msgs\"\024\n\004Bool\022\014"
|
||||
"\n\004data\030\001 \002(\010B\010B\006GzBool", 62);
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||
"msgs/bool.proto", &protobuf_RegisterTypes);
|
||||
Bool::default_instance_ = new Bool();
|
||||
Bool::default_instance_->InitAsDefaultInstance();
|
||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2fbool_2eproto);
|
||||
}
|
||||
|
||||
// Force AddDescriptors() to be called at static initialization time.
|
||||
struct StaticDescriptorInitializer_msgs_2fbool_2eproto {
|
||||
StaticDescriptorInitializer_msgs_2fbool_2eproto() {
|
||||
protobuf_AddDesc_msgs_2fbool_2eproto();
|
||||
}
|
||||
} static_descriptor_initializer_msgs_2fbool_2eproto_;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
#ifndef _MSC_VER
|
||||
const int Bool::kDataFieldNumber;
|
||||
#endif // !_MSC_VER
|
||||
|
||||
Bool::Bool()
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
}
|
||||
|
||||
void Bool::InitAsDefaultInstance() {
|
||||
}
|
||||
|
||||
Bool::Bool(const Bool& from)
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void Bool::SharedCtor() {
|
||||
_cached_size_ = 0;
|
||||
data_ = false;
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
}
|
||||
|
||||
Bool::~Bool() {
|
||||
SharedDtor();
|
||||
}
|
||||
|
||||
void Bool::SharedDtor() {
|
||||
if (this != default_instance_) {
|
||||
}
|
||||
}
|
||||
|
||||
void Bool::SetCachedSize(int size) const {
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* Bool::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return Bool_descriptor_;
|
||||
}
|
||||
|
||||
const Bool& Bool::default_instance() {
|
||||
if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fbool_2eproto();
|
||||
return *default_instance_;
|
||||
}
|
||||
|
||||
Bool* Bool::default_instance_ = NULL;
|
||||
|
||||
Bool* Bool::New() const {
|
||||
return new Bool;
|
||||
}
|
||||
|
||||
void Bool::Clear() {
|
||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
data_ = false;
|
||||
}
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
mutable_unknown_fields()->Clear();
|
||||
}
|
||||
|
||||
bool Bool::MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input) {
|
||||
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
|
||||
::google::protobuf::uint32 tag;
|
||||
while ((tag = input->ReadTag()) != 0) {
|
||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
||||
// required bool data = 1;
|
||||
case 1: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
|
||||
input, &data_)));
|
||||
set_has_data();
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectAtEnd()) return true;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
handle_uninterpreted:
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
||||
return true;
|
||||
}
|
||||
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||
input, tag, mutable_unknown_fields()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#undef DO_
|
||||
}
|
||||
|
||||
void Bool::SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const {
|
||||
// required bool data = 1;
|
||||
if (has_data()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteBool(1, this->data(), output);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||
unknown_fields(), output);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::uint8* Bool::SerializeWithCachedSizesToArray(
|
||||
::google::protobuf::uint8* target) const {
|
||||
// required bool data = 1;
|
||||
if (has_data()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->data(), target);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||
unknown_fields(), target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int Bool::ByteSize() const {
|
||||
int total_size = 0;
|
||||
|
||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
// required bool data = 1;
|
||||
if (has_data()) {
|
||||
total_size += 1 + 1;
|
||||
}
|
||||
|
||||
}
|
||||
if (!unknown_fields().empty()) {
|
||||
total_size +=
|
||||
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||
unknown_fields());
|
||||
}
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = total_size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
return total_size;
|
||||
}
|
||||
|
||||
void Bool::MergeFrom(const ::google::protobuf::Message& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
const Bool* source =
|
||||
::google::protobuf::internal::dynamic_cast_if_available<const Bool*>(
|
||||
&from);
|
||||
if (source == NULL) {
|
||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||
} else {
|
||||
MergeFrom(*source);
|
||||
}
|
||||
}
|
||||
|
||||
void Bool::MergeFrom(const Bool& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
if (from.has_data()) {
|
||||
set_data(from.data());
|
||||
}
|
||||
}
|
||||
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
|
||||
}
|
||||
|
||||
void Bool::CopyFrom(const ::google::protobuf::Message& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void Bool::CopyFrom(const Bool& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
bool Bool::IsInitialized() const {
|
||||
if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Bool::Swap(Bool* other) {
|
||||
if (other != this) {
|
||||
std::swap(data_, other->data_);
|
||||
std::swap(_has_bits_[0], other->_has_bits_[0]);
|
||||
_unknown_fields_.Swap(&other->_unknown_fields_);
|
||||
std::swap(_cached_size_, other->_cached_size_);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::Metadata Bool::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::Metadata metadata;
|
||||
metadata.descriptor = Bool_descriptor_;
|
||||
metadata.reflection = Bool_reflection_;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace msgs
|
||||
} // namespace gazebo
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
167
simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.h
Normal file
167
simulation/frc_gazebo_plugins/msgs/src/msgs/bool.pb.h
Normal file
@@ -0,0 +1,167 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: msgs/bool.proto
|
||||
|
||||
#ifndef PROTOBUF_msgs_2fbool_2eproto__INCLUDED
|
||||
#define PROTOBUF_msgs_2fbool_2eproto__INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION < 2005000
|
||||
#error This file was generated by a newer version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please update
|
||||
#error your headers.
|
||||
#endif
|
||||
#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#error This file was generated by an older version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please
|
||||
#error regenerate this file with a newer version of protoc.
|
||||
#endif
|
||||
|
||||
#include <google/protobuf/generated_message_util.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/repeated_field.h>
|
||||
#include <google/protobuf/extension_set.h>
|
||||
#include <google/protobuf/unknown_field_set.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace gazebo {
|
||||
namespace msgs {
|
||||
|
||||
// Internal implementation detail -- do not call these.
|
||||
void protobuf_AddDesc_msgs_2fbool_2eproto();
|
||||
void protobuf_AssignDesc_msgs_2fbool_2eproto();
|
||||
void protobuf_ShutdownFile_msgs_2fbool_2eproto();
|
||||
|
||||
class Bool;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class Bool : public ::google::protobuf::Message {
|
||||
public:
|
||||
Bool();
|
||||
virtual ~Bool();
|
||||
|
||||
Bool(const Bool& from);
|
||||
|
||||
inline Bool& operator=(const Bool& from) {
|
||||
CopyFrom(from);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
||||
return _unknown_fields_;
|
||||
}
|
||||
|
||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
||||
return &_unknown_fields_;
|
||||
}
|
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor();
|
||||
static const Bool& default_instance();
|
||||
|
||||
void Swap(Bool* other);
|
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
Bool* New() const;
|
||||
void CopyFrom(const ::google::protobuf::Message& from);
|
||||
void MergeFrom(const ::google::protobuf::Message& from);
|
||||
void CopyFrom(const Bool& from);
|
||||
void MergeFrom(const Bool& from);
|
||||
void Clear();
|
||||
bool IsInitialized() const;
|
||||
|
||||
int ByteSize() const;
|
||||
bool MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input);
|
||||
void SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const;
|
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
|
||||
int GetCachedSize() const { return _cached_size_; }
|
||||
private:
|
||||
void SharedCtor();
|
||||
void SharedDtor();
|
||||
void SetCachedSize(int size) const;
|
||||
public:
|
||||
|
||||
::google::protobuf::Metadata GetMetadata() const;
|
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// required bool data = 1;
|
||||
inline bool has_data() const;
|
||||
inline void clear_data();
|
||||
static const int kDataFieldNumber = 1;
|
||||
inline bool data() const;
|
||||
inline void set_data(bool value);
|
||||
|
||||
// @@protoc_insertion_point(class_scope:gazebo.msgs.Bool)
|
||||
private:
|
||||
inline void set_has_data();
|
||||
inline void clear_has_data();
|
||||
|
||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
||||
|
||||
bool data_;
|
||||
|
||||
mutable int _cached_size_;
|
||||
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
|
||||
|
||||
friend void protobuf_AddDesc_msgs_2fbool_2eproto();
|
||||
friend void protobuf_AssignDesc_msgs_2fbool_2eproto();
|
||||
friend void protobuf_ShutdownFile_msgs_2fbool_2eproto();
|
||||
|
||||
void InitAsDefaultInstance();
|
||||
static Bool* default_instance_;
|
||||
};
|
||||
// ===================================================================
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// Bool
|
||||
|
||||
// required bool data = 1;
|
||||
inline bool Bool::has_data() const {
|
||||
return (_has_bits_[0] & 0x00000001u) != 0;
|
||||
}
|
||||
inline void Bool::set_has_data() {
|
||||
_has_bits_[0] |= 0x00000001u;
|
||||
}
|
||||
inline void Bool::clear_has_data() {
|
||||
_has_bits_[0] &= ~0x00000001u;
|
||||
}
|
||||
inline void Bool::clear_data() {
|
||||
data_ = false;
|
||||
clear_has_data();
|
||||
}
|
||||
inline bool Bool::data() const {
|
||||
return data_;
|
||||
}
|
||||
inline void Bool::set_data(bool value) {
|
||||
set_has_data();
|
||||
data_ = value;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace msgs
|
||||
} // namespace gazebo
|
||||
|
||||
#ifndef SWIG
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
|
||||
} // namespace google
|
||||
} // namespace protobuf
|
||||
#endif // SWIG
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
#endif // PROTOBUF_msgs_2fbool_2eproto__INCLUDED
|
||||
385
simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.cc
Normal file
385
simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.cc
Normal file
@@ -0,0 +1,385 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: msgs/driver-station.proto
|
||||
|
||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
||||
#include "msgs/driver-station.pb.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/stubs/once.h>
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/wire_format_lite_inl.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/generated_message_reflection.h>
|
||||
#include <google/protobuf/reflection_ops.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace gazebo {
|
||||
namespace msgs {
|
||||
|
||||
namespace {
|
||||
|
||||
const ::google::protobuf::Descriptor* DriverStation_descriptor_ = NULL;
|
||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
||||
DriverStation_reflection_ = NULL;
|
||||
const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor_ = NULL;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto() {
|
||||
protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto();
|
||||
const ::google::protobuf::FileDescriptor* file =
|
||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
||||
"msgs/driver-station.proto");
|
||||
GOOGLE_CHECK(file != NULL);
|
||||
DriverStation_descriptor_ = file->message_type(0);
|
||||
static const int DriverStation_offsets_[2] = {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, enabled_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, state_),
|
||||
};
|
||||
DriverStation_reflection_ =
|
||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
||||
DriverStation_descriptor_,
|
||||
DriverStation::default_instance_,
|
||||
DriverStation_offsets_,
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, _has_bits_[0]),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, _unknown_fields_),
|
||||
-1,
|
||||
::google::protobuf::DescriptorPool::generated_pool(),
|
||||
::google::protobuf::MessageFactory::generated_factory(),
|
||||
sizeof(DriverStation));
|
||||
DriverStation_State_descriptor_ = DriverStation_descriptor_->enum_type(0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
||||
inline void protobuf_AssignDescriptorsOnce() {
|
||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
||||
&protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto);
|
||||
}
|
||||
|
||||
void protobuf_RegisterTypes(const ::std::string&) {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
||||
DriverStation_descriptor_, &DriverStation::default_instance());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto() {
|
||||
delete DriverStation::default_instance_;
|
||||
delete DriverStation_reflection_;
|
||||
}
|
||||
|
||||
void protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto() {
|
||||
static bool already_here = false;
|
||||
if (already_here) return;
|
||||
already_here = true;
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||
"\n\031msgs/driver-station.proto\022\013gazebo.msgs"
|
||||
"\"z\n\rDriverStation\022\017\n\007enabled\030\001 \002(\010\022/\n\005st"
|
||||
"ate\030\002 \002(\0162 .gazebo.msgs.DriverStation.St"
|
||||
"ate\"\'\n\005State\022\010\n\004AUTO\020\000\022\n\n\006TELEOP\020\001\022\010\n\004TE"
|
||||
"ST\020\002B\021B\017GzDriverStation", 183);
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||
"msgs/driver-station.proto", &protobuf_RegisterTypes);
|
||||
DriverStation::default_instance_ = new DriverStation();
|
||||
DriverStation::default_instance_->InitAsDefaultInstance();
|
||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto);
|
||||
}
|
||||
|
||||
// Force AddDescriptors() to be called at static initialization time.
|
||||
struct StaticDescriptorInitializer_msgs_2fdriver_2dstation_2eproto {
|
||||
StaticDescriptorInitializer_msgs_2fdriver_2dstation_2eproto() {
|
||||
protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto();
|
||||
}
|
||||
} static_descriptor_initializer_msgs_2fdriver_2dstation_2eproto_;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return DriverStation_State_descriptor_;
|
||||
}
|
||||
bool DriverStation_State_IsValid(int value) {
|
||||
switch(value) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _MSC_VER
|
||||
const DriverStation_State DriverStation::AUTO;
|
||||
const DriverStation_State DriverStation::TELEOP;
|
||||
const DriverStation_State DriverStation::TEST;
|
||||
const DriverStation_State DriverStation::State_MIN;
|
||||
const DriverStation_State DriverStation::State_MAX;
|
||||
const int DriverStation::State_ARRAYSIZE;
|
||||
#endif // _MSC_VER
|
||||
#ifndef _MSC_VER
|
||||
const int DriverStation::kEnabledFieldNumber;
|
||||
const int DriverStation::kStateFieldNumber;
|
||||
#endif // !_MSC_VER
|
||||
|
||||
DriverStation::DriverStation()
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
}
|
||||
|
||||
void DriverStation::InitAsDefaultInstance() {
|
||||
}
|
||||
|
||||
DriverStation::DriverStation(const DriverStation& from)
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void DriverStation::SharedCtor() {
|
||||
_cached_size_ = 0;
|
||||
enabled_ = false;
|
||||
state_ = 0;
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
}
|
||||
|
||||
DriverStation::~DriverStation() {
|
||||
SharedDtor();
|
||||
}
|
||||
|
||||
void DriverStation::SharedDtor() {
|
||||
if (this != default_instance_) {
|
||||
}
|
||||
}
|
||||
|
||||
void DriverStation::SetCachedSize(int size) const {
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* DriverStation::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return DriverStation_descriptor_;
|
||||
}
|
||||
|
||||
const DriverStation& DriverStation::default_instance() {
|
||||
if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto();
|
||||
return *default_instance_;
|
||||
}
|
||||
|
||||
DriverStation* DriverStation::default_instance_ = NULL;
|
||||
|
||||
DriverStation* DriverStation::New() const {
|
||||
return new DriverStation;
|
||||
}
|
||||
|
||||
void DriverStation::Clear() {
|
||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
enabled_ = false;
|
||||
state_ = 0;
|
||||
}
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
mutable_unknown_fields()->Clear();
|
||||
}
|
||||
|
||||
bool DriverStation::MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input) {
|
||||
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
|
||||
::google::protobuf::uint32 tag;
|
||||
while ((tag = input->ReadTag()) != 0) {
|
||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
||||
// required bool enabled = 1;
|
||||
case 1: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
|
||||
input, &enabled_)));
|
||||
set_has_enabled();
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectTag(16)) goto parse_state;
|
||||
break;
|
||||
}
|
||||
|
||||
// required .gazebo.msgs.DriverStation.State state = 2;
|
||||
case 2: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
||||
parse_state:
|
||||
int value;
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
|
||||
input, &value)));
|
||||
if (::gazebo::msgs::DriverStation_State_IsValid(value)) {
|
||||
set_state(static_cast< ::gazebo::msgs::DriverStation_State >(value));
|
||||
} else {
|
||||
mutable_unknown_fields()->AddVarint(2, value);
|
||||
}
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectAtEnd()) return true;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
handle_uninterpreted:
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
||||
return true;
|
||||
}
|
||||
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||
input, tag, mutable_unknown_fields()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#undef DO_
|
||||
}
|
||||
|
||||
void DriverStation::SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const {
|
||||
// required bool enabled = 1;
|
||||
if (has_enabled()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteBool(1, this->enabled(), output);
|
||||
}
|
||||
|
||||
// required .gazebo.msgs.DriverStation.State state = 2;
|
||||
if (has_state()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteEnum(
|
||||
2, this->state(), output);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||
unknown_fields(), output);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::uint8* DriverStation::SerializeWithCachedSizesToArray(
|
||||
::google::protobuf::uint8* target) const {
|
||||
// required bool enabled = 1;
|
||||
if (has_enabled()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->enabled(), target);
|
||||
}
|
||||
|
||||
// required .gazebo.msgs.DriverStation.State state = 2;
|
||||
if (has_state()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
|
||||
2, this->state(), target);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||
unknown_fields(), target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int DriverStation::ByteSize() const {
|
||||
int total_size = 0;
|
||||
|
||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
// required bool enabled = 1;
|
||||
if (has_enabled()) {
|
||||
total_size += 1 + 1;
|
||||
}
|
||||
|
||||
// required .gazebo.msgs.DriverStation.State state = 2;
|
||||
if (has_state()) {
|
||||
total_size += 1 +
|
||||
::google::protobuf::internal::WireFormatLite::EnumSize(this->state());
|
||||
}
|
||||
|
||||
}
|
||||
if (!unknown_fields().empty()) {
|
||||
total_size +=
|
||||
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||
unknown_fields());
|
||||
}
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = total_size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
return total_size;
|
||||
}
|
||||
|
||||
void DriverStation::MergeFrom(const ::google::protobuf::Message& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
const DriverStation* source =
|
||||
::google::protobuf::internal::dynamic_cast_if_available<const DriverStation*>(
|
||||
&from);
|
||||
if (source == NULL) {
|
||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||
} else {
|
||||
MergeFrom(*source);
|
||||
}
|
||||
}
|
||||
|
||||
void DriverStation::MergeFrom(const DriverStation& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
if (from.has_enabled()) {
|
||||
set_enabled(from.enabled());
|
||||
}
|
||||
if (from.has_state()) {
|
||||
set_state(from.state());
|
||||
}
|
||||
}
|
||||
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
|
||||
}
|
||||
|
||||
void DriverStation::CopyFrom(const ::google::protobuf::Message& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void DriverStation::CopyFrom(const DriverStation& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
bool DriverStation::IsInitialized() const {
|
||||
if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DriverStation::Swap(DriverStation* other) {
|
||||
if (other != this) {
|
||||
std::swap(enabled_, other->enabled_);
|
||||
std::swap(state_, other->state_);
|
||||
std::swap(_has_bits_[0], other->_has_bits_[0]);
|
||||
_unknown_fields_.Swap(&other->_unknown_fields_);
|
||||
std::swap(_cached_size_, other->_cached_size_);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::Metadata DriverStation::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::Metadata metadata;
|
||||
metadata.descriptor = DriverStation_descriptor_;
|
||||
metadata.reflection = DriverStation_reflection_;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace msgs
|
||||
} // namespace gazebo
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
250
simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.h
Normal file
250
simulation/frc_gazebo_plugins/msgs/src/msgs/driver-station.pb.h
Normal file
@@ -0,0 +1,250 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: msgs/driver-station.proto
|
||||
|
||||
#ifndef PROTOBUF_msgs_2fdriver_2dstation_2eproto__INCLUDED
|
||||
#define PROTOBUF_msgs_2fdriver_2dstation_2eproto__INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION < 2005000
|
||||
#error This file was generated by a newer version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please update
|
||||
#error your headers.
|
||||
#endif
|
||||
#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#error This file was generated by an older version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please
|
||||
#error regenerate this file with a newer version of protoc.
|
||||
#endif
|
||||
|
||||
#include <google/protobuf/generated_message_util.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/repeated_field.h>
|
||||
#include <google/protobuf/extension_set.h>
|
||||
#include <google/protobuf/generated_enum_reflection.h>
|
||||
#include <google/protobuf/unknown_field_set.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace gazebo {
|
||||
namespace msgs {
|
||||
|
||||
// Internal implementation detail -- do not call these.
|
||||
void protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto();
|
||||
void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto();
|
||||
void protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto();
|
||||
|
||||
class DriverStation;
|
||||
|
||||
enum DriverStation_State {
|
||||
DriverStation_State_AUTO = 0,
|
||||
DriverStation_State_TELEOP = 1,
|
||||
DriverStation_State_TEST = 2
|
||||
};
|
||||
bool DriverStation_State_IsValid(int value);
|
||||
const DriverStation_State DriverStation_State_State_MIN = DriverStation_State_AUTO;
|
||||
const DriverStation_State DriverStation_State_State_MAX = DriverStation_State_TEST;
|
||||
const int DriverStation_State_State_ARRAYSIZE = DriverStation_State_State_MAX + 1;
|
||||
|
||||
const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor();
|
||||
inline const ::std::string& DriverStation_State_Name(DriverStation_State value) {
|
||||
return ::google::protobuf::internal::NameOfEnum(
|
||||
DriverStation_State_descriptor(), value);
|
||||
}
|
||||
inline bool DriverStation_State_Parse(
|
||||
const ::std::string& name, DriverStation_State* value) {
|
||||
return ::google::protobuf::internal::ParseNamedEnum<DriverStation_State>(
|
||||
DriverStation_State_descriptor(), name, value);
|
||||
}
|
||||
// ===================================================================
|
||||
|
||||
class DriverStation : public ::google::protobuf::Message {
|
||||
public:
|
||||
DriverStation();
|
||||
virtual ~DriverStation();
|
||||
|
||||
DriverStation(const DriverStation& from);
|
||||
|
||||
inline DriverStation& operator=(const DriverStation& from) {
|
||||
CopyFrom(from);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
||||
return _unknown_fields_;
|
||||
}
|
||||
|
||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
||||
return &_unknown_fields_;
|
||||
}
|
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor();
|
||||
static const DriverStation& default_instance();
|
||||
|
||||
void Swap(DriverStation* other);
|
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
DriverStation* New() const;
|
||||
void CopyFrom(const ::google::protobuf::Message& from);
|
||||
void MergeFrom(const ::google::protobuf::Message& from);
|
||||
void CopyFrom(const DriverStation& from);
|
||||
void MergeFrom(const DriverStation& from);
|
||||
void Clear();
|
||||
bool IsInitialized() const;
|
||||
|
||||
int ByteSize() const;
|
||||
bool MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input);
|
||||
void SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const;
|
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
|
||||
int GetCachedSize() const { return _cached_size_; }
|
||||
private:
|
||||
void SharedCtor();
|
||||
void SharedDtor();
|
||||
void SetCachedSize(int size) const;
|
||||
public:
|
||||
|
||||
::google::protobuf::Metadata GetMetadata() const;
|
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
typedef DriverStation_State State;
|
||||
static const State AUTO = DriverStation_State_AUTO;
|
||||
static const State TELEOP = DriverStation_State_TELEOP;
|
||||
static const State TEST = DriverStation_State_TEST;
|
||||
static inline bool State_IsValid(int value) {
|
||||
return DriverStation_State_IsValid(value);
|
||||
}
|
||||
static const State State_MIN =
|
||||
DriverStation_State_State_MIN;
|
||||
static const State State_MAX =
|
||||
DriverStation_State_State_MAX;
|
||||
static const int State_ARRAYSIZE =
|
||||
DriverStation_State_State_ARRAYSIZE;
|
||||
static inline const ::google::protobuf::EnumDescriptor*
|
||||
State_descriptor() {
|
||||
return DriverStation_State_descriptor();
|
||||
}
|
||||
static inline const ::std::string& State_Name(State value) {
|
||||
return DriverStation_State_Name(value);
|
||||
}
|
||||
static inline bool State_Parse(const ::std::string& name,
|
||||
State* value) {
|
||||
return DriverStation_State_Parse(name, value);
|
||||
}
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// required bool enabled = 1;
|
||||
inline bool has_enabled() const;
|
||||
inline void clear_enabled();
|
||||
static const int kEnabledFieldNumber = 1;
|
||||
inline bool enabled() const;
|
||||
inline void set_enabled(bool value);
|
||||
|
||||
// required .gazebo.msgs.DriverStation.State state = 2;
|
||||
inline bool has_state() const;
|
||||
inline void clear_state();
|
||||
static const int kStateFieldNumber = 2;
|
||||
inline ::gazebo::msgs::DriverStation_State state() const;
|
||||
inline void set_state(::gazebo::msgs::DriverStation_State value);
|
||||
|
||||
// @@protoc_insertion_point(class_scope:gazebo.msgs.DriverStation)
|
||||
private:
|
||||
inline void set_has_enabled();
|
||||
inline void clear_has_enabled();
|
||||
inline void set_has_state();
|
||||
inline void clear_has_state();
|
||||
|
||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
||||
|
||||
bool enabled_;
|
||||
int state_;
|
||||
|
||||
mutable int _cached_size_;
|
||||
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
|
||||
|
||||
friend void protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto();
|
||||
friend void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto();
|
||||
friend void protobuf_ShutdownFile_msgs_2fdriver_2dstation_2eproto();
|
||||
|
||||
void InitAsDefaultInstance();
|
||||
static DriverStation* default_instance_;
|
||||
};
|
||||
// ===================================================================
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// DriverStation
|
||||
|
||||
// required bool enabled = 1;
|
||||
inline bool DriverStation::has_enabled() const {
|
||||
return (_has_bits_[0] & 0x00000001u) != 0;
|
||||
}
|
||||
inline void DriverStation::set_has_enabled() {
|
||||
_has_bits_[0] |= 0x00000001u;
|
||||
}
|
||||
inline void DriverStation::clear_has_enabled() {
|
||||
_has_bits_[0] &= ~0x00000001u;
|
||||
}
|
||||
inline void DriverStation::clear_enabled() {
|
||||
enabled_ = false;
|
||||
clear_has_enabled();
|
||||
}
|
||||
inline bool DriverStation::enabled() const {
|
||||
return enabled_;
|
||||
}
|
||||
inline void DriverStation::set_enabled(bool value) {
|
||||
set_has_enabled();
|
||||
enabled_ = value;
|
||||
}
|
||||
|
||||
// required .gazebo.msgs.DriverStation.State state = 2;
|
||||
inline bool DriverStation::has_state() const {
|
||||
return (_has_bits_[0] & 0x00000002u) != 0;
|
||||
}
|
||||
inline void DriverStation::set_has_state() {
|
||||
_has_bits_[0] |= 0x00000002u;
|
||||
}
|
||||
inline void DriverStation::clear_has_state() {
|
||||
_has_bits_[0] &= ~0x00000002u;
|
||||
}
|
||||
inline void DriverStation::clear_state() {
|
||||
state_ = 0;
|
||||
clear_has_state();
|
||||
}
|
||||
inline ::gazebo::msgs::DriverStation_State DriverStation::state() const {
|
||||
return static_cast< ::gazebo::msgs::DriverStation_State >(state_);
|
||||
}
|
||||
inline void DriverStation::set_state(::gazebo::msgs::DriverStation_State value) {
|
||||
assert(::gazebo::msgs::DriverStation_State_IsValid(value));
|
||||
set_has_state();
|
||||
state_ = value;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace msgs
|
||||
} // namespace gazebo
|
||||
|
||||
#ifndef SWIG
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
template <>
|
||||
inline const EnumDescriptor* GetEnumDescriptor< ::gazebo::msgs::DriverStation_State>() {
|
||||
return ::gazebo::msgs::DriverStation_State_descriptor();
|
||||
}
|
||||
|
||||
} // namespace google
|
||||
} // namespace protobuf
|
||||
#endif // SWIG
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
#endif // PROTOBUF_msgs_2fdriver_2dstation_2eproto__INCLUDED
|
||||
310
simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.cc
Normal file
310
simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.cc
Normal file
@@ -0,0 +1,310 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: msgs/float64.proto
|
||||
|
||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
||||
#include "msgs/float64.pb.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/stubs/once.h>
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/wire_format_lite_inl.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/generated_message_reflection.h>
|
||||
#include <google/protobuf/reflection_ops.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace gazebo {
|
||||
namespace msgs {
|
||||
|
||||
namespace {
|
||||
|
||||
const ::google::protobuf::Descriptor* Float64_descriptor_ = NULL;
|
||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
||||
Float64_reflection_ = NULL;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void protobuf_AssignDesc_msgs_2ffloat64_2eproto() {
|
||||
protobuf_AddDesc_msgs_2ffloat64_2eproto();
|
||||
const ::google::protobuf::FileDescriptor* file =
|
||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
||||
"msgs/float64.proto");
|
||||
GOOGLE_CHECK(file != NULL);
|
||||
Float64_descriptor_ = file->message_type(0);
|
||||
static const int Float64_offsets_[1] = {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, data_),
|
||||
};
|
||||
Float64_reflection_ =
|
||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
||||
Float64_descriptor_,
|
||||
Float64::default_instance_,
|
||||
Float64_offsets_,
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, _has_bits_[0]),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, _unknown_fields_),
|
||||
-1,
|
||||
::google::protobuf::DescriptorPool::generated_pool(),
|
||||
::google::protobuf::MessageFactory::generated_factory(),
|
||||
sizeof(Float64));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
||||
inline void protobuf_AssignDescriptorsOnce() {
|
||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
||||
&protobuf_AssignDesc_msgs_2ffloat64_2eproto);
|
||||
}
|
||||
|
||||
void protobuf_RegisterTypes(const ::std::string&) {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
||||
Float64_descriptor_, &Float64::default_instance());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void protobuf_ShutdownFile_msgs_2ffloat64_2eproto() {
|
||||
delete Float64::default_instance_;
|
||||
delete Float64_reflection_;
|
||||
}
|
||||
|
||||
void protobuf_AddDesc_msgs_2ffloat64_2eproto() {
|
||||
static bool already_here = false;
|
||||
if (already_here) return;
|
||||
already_here = true;
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||
"\n\022msgs/float64.proto\022\013gazebo.msgs\"\027\n\007Flo"
|
||||
"at64\022\014\n\004data\030\001 \002(\001B\013B\tGzFloat64", 71);
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||
"msgs/float64.proto", &protobuf_RegisterTypes);
|
||||
Float64::default_instance_ = new Float64();
|
||||
Float64::default_instance_->InitAsDefaultInstance();
|
||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_msgs_2ffloat64_2eproto);
|
||||
}
|
||||
|
||||
// Force AddDescriptors() to be called at static initialization time.
|
||||
struct StaticDescriptorInitializer_msgs_2ffloat64_2eproto {
|
||||
StaticDescriptorInitializer_msgs_2ffloat64_2eproto() {
|
||||
protobuf_AddDesc_msgs_2ffloat64_2eproto();
|
||||
}
|
||||
} static_descriptor_initializer_msgs_2ffloat64_2eproto_;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
#ifndef _MSC_VER
|
||||
const int Float64::kDataFieldNumber;
|
||||
#endif // !_MSC_VER
|
||||
|
||||
Float64::Float64()
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
}
|
||||
|
||||
void Float64::InitAsDefaultInstance() {
|
||||
}
|
||||
|
||||
Float64::Float64(const Float64& from)
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void Float64::SharedCtor() {
|
||||
_cached_size_ = 0;
|
||||
data_ = 0;
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
}
|
||||
|
||||
Float64::~Float64() {
|
||||
SharedDtor();
|
||||
}
|
||||
|
||||
void Float64::SharedDtor() {
|
||||
if (this != default_instance_) {
|
||||
}
|
||||
}
|
||||
|
||||
void Float64::SetCachedSize(int size) const {
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* Float64::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return Float64_descriptor_;
|
||||
}
|
||||
|
||||
const Float64& Float64::default_instance() {
|
||||
if (default_instance_ == NULL) protobuf_AddDesc_msgs_2ffloat64_2eproto();
|
||||
return *default_instance_;
|
||||
}
|
||||
|
||||
Float64* Float64::default_instance_ = NULL;
|
||||
|
||||
Float64* Float64::New() const {
|
||||
return new Float64;
|
||||
}
|
||||
|
||||
void Float64::Clear() {
|
||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
data_ = 0;
|
||||
}
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
mutable_unknown_fields()->Clear();
|
||||
}
|
||||
|
||||
bool Float64::MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input) {
|
||||
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
|
||||
::google::protobuf::uint32 tag;
|
||||
while ((tag = input->ReadTag()) != 0) {
|
||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
||||
// required double data = 1;
|
||||
case 1: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) {
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
|
||||
input, &data_)));
|
||||
set_has_data();
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectAtEnd()) return true;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
handle_uninterpreted:
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
||||
return true;
|
||||
}
|
||||
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||
input, tag, mutable_unknown_fields()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#undef DO_
|
||||
}
|
||||
|
||||
void Float64::SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const {
|
||||
// required double data = 1;
|
||||
if (has_data()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->data(), output);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||
unknown_fields(), output);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::uint8* Float64::SerializeWithCachedSizesToArray(
|
||||
::google::protobuf::uint8* target) const {
|
||||
// required double data = 1;
|
||||
if (has_data()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->data(), target);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||
unknown_fields(), target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int Float64::ByteSize() const {
|
||||
int total_size = 0;
|
||||
|
||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
// required double data = 1;
|
||||
if (has_data()) {
|
||||
total_size += 1 + 8;
|
||||
}
|
||||
|
||||
}
|
||||
if (!unknown_fields().empty()) {
|
||||
total_size +=
|
||||
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||
unknown_fields());
|
||||
}
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = total_size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
return total_size;
|
||||
}
|
||||
|
||||
void Float64::MergeFrom(const ::google::protobuf::Message& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
const Float64* source =
|
||||
::google::protobuf::internal::dynamic_cast_if_available<const Float64*>(
|
||||
&from);
|
||||
if (source == NULL) {
|
||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||
} else {
|
||||
MergeFrom(*source);
|
||||
}
|
||||
}
|
||||
|
||||
void Float64::MergeFrom(const Float64& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
if (from.has_data()) {
|
||||
set_data(from.data());
|
||||
}
|
||||
}
|
||||
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
|
||||
}
|
||||
|
||||
void Float64::CopyFrom(const ::google::protobuf::Message& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void Float64::CopyFrom(const Float64& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
bool Float64::IsInitialized() const {
|
||||
if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Float64::Swap(Float64* other) {
|
||||
if (other != this) {
|
||||
std::swap(data_, other->data_);
|
||||
std::swap(_has_bits_[0], other->_has_bits_[0]);
|
||||
_unknown_fields_.Swap(&other->_unknown_fields_);
|
||||
std::swap(_cached_size_, other->_cached_size_);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::Metadata Float64::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::Metadata metadata;
|
||||
metadata.descriptor = Float64_descriptor_;
|
||||
metadata.reflection = Float64_reflection_;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace msgs
|
||||
} // namespace gazebo
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
167
simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.h
Normal file
167
simulation/frc_gazebo_plugins/msgs/src/msgs/float64.pb.h
Normal file
@@ -0,0 +1,167 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: msgs/float64.proto
|
||||
|
||||
#ifndef PROTOBUF_msgs_2ffloat64_2eproto__INCLUDED
|
||||
#define PROTOBUF_msgs_2ffloat64_2eproto__INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION < 2005000
|
||||
#error This file was generated by a newer version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please update
|
||||
#error your headers.
|
||||
#endif
|
||||
#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#error This file was generated by an older version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please
|
||||
#error regenerate this file with a newer version of protoc.
|
||||
#endif
|
||||
|
||||
#include <google/protobuf/generated_message_util.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/repeated_field.h>
|
||||
#include <google/protobuf/extension_set.h>
|
||||
#include <google/protobuf/unknown_field_set.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace gazebo {
|
||||
namespace msgs {
|
||||
|
||||
// Internal implementation detail -- do not call these.
|
||||
void protobuf_AddDesc_msgs_2ffloat64_2eproto();
|
||||
void protobuf_AssignDesc_msgs_2ffloat64_2eproto();
|
||||
void protobuf_ShutdownFile_msgs_2ffloat64_2eproto();
|
||||
|
||||
class Float64;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class Float64 : public ::google::protobuf::Message {
|
||||
public:
|
||||
Float64();
|
||||
virtual ~Float64();
|
||||
|
||||
Float64(const Float64& from);
|
||||
|
||||
inline Float64& operator=(const Float64& from) {
|
||||
CopyFrom(from);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
||||
return _unknown_fields_;
|
||||
}
|
||||
|
||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
||||
return &_unknown_fields_;
|
||||
}
|
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor();
|
||||
static const Float64& default_instance();
|
||||
|
||||
void Swap(Float64* other);
|
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
Float64* New() const;
|
||||
void CopyFrom(const ::google::protobuf::Message& from);
|
||||
void MergeFrom(const ::google::protobuf::Message& from);
|
||||
void CopyFrom(const Float64& from);
|
||||
void MergeFrom(const Float64& from);
|
||||
void Clear();
|
||||
bool IsInitialized() const;
|
||||
|
||||
int ByteSize() const;
|
||||
bool MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input);
|
||||
void SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const;
|
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
|
||||
int GetCachedSize() const { return _cached_size_; }
|
||||
private:
|
||||
void SharedCtor();
|
||||
void SharedDtor();
|
||||
void SetCachedSize(int size) const;
|
||||
public:
|
||||
|
||||
::google::protobuf::Metadata GetMetadata() const;
|
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// required double data = 1;
|
||||
inline bool has_data() const;
|
||||
inline void clear_data();
|
||||
static const int kDataFieldNumber = 1;
|
||||
inline double data() const;
|
||||
inline void set_data(double value);
|
||||
|
||||
// @@protoc_insertion_point(class_scope:gazebo.msgs.Float64)
|
||||
private:
|
||||
inline void set_has_data();
|
||||
inline void clear_has_data();
|
||||
|
||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
||||
|
||||
double data_;
|
||||
|
||||
mutable int _cached_size_;
|
||||
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
|
||||
|
||||
friend void protobuf_AddDesc_msgs_2ffloat64_2eproto();
|
||||
friend void protobuf_AssignDesc_msgs_2ffloat64_2eproto();
|
||||
friend void protobuf_ShutdownFile_msgs_2ffloat64_2eproto();
|
||||
|
||||
void InitAsDefaultInstance();
|
||||
static Float64* default_instance_;
|
||||
};
|
||||
// ===================================================================
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// Float64
|
||||
|
||||
// required double data = 1;
|
||||
inline bool Float64::has_data() const {
|
||||
return (_has_bits_[0] & 0x00000001u) != 0;
|
||||
}
|
||||
inline void Float64::set_has_data() {
|
||||
_has_bits_[0] |= 0x00000001u;
|
||||
}
|
||||
inline void Float64::clear_has_data() {
|
||||
_has_bits_[0] &= ~0x00000001u;
|
||||
}
|
||||
inline void Float64::clear_data() {
|
||||
data_ = 0;
|
||||
clear_has_data();
|
||||
}
|
||||
inline double Float64::data() const {
|
||||
return data_;
|
||||
}
|
||||
inline void Float64::set_data(double value) {
|
||||
set_has_data();
|
||||
data_ = value;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace msgs
|
||||
} // namespace gazebo
|
||||
|
||||
#ifndef SWIG
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
|
||||
} // namespace google
|
||||
} // namespace protobuf
|
||||
#endif // SWIG
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
#endif // PROTOBUF_msgs_2ffloat64_2eproto__INCLUDED
|
||||
30
simulation/frc_gazebo_plugins/msgs/src/msgs/msgs.h
Normal file
30
simulation/frc_gazebo_plugins/msgs/src/msgs/msgs.h
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
#include "msgs/float64.pb.h"
|
||||
#include "msgs/bool.pb.h"
|
||||
#include "msgs/driver-station.pb.h"
|
||||
|
||||
#include <gazebo/msgs/msgs.hh>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#ifndef _FRC_MSGS_H_
|
||||
#define _FRC_MSGS_H_
|
||||
|
||||
namespace gazebo {
|
||||
namespace msgs {
|
||||
|
||||
typedef GzString String;
|
||||
typedef boost::shared_ptr< gazebo::msgs::String > StringPtr;
|
||||
typedef const boost::shared_ptr< const gazebo::msgs::String > ConstStringPtr;
|
||||
|
||||
typedef boost::shared_ptr< msgs::Float64 > Float64Ptr;
|
||||
typedef const boost::shared_ptr< const msgs::Float64 > ConstFloat64Ptr;
|
||||
|
||||
typedef boost::shared_ptr< msgs::Bool > BoolPtr;
|
||||
typedef const boost::shared_ptr< const msgs::Bool > ConstBoolPtr;
|
||||
|
||||
typedef boost::shared_ptr< msgs::DriverStation > DriverStationPtr;
|
||||
typedef const boost::shared_ptr< const msgs::DriverStation > ConstDriverStationPtr;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _FRC_MSGS_H_ */
|
||||
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(gz_pneumatic_piston)
|
||||
|
||||
include (FindPkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GAZEBO gazebo)
|
||||
endif()
|
||||
|
||||
find_package(gazebo REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp)
|
||||
file(GLOB_RECURSE MSG_FILES ../msgs/src/*.cc)
|
||||
include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src)
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${MSG_FILES})
|
||||
|
||||
link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build)
|
||||
target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES})
|
||||
15
simulation/frc_gazebo_plugins/pneumatic_piston/Makefile
Normal file
15
simulation/frc_gazebo_plugins/pneumatic_piston/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
all:
|
||||
mkdir -p $(build.dir)
|
||||
cd ${build.dir} && cmake .. && make
|
||||
|
||||
clean:
|
||||
rm -rf $(build.dir)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(plugin.dir)
|
||||
install $(build.dir)/libgz_pneumatic_piston.so $(DESTDIR)$(plugin.dir)
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "pneumatic_piston.h"
|
||||
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
|
||||
GZ_REGISTER_MODEL_PLUGIN(PneumaticPiston)
|
||||
|
||||
PneumaticPiston::PneumaticPiston() {}
|
||||
|
||||
PneumaticPiston::~PneumaticPiston() {}
|
||||
|
||||
void PneumaticPiston::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
this->model = model;
|
||||
signal = 0;
|
||||
|
||||
// Parse SDF properties
|
||||
joint = model->GetJoint(sdf->Get<std::string>("joint"));
|
||||
if (sdf->HasElement("topic")) {
|
||||
topic = sdf->Get<std::string>("topic");
|
||||
} else {
|
||||
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") {
|
||||
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;
|
||||
|
||||
// Connect to Gazebo transport for messaging
|
||||
std::string scoped_name = model->GetWorld()->GetName()+"::"+model->GetScopedName();
|
||||
boost::replace_all(scoped_name, "::", "/");
|
||||
node = transport::NodePtr(new transport::Node());
|
||||
node->Init(scoped_name);
|
||||
sub = node->Subscribe(topic, &PneumaticPiston::Callback, this);
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
#include "msgs/msgs.h"
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
/**
|
||||
* \brief Plugin for controlling a joint with a pneumatic piston.
|
||||
*
|
||||
* This plugin subscribes to a topic to get a signal. It accepts three
|
||||
* values:
|
||||
*
|
||||
* - 1: Apply the forward force to the joint.
|
||||
* - 0: Maintain last applied force
|
||||
* - -1: Apply the reverse force to the joint.
|
||||
*
|
||||
* Every physics update the joint's torque is set to reflect the
|
||||
* signal.
|
||||
*
|
||||
* To add a pneumatic piston to your robot, add the following XML to
|
||||
* your robot model:
|
||||
*
|
||||
* <plugin name="my_piston" filename="libgz_pneumatic_piston.so">
|
||||
* <joint>Joint Name</joint>
|
||||
* <topic>~/my/topic</topic>
|
||||
* <direction>{forward, reversed}</direction>
|
||||
* <forward-force>Number</forward-force>
|
||||
* <reverse-force>Number</reverse-force>
|
||||
* </plugin>
|
||||
*
|
||||
* - `joint`: Name of the joint this Dc motor is attached to.
|
||||
* - `topic`: Optional. Message type should be gazebo.msgs.Float64.
|
||||
* - `direction`: Optional. Defaults to forward. Reversed if the
|
||||
* piston pushes in the opposite direction of the joint
|
||||
* axis.
|
||||
* - `forward-force`: Force to apply in the forward direction.
|
||||
* - `reverse-force`: Force to apply in the reverse direction.
|
||||
*
|
||||
* \todo Signal should probably be made a tri-state message.
|
||||
*/
|
||||
class PneumaticPiston: public ModelPlugin {
|
||||
public:
|
||||
PneumaticPiston();
|
||||
~PneumaticPiston();
|
||||
|
||||
/// \brief Load the pneumatic piston and configures it according to the sdf.
|
||||
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
|
||||
/// \brief Updat the force the piston applies on the joint.
|
||||
void Update(const common::UpdateInfo &info);
|
||||
|
||||
private:
|
||||
/// \brief Topic to read control signal from.
|
||||
std::string topic;
|
||||
|
||||
/// \brief The signal is one of: {-1,0,1}.
|
||||
double signal;
|
||||
|
||||
/// \brief The magic force multipliers for each direction.
|
||||
double forward_force, reverse_force;
|
||||
|
||||
/// \brief The joint that this pneumatic piston actuates.
|
||||
physics::JointPtr joint;
|
||||
|
||||
/// \brief Callback for receiving msgs and updating the torque.
|
||||
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.
|
||||
};
|
||||
17
simulation/frc_gazebo_plugins/potentiometer/CMakeLists.txt
Normal file
17
simulation/frc_gazebo_plugins/potentiometer/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(gz_potentiometer)
|
||||
|
||||
include (FindPkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GAZEBO gazebo)
|
||||
endif()
|
||||
|
||||
find_package(gazebo REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp)
|
||||
file(GLOB_RECURSE MSG_FILES ../msgs/src/*.cc)
|
||||
include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src)
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${MSG_FILES})
|
||||
|
||||
link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build)
|
||||
target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES})
|
||||
15
simulation/frc_gazebo_plugins/potentiometer/Makefile
Normal file
15
simulation/frc_gazebo_plugins/potentiometer/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
all:
|
||||
mkdir -p $(build.dir)
|
||||
cd ${build.dir} && cmake .. && make
|
||||
|
||||
clean:
|
||||
rm -rf $(build.dir)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(plugin.dir)
|
||||
install $(build.dir)/libgz_potentiometer.so $(DESTDIR)$(plugin.dir)
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "potentiometer.h"
|
||||
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "msgs/msgs.h"
|
||||
|
||||
GZ_REGISTER_MODEL_PLUGIN(Potentiometer)
|
||||
|
||||
Potentiometer::Potentiometer() {}
|
||||
|
||||
Potentiometer::~Potentiometer() {}
|
||||
|
||||
void Potentiometer::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
this->model = model;
|
||||
|
||||
// Parse SDF properties
|
||||
joint = model->GetJoint(sdf->Get<std::string>("joint"));
|
||||
if (sdf->HasElement("topic")) {
|
||||
topic = sdf->Get<std::string>("topic");
|
||||
} else {
|
||||
topic = "~/"+sdf->GetAttribute("name")->GetAsString();
|
||||
}
|
||||
|
||||
if (sdf->HasElement("units")) {
|
||||
radians = sdf->Get<std::string>("units") != "degrees";
|
||||
} else {
|
||||
radians = true;
|
||||
}
|
||||
|
||||
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();
|
||||
boost::replace_all(scoped_name, "::", "/");
|
||||
node = transport::NodePtr(new transport::Node());
|
||||
node->Init(scoped_name);
|
||||
pub = node->Advertise<msgs::Float64>(topic);
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
void Potentiometer::Update(const common::UpdateInfo &info) {
|
||||
joint->GetAngle(0).Normalize();
|
||||
msgs::Float64 msg;
|
||||
if (radians) {
|
||||
msg.set_data(joint->GetAngle(0).Radian());
|
||||
} else {
|
||||
msg.set_data(joint->GetAngle(0).Degree());
|
||||
}
|
||||
pub->Publish(msg);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
/**
|
||||
* \brief Plugin for reading the angle of a joint.
|
||||
*
|
||||
* This plugin publishes the angle of a joint to the topic every
|
||||
* physics update. Supports reading in either radians or degrees.
|
||||
*
|
||||
* To add a potentiometer to your robot, add the following XML to your
|
||||
* robot model:
|
||||
*
|
||||
* <plugin name="my_pot" filename="libgz_potentiometer.so">
|
||||
* <joint>Joint Name</joint>
|
||||
* <topic>~/my/topic</topic>
|
||||
* <units>{degrees, radians}</units>
|
||||
* </plugin>
|
||||
*
|
||||
* - `joint`: Name of the joint this potentiometer is attached to.
|
||||
* - `topic`: Optional. Message will be published as a gazebo.msgs.Float64.
|
||||
* - `units`: Optional. Defaults to radians.
|
||||
*/
|
||||
class Potentiometer: public ModelPlugin {
|
||||
public:
|
||||
Potentiometer();
|
||||
~Potentiometer();
|
||||
|
||||
/// \brief Load the potentiometer and configures it according to the sdf.
|
||||
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
|
||||
/// \brief Sends out the potentiometer reading each timestep.
|
||||
void Update(const common::UpdateInfo &info);
|
||||
|
||||
private:
|
||||
/// \brief Publish the angle on this topic.
|
||||
std::string topic;
|
||||
|
||||
/// \brief Whether or not this potentiometer measures radians or degrees.
|
||||
bool radians;
|
||||
|
||||
/// \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.
|
||||
};
|
||||
17
simulation/frc_gazebo_plugins/rangefinder/CMakeLists.txt
Normal file
17
simulation/frc_gazebo_plugins/rangefinder/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(gz_rangefinder)
|
||||
|
||||
include (FindPkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GAZEBO gazebo)
|
||||
endif()
|
||||
|
||||
find_package(gazebo REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC_FILES src/*.cpp)
|
||||
file(GLOB_RECURSE MSG_FILES ../msgs/src/*.cc)
|
||||
include_directories(src ${Boost_INCLUDE_DIR} ${GAZEBO_INCLUDE_DIRS} ../msgs/src)
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${MSG_FILES})
|
||||
|
||||
link_directories(${GAZEBO_LIBRARY_DIRS} ../msgs/build)
|
||||
target_link_libraries(${PROJECT_NAME} ${GAZEBO_LIBRARIES})
|
||||
15
simulation/frc_gazebo_plugins/rangefinder/Makefile
Normal file
15
simulation/frc_gazebo_plugins/rangefinder/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
prefix = /usr
|
||||
lib.dir = $(prefix)/lib
|
||||
plugin.dir = $(lib.dir)/frcsim/plugins
|
||||
build.dir = build
|
||||
|
||||
all:
|
||||
mkdir -p $(build.dir)
|
||||
cd ${build.dir} && cmake .. && make
|
||||
|
||||
clean:
|
||||
rm -rf $(build.dir)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(plugin.dir)
|
||||
install $(build.dir)/libgz_rangefinder.so $(DESTDIR)$(plugin.dir)
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "rangefinder.h"
|
||||
|
||||
#include <gazebo/physics/physics.hh>
|
||||
#include <gazebo/transport/transport.hh>
|
||||
#include <gazebo/sensors/sensors.hh>
|
||||
|
||||
#include <boost/pointer_cast.hpp>
|
||||
|
||||
#include "msgs/msgs.h"
|
||||
|
||||
GZ_REGISTER_MODEL_PLUGIN(Rangefinder)
|
||||
|
||||
Rangefinder::Rangefinder() {}
|
||||
|
||||
Rangefinder::~Rangefinder() {}
|
||||
|
||||
void Rangefinder::Load(physics::ModelPtr model, sdf::ElementPtr sdf) {
|
||||
this->model = model;
|
||||
|
||||
// Parse SDF properties
|
||||
sensor = boost::dynamic_pointer_cast<sensors::SonarSensor>(
|
||||
sensors::get_sensor(sdf->Get<std::string>("sensor")));
|
||||
if (sdf->HasElement("topic")) {
|
||||
topic = sdf->Get<std::string>("topic");
|
||||
} else {
|
||||
topic = "~/"+sdf->GetAttribute("name")->GetAsString();
|
||||
}
|
||||
|
||||
gzmsg << "Initializing rangefinder: " << topic << " sensor=" << sensor->GetName() << std::endl;
|
||||
|
||||
// Connect to Gazebo transport for messaging
|
||||
std::string scoped_name = model->GetWorld()->GetName()+"::"+model->GetScopedName();
|
||||
boost::replace_all(scoped_name, "::", "/");
|
||||
node = transport::NodePtr(new transport::Node());
|
||||
node->Init(scoped_name);
|
||||
pub = node->Advertise<msgs::Float64>(topic);
|
||||
|
||||
// Connect to the world update event.
|
||||
// This will trigger the Update function every Gazebo iteration
|
||||
updateConn = event::Events::ConnectWorldUpdateBegin(boost::bind(&Rangefinder::Update, this, _1));
|
||||
}
|
||||
|
||||
void Rangefinder::Update(const common::UpdateInfo &info) {
|
||||
msgs::Float64 msg;
|
||||
msg.set_data(sensor->GetRange());
|
||||
pub->Publish(msg);
|
||||
}
|
||||
46
simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.h
Normal file
46
simulation/frc_gazebo_plugins/rangefinder/src/rangefinder.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <gazebo/gazebo.hh>
|
||||
|
||||
using namespace gazebo;
|
||||
|
||||
/**
|
||||
* \brief Plugin for reading the range of obstacles.
|
||||
*
|
||||
* This plugin publishes the range of obstacles detected by a sonar
|
||||
* rangefinder every physics update.
|
||||
*
|
||||
* To add a rangefinder to your robot, add the following XML to your
|
||||
* robot model:
|
||||
*
|
||||
* <plugin name="my_rangefinder" filename="libgz_rangefinder.so">
|
||||
* <sensor>Sensor Name</sensor>
|
||||
* <topic>~/my/topic</topic>
|
||||
* </plugin>
|
||||
*
|
||||
* - `sensor`: Name of the sonar sensor that this rangefinder uses.
|
||||
* - `topic`: Optional. Message will be published as a gazebo.msgs.Float64.
|
||||
*/
|
||||
class Rangefinder: public ModelPlugin {
|
||||
public:
|
||||
Rangefinder();
|
||||
~Rangefinder();
|
||||
|
||||
/// \brief Load the rangefinder and configures it according to the sdf.
|
||||
void Load(physics::ModelPtr model, sdf::ElementPtr sdf);
|
||||
|
||||
/// \brief Sends out the rangefinder reading each timestep.
|
||||
void Update(const common::UpdateInfo &info);
|
||||
|
||||
private:
|
||||
/// \brief Publish the range on this topic.
|
||||
std::string topic;
|
||||
|
||||
/// \brief The sonar sensor that this rangefinder uses
|
||||
sensors::SonarSensorPtr sensor;
|
||||
|
||||
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