mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Replace std::to_string() with fmt::format() (#3451)
This commit is contained in:
@@ -47,6 +47,7 @@ model {
|
||||
linker.args gazebo_linker_args
|
||||
cppCompiler.args gazebo_cppflags
|
||||
lib project: ":simulation:gz_msgs", library: "gz_msgs", linkage: "static"
|
||||
lib project: ":wpiutil", library: "wpiutil", linkage: "static"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,6 +15,7 @@ repoRootNameOverride {
|
||||
includeOtherLibs {
|
||||
^cameraserver/
|
||||
^cscore
|
||||
^fmt/
|
||||
^frc/
|
||||
^hal/
|
||||
^imgui
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
#include "frc2/command/WaitCommand.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <frc/fmt/Units.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
WaitCommand::WaitCommand(units::second_t duration) : m_duration{duration} {
|
||||
auto durationStr = std::to_string(duration.to<double>());
|
||||
SetName(fmt::format("{}: {} seconds", GetName(), durationStr));
|
||||
SetName(fmt::format("{}: {}", GetName(), duration));
|
||||
}
|
||||
|
||||
void WaitCommand::Initialize() {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "frc/trajectory/TrajectoryParameterizer.h"
|
||||
|
||||
#include <string>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "units/math.h"
|
||||
|
||||
@@ -193,9 +193,9 @@ Trajectory TrajectoryParameterizer::TimeParameterizeTrajectory(
|
||||
// delta_x = v * t
|
||||
dt = ds / v;
|
||||
} else {
|
||||
throw std::runtime_error("Something went wrong at iteration " +
|
||||
std::to_string(i) +
|
||||
" of time parameterization.");
|
||||
throw std::runtime_error(fmt::format(
|
||||
"Something went wrong at iteration {} of time parameterization.",
|
||||
i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user