"using" directives are no longer used in global namespaces (#219)

This commit is contained in:
Tyler Veness
2016-11-01 23:09:51 -07:00
committed by Peter Johnson
parent 78f0b1562c
commit ba8761e39e
39 changed files with 292 additions and 256 deletions

View File

@@ -29,26 +29,26 @@ int DriverStation::m_updateNumber = 0;
* This is only called once the first time GetInstance() is called
*/
DriverStation::DriverStation() {
state = msgs::DriverStationPtr(new msgs::DriverStation());
state = gazebo::msgs::DriverStationPtr(new gazebo::msgs::DriverStation());
stateSub =
MainNode::Subscribe("~/ds/state", &DriverStation::stateCallback, this);
// TODO: for loop + boost bind
joysticks[0] = msgs::FRCJoystickPtr(new msgs::FRCJoystick());
joysticks[0] = gazebo::msgs::FRCJoystickPtr(new gazebo::msgs::FRCJoystick());
joysticksSub[0] = MainNode::Subscribe(
"~/ds/joysticks/0", &DriverStation::joystickCallback0, this);
joysticks[1] = msgs::FRCJoystickPtr(new msgs::FRCJoystick());
joysticks[1] = gazebo::msgs::FRCJoystickPtr(new gazebo::msgs::FRCJoystick());
joysticksSub[1] = MainNode::Subscribe(
"~/ds/joysticks/1", &DriverStation::joystickCallback1, this);
joysticks[2] = msgs::FRCJoystickPtr(new msgs::FRCJoystick());
joysticks[2] = gazebo::msgs::FRCJoystickPtr(new gazebo::msgs::FRCJoystick());
joysticksSub[2] = MainNode::Subscribe(
"~/ds/joysticks/2", &DriverStation::joystickCallback2, this);
joysticks[3] = msgs::FRCJoystickPtr(new msgs::FRCJoystick());
joysticks[3] = gazebo::msgs::FRCJoystickPtr(new gazebo::msgs::FRCJoystick());
joysticksSub[3] = MainNode::Subscribe(
"~/ds/joysticks/5", &DriverStation::joystickCallback3, this);
joysticks[4] = msgs::FRCJoystickPtr(new msgs::FRCJoystick());
joysticks[4] = gazebo::msgs::FRCJoystickPtr(new gazebo::msgs::FRCJoystick());
joysticksSub[4] = MainNode::Subscribe(
"~/ds/joysticks/4", &DriverStation::joystickCallback4, this);
joysticks[5] = msgs::FRCJoystickPtr(new msgs::FRCJoystick());
joysticks[5] = gazebo::msgs::FRCJoystickPtr(new gazebo::msgs::FRCJoystick());
joysticksSub[5] = MainNode::Subscribe(
"~/ds/joysticks/5", &DriverStation::joystickCallback5, this);
}
@@ -137,7 +137,7 @@ int16_t DriverStation::GetStickButtons(int stick) {
int16_t btns = 0, btnid;
std::unique_lock<std::recursive_mutex> lock(m_joystickMutex);
msgs::FRCJoystickPtr joy = joysticks[stick];
gazebo::msgs::FRCJoystickPtr joy = joysticks[stick];
for (btnid = 0; btnid < joy->buttons().size() && btnid < 12; btnid++) {
if (joysticks[stick]->buttons(btnid)) {
btns |= (1 << btnid);
@@ -212,8 +212,9 @@ bool DriverStation::IsDisabled() const { return !IsEnabled(); }
bool DriverStation::IsAutonomous() const {
std::unique_lock<std::recursive_mutex> lock(m_stateMutex);
return state != nullptr ? state->state() == msgs::DriverStation_State_AUTO
: false;
return state != nullptr
? state->state() == gazebo::msgs::DriverStation_State_AUTO
: false;
}
bool DriverStation::IsOperatorControl() const {
@@ -222,8 +223,9 @@ bool DriverStation::IsOperatorControl() const {
bool DriverStation::IsTest() const {
std::unique_lock<std::recursive_mutex> lock(m_stateMutex);
return state != nullptr ? state->state() == msgs::DriverStation_State_TEST
: false;
return state != nullptr
? state->state() == gazebo::msgs::DriverStation_State_TEST
: false;
}
/**
@@ -360,7 +362,8 @@ void DriverStation::ReportError(bool is_error, int code,
*/
uint16_t DriverStation::GetTeamNumber() const { return 348; }
void DriverStation::stateCallback(const msgs::ConstDriverStationPtr& msg) {
void DriverStation::stateCallback(
const gazebo::msgs::ConstDriverStationPtr& msg) {
{
std::unique_lock<std::recursive_mutex> lock(m_stateMutex);
*state = *msg;
@@ -372,32 +375,38 @@ void DriverStation::stateCallback(const msgs::ConstDriverStationPtr& msg) {
m_waitForDataCond.notify_all();
}
void DriverStation::joystickCallback(const msgs::ConstFRCJoystickPtr& msg,
int i) {
void DriverStation::joystickCallback(
const gazebo::msgs::ConstFRCJoystickPtr& msg, int i) {
std::unique_lock<std::recursive_mutex> lock(m_joystickMutex);
*(joysticks[i]) = *msg;
}
void DriverStation::joystickCallback0(const msgs::ConstFRCJoystickPtr& msg) {
void DriverStation::joystickCallback0(
const gazebo::msgs::ConstFRCJoystickPtr& msg) {
joystickCallback(msg, 0);
}
void DriverStation::joystickCallback1(const msgs::ConstFRCJoystickPtr& msg) {
void DriverStation::joystickCallback1(
const gazebo::msgs::ConstFRCJoystickPtr& msg) {
joystickCallback(msg, 1);
}
void DriverStation::joystickCallback2(const msgs::ConstFRCJoystickPtr& msg) {
void DriverStation::joystickCallback2(
const gazebo::msgs::ConstFRCJoystickPtr& msg) {
joystickCallback(msg, 2);
}
void DriverStation::joystickCallback3(const msgs::ConstFRCJoystickPtr& msg) {
void DriverStation::joystickCallback3(
const gazebo::msgs::ConstFRCJoystickPtr& msg) {
joystickCallback(msg, 3);
}
void DriverStation::joystickCallback4(const msgs::ConstFRCJoystickPtr& msg) {
void DriverStation::joystickCallback4(
const gazebo::msgs::ConstFRCJoystickPtr& msg) {
joystickCallback(msg, 4);
}
void DriverStation::joystickCallback5(const msgs::ConstFRCJoystickPtr& msg) {
void DriverStation::joystickCallback5(
const gazebo::msgs::ConstFRCJoystickPtr& msg) {
joystickCallback(msg, 5);
}

View File

@@ -19,7 +19,7 @@ double simTime = 0;
std::condition_variable time_wait;
std::mutex time_wait_mutex;
void time_callback(const msgs::ConstFloat64Ptr& msg) {
void time_callback(const gazebo::msgs::ConstFloat64Ptr& msg) {
simTime = msg->data();
time_wait.notify_all();
}

View File

@@ -12,12 +12,12 @@
using namespace frc;
SimContinuousOutput::SimContinuousOutput(std::string topic) {
pub = MainNode::Advertise<msgs::Float64>("~/simulator/" + topic);
pub = MainNode::Advertise<gazebo::msgs::Float64>("~/simulator/" + topic);
std::cout << "Initialized ~/simulator/" + topic << std::endl;
}
void SimContinuousOutput::Set(float speed) {
msgs::Float64 msg;
gazebo::msgs::Float64 msg;
msg.set_data(speed);
pub->Publish(msg);
}

View File

@@ -19,6 +19,6 @@ SimDigitalInput::SimDigitalInput(std::string topic) {
bool SimDigitalInput::Get() { return value; }
void SimDigitalInput::callback(const msgs::ConstBoolPtr& msg) {
void SimDigitalInput::callback(const gazebo::msgs::ConstBoolPtr& msg) {
value = msg->data();
}

View File

@@ -12,8 +12,8 @@
using namespace frc;
SimEncoder::SimEncoder(std::string topic) {
commandPub =
MainNode::Advertise<msgs::GzString>("~/simulator/" + topic + "/control");
commandPub = MainNode::Advertise<gazebo::msgs::GzString>("~/simulator/" +
topic + "/control");
posSub = MainNode::Subscribe("~/simulator/" + topic + "/position",
&SimEncoder::positionCallback, this);
@@ -41,15 +41,15 @@ double SimEncoder::GetPosition() { return position; }
double SimEncoder::GetVelocity() { return velocity; }
void SimEncoder::sendCommand(std::string cmd) {
msgs::GzString msg;
gazebo::msgs::GzString msg;
msg.set_data(cmd);
commandPub->Publish(msg);
}
void SimEncoder::positionCallback(const msgs::ConstFloat64Ptr& msg) {
void SimEncoder::positionCallback(const gazebo::msgs::ConstFloat64Ptr& msg) {
position = msg->data();
}
void SimEncoder::velocityCallback(const msgs::ConstFloat64Ptr& msg) {
void SimEncoder::velocityCallback(const gazebo::msgs::ConstFloat64Ptr& msg) {
velocity = msg->data();
}

View File

@@ -19,6 +19,6 @@ SimFloatInput::SimFloatInput(std::string topic) {
double SimFloatInput::Get() { return value; }
void SimFloatInput::callback(const msgs::ConstFloat64Ptr& msg) {
void SimFloatInput::callback(const gazebo::msgs::ConstFloat64Ptr& msg) {
value = msg->data();
}

View File

@@ -12,8 +12,8 @@
using namespace frc;
SimGyro::SimGyro(std::string topic) {
commandPub =
MainNode::Advertise<msgs::GzString>("~/simulator/" + topic + "/control");
commandPub = MainNode::Advertise<gazebo::msgs::GzString>("~/simulator/" +
topic + "/control");
posSub = MainNode::Subscribe("~/simulator/" + topic + "/position",
&SimGyro::positionCallback, this);
@@ -37,15 +37,15 @@ double SimGyro::GetAngle() { return position; }
double SimGyro::GetVelocity() { return velocity; }
void SimGyro::sendCommand(std::string cmd) {
msgs::GzString msg;
gazebo::msgs::GzString msg;
msg.set_data(cmd);
commandPub->Publish(msg);
}
void SimGyro::positionCallback(const msgs::ConstFloat64Ptr& msg) {
void SimGyro::positionCallback(const gazebo::msgs::ConstFloat64Ptr& msg) {
position = msg->data();
}
void SimGyro::velocityCallback(const msgs::ConstFloat64Ptr& msg) {
void SimGyro::velocityCallback(const gazebo::msgs::ConstFloat64Ptr& msg) {
velocity = msg->data();
}