mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Replace std::to_string() with fmt::format() (#3451)
This commit is contained in:
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "GazeboAnalogIn.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <hal/Power.h>
|
||||
#include <hal/Value.h>
|
||||
#include <hal/simulation/AnalogInData.h>
|
||||
@@ -30,7 +29,7 @@ GazeboAnalogIn::GazeboAnalogIn(int index, HALSimGazebo* halsim) {
|
||||
void GazeboAnalogIn::Listen() {
|
||||
if (!m_sub)
|
||||
m_sub = m_halsim->node.Subscribe<gazebo::msgs::Float64>(
|
||||
"~/simulator/analog/" + std::to_string(m_index),
|
||||
fmt::format("~/simulator/analog/{}", m_index),
|
||||
&GazeboAnalogIn::Callback, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "GazeboDIO.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <hal/Value.h>
|
||||
#include <hal/simulation/DIOData.h>
|
||||
#include <hal/simulation/NotifyListener.h>
|
||||
@@ -29,8 +28,7 @@ GazeboDIO::GazeboDIO(int index, HALSimGazebo* halsim) {
|
||||
void GazeboDIO::Listen() {
|
||||
if (!m_sub)
|
||||
m_sub = m_halsim->node.Subscribe<gazebo::msgs::Bool>(
|
||||
"~/simulator/dio/" + std::to_string(m_index), &GazeboDIO::Callback,
|
||||
this);
|
||||
fmt::format("~/simulator/dio/{}", m_index), &GazeboDIO::Callback, this);
|
||||
}
|
||||
|
||||
void GazeboDIO::Callback(const gazebo::msgs::ConstBoolPtr& msg) {
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "GazeboEncoder.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <hal/Value.h>
|
||||
#include <hal/simulation/EncoderData.h>
|
||||
#include <hal/simulation/NotifyListener.h>
|
||||
@@ -51,8 +50,8 @@ GazeboEncoder::GazeboEncoder(int index, HALSimGazebo* halsim) {
|
||||
void GazeboEncoder::Control(const char* command) {
|
||||
if (!m_pub) {
|
||||
m_pub = m_halsim->node.Advertise<gazebo::msgs::String>(
|
||||
"~/simulator/encoder/dio/" +
|
||||
std::to_string(HALSIM_GetEncoderDigitalChannelA(m_index)) + "/control");
|
||||
fmt::format("~/simulator/encoder/dio/{}/control",
|
||||
HALSIM_GetEncoderDigitalChannelA(m_index)));
|
||||
m_pub->WaitForConnection(gazebo::common::Time(1, 0));
|
||||
}
|
||||
gazebo::msgs::String msg;
|
||||
@@ -64,9 +63,8 @@ void GazeboEncoder::Control(const char* command) {
|
||||
void GazeboEncoder::Listen() {
|
||||
if (!m_sub)
|
||||
m_sub = m_halsim->node.Subscribe<gazebo::msgs::Float64>(
|
||||
"~/simulator/encoder/dio/" +
|
||||
std::to_string(HALSIM_GetEncoderDigitalChannelA(m_index)) +
|
||||
"/position",
|
||||
fmt::format("~/simulator/encoder/dio/{}/position",
|
||||
HALSIM_GetEncoderDigitalChannelA(m_index)),
|
||||
&GazeboEncoder::Callback, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "GazeboPCM.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <hal/Value.h>
|
||||
#include <hal/simulation/CTREPCMData.h>
|
||||
#include <hal/simulation/NotifyListener.h>
|
||||
@@ -38,8 +37,7 @@ GazeboPCM::GazeboPCM(int index, int channel, HALSimGazebo* halsim) {
|
||||
void GazeboPCM::Publish(bool value) {
|
||||
if (!m_pub) {
|
||||
m_pub = m_halsim->node.Advertise<gazebo::msgs::Bool>(
|
||||
"~/simulator/pneumatic/" + std::to_string(m_index + 1) + "/" +
|
||||
std::to_string(m_channel));
|
||||
fmt::format("~/simulator/pneumatic/{}/{}", m_index + 1, m_channel));
|
||||
m_pub->WaitForConnection(gazebo::common::Time(1, 0));
|
||||
}
|
||||
gazebo::msgs::Bool msg;
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
#include "GazeboPWM.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <hal/Value.h>
|
||||
#include <hal/simulation/NotifyListener.h>
|
||||
#include <hal/simulation/PWMData.h>
|
||||
@@ -35,7 +34,7 @@ GazeboPWM::GazeboPWM(int port, HALSimGazebo* halsim) {
|
||||
void GazeboPWM::Publish(double value) {
|
||||
if (!m_pub) {
|
||||
m_pub = m_halsim->node.Advertise<gazebo::msgs::Float64>(
|
||||
"~/simulator/pwm/" + std::to_string(m_port));
|
||||
fmt::format("~/simulator/pwm/{}", m_port));
|
||||
m_pub->WaitForConnection(gazebo::common::Time(1, 0));
|
||||
}
|
||||
gazebo::msgs::Float64 msg;
|
||||
|
||||
Reference in New Issue
Block a user