Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ jobs:
cd "$RUNNER_TEMP/grSim-download"
unset QT_PLUGIN_PATH QT_QPA_PLATFORM_PLUGIN_PATH QML2_IMPORT_PATH DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH
./grSim.app/Contents/MacOS/grSim --smoke-test
./grSim.app/Contents/MacOS/grSim --smoke-test \
--settings "$PWD/grSim.app/Contents/Resources/config/Utama-Field-20261028.xml"

# Windows build does not work currently, see https://github.com/RoboCup-SSL/grSim/issues/183
# build-windows:
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ foreach(dependency vartypes_external protobuf_external ode_external)
endforeach()
target_sources(${app} PRIVATE src/main.cpp)
if(APPLE AND GRSIM_MACOSX_BUNDLE)
file(GLOB CONFIG_FILES "config/*.ini")
file(GLOB CONFIG_FILES "config/*.ini" "config/*.xml")
set_source_files_properties(${CONFIG_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/config")
set(app_icon "${PROJECT_SOURCE_DIR}/resources/icons/grsim.icns")
set_source_files_properties("${app_icon}" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
Expand Down Expand Up @@ -324,9 +324,13 @@ if(BUILD_TESTING)
target_sources(${app} PRIVATE tests/application_smoke.cpp)
target_compile_definitions(${app} PRIVATE GRSIM_BUILD_SMOKE_TEST)
add_test(NAME application_smoke COMMAND $<TARGET_FILE:${app}> --smoke-test)
add_test(NAME application_smoke_field_profile COMMAND $<TARGET_FILE:${app}>
--smoke-test --settings "${PROJECT_SOURCE_DIR}/config/Utama-Field-20261028.xml")
set_tests_properties(application_smoke_field_profile PROPERTIES
TIMEOUT 20 LABELS "opengl")
set_tests_properties(application_smoke PROPERTIES TIMEOUT 20 LABELS "opengl")
if(UNIX AND NOT APPLE)
set_tests_properties(application_smoke PROPERTIES
set_tests_properties(application_smoke application_smoke_field_profile PROPERTIES
ENVIRONMENT "QT_QPA_PLATFORM=xcb;LIBGL_ALWAYS_SOFTWARE=1")
endif()
add_executable(grSim_timing_test tests/timing_regression.cpp)
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,32 @@ ER-Force 2016 fitted coefficients. These describe that team's field and ball,
not a calibration of another setup. `--require-agreement` makes a reference
mismatch return failure. Raw measurements and generated recordings should stay
outside Git.

### Utama physical-field calibration

`config/Utama-Field-20261028.xml` selects the two measured robot models (yellow:
radio 0, blue: radio 1), six robots per side, and 0.20 m/s² ball rolling
deceleration. Start with `grSim --settings config/Utama-Field-20261028.xml`.
The file applies to this run; saved personal settings are unchanged. In a Mac
bundle it is under `grSim.app/Contents/Resources/config/`.

The profiles use physical logs from 27–28 October in
[Utama-Core v2.5.0](https://github.com/First-Order-RoboCup-SSL/Utama-Core/releases/tag/v2.5.0).
SIM logs, the simulated tournament, uncertain 21 October logs, setup-only
segments and invalid starting states were excluded from fitting. Robot gains
were checked on held-out command steps, and ball rolling on held-out source logs.
Geometry and masses remain assumptions from Parsian; these logs do not measure
them. Response is validated for the observed drives (up to 1 m/s) and turns
(1–4 rad/s), not all possible commands.

Local/global body-velocity commands use separate forward/left gains and angular
gain `AngularVelocityScale + AngularVelocityScaleSlope * abs(requested_turn)`.
Teleport velocity targets and raw wheel-speed commands keep their existing meaning.
General models retain unit
gains and zero slope. Camera/radio delay, vision noise, kicker charge and dribbler
loss are separate effects; this profile does not fit those into ODE or duplicate
an external hardware-noise layer. Use one actuator-response model in the stack.

For physics comparisons, `grSim_replay --replay FILE --checkpoint-every 1` saves
every simulation tick. The default interval remains 30 ticks; diagnostics do not
change the fixed timestep or five ODE substeps.
18 changes: 18 additions & 0 deletions config/Utama-Field-20261028.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!-- Utama field, physical logs from 27-28 October 2026 (Utama-Core v2.5.0).
Calibrates ground rolling and body-velocity response of the two measured robots.
Ball rolling was checked on held-out logs; robot response on held-out moves. -->
<VarXML>
<Var name="Geometry" type="list">
<Var name="Game" type="list">
<Var name="Robots Count" type="int">6</Var>
</Var>
<Var name="Yellow Team" type="stringenum">Utama-Radio-0</Var>
<Var name="Blue Team" type="stringenum">Utama-Radio-1</Var>
</Var>
<Var name="Physics" type="list">
<Var name="Ball" type="list">
<Var name="Ball rolling deceleration (m/s^2)" type="double">0.20</Var>
</Var>
</Var>
</VarXML>
43 changes: 43 additions & 0 deletions config/Utama-Radio-0.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
; Utama physical robot on radio 0, 27-28 October2026 field logs.
; Geometry/mass are inherited Parsian assumptions; only body-response gains were fitted.
[Geometery]
CenterFromKicker= 0.073
Radius = 0.09
Height = 0.147
RobotBottomZValue = 0.02
KickerZValue = 0.005
KickerThickness = 0.005
KickerWidth = 0.08
KickerHeight = 0.04
WheelRadius = 0.027
WheelThickness = 0.005
Wheel1Angle = 60
Wheel2Angle = 135
Wheel3Angle = 225
Wheel4Angle = 300
[Physics]
Bodymass = 2
Wheelmass = 0.2
Kickermass =0.02
KickerDampFactor = 0.2
RollerTorqueFactor = 0.06
RollerPerpendicularTorqueFactor = 0.005
KickerFriction = 0.8
WheelTangentFriction = 0.8
WheelPerpendicularFriction = 0.05
WheelMotorMaximumApplyingTorque= 0.2

MaxLinearKickSpeed=10
MaxChipKickSpeed=10
AccSpeedupAbsoluteMax=4
AccSpeedupAngularMax=50
AccBrakeAbsoluteMax=4
AccBrakeAngularMax=50
VelAbsoluteMax=5
VelAngularMax=20

[Actuation]
ForwardVelocityScale=0.974
LeftVelocityScale=0.958
AngularVelocityScale=1.002
AngularVelocityScaleSlope=0.021
43 changes: 43 additions & 0 deletions config/Utama-Radio-1.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
; Utama physical robot on radio 1, 27-28 October2026 field logs.
; Geometry/mass are inherited Parsian assumptions; only body-response gains were fitted.
[Geometery]
CenterFromKicker= 0.073
Radius = 0.09
Height = 0.147
RobotBottomZValue = 0.02
KickerZValue = 0.005
KickerThickness = 0.005
KickerWidth = 0.08
KickerHeight = 0.04
WheelRadius = 0.027
WheelThickness = 0.005
Wheel1Angle = 60
Wheel2Angle = 135
Wheel3Angle = 225
Wheel4Angle = 300
[Physics]
Bodymass = 2
Wheelmass = 0.2
Kickermass =0.02
KickerDampFactor = 0.2
RollerTorqueFactor = 0.06
RollerPerpendicularTorqueFactor = 0.005
KickerFriction = 0.8
WheelTangentFriction = 0.8
WheelPerpendicularFriction = 0.05
WheelMotorMaximumApplyingTorque= 0.2

MaxLinearKickSpeed=10
MaxChipKickSpeed=10
AccSpeedupAbsoluteMax=4
AccSpeedupAngularMax=50
AccBrakeAbsoluteMax=4
AccBrakeAngularMax=50
VelAbsoluteMax=5
VelAngularMax=20

[Actuation]
ForwardVelocityScale=0.962
LeftVelocityScale=0.924
AngularVelocityScale=0.958
AngularVelocityScaleSlope=0.023
2 changes: 1 addition & 1 deletion include/robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Robot {
~Robot();
void step();
void setSpeed(int i,dReal s); //i = 0,1,2,3
void setSpeed(dReal vx, dReal vy, dReal vw);
void setSpeed(dReal vx, dReal vy, dReal vw, bool applyResponse = true);
dReal getSpeed(int i);
void incSpeed(int i,dReal v);
void resetSpeeds();
Expand Down
13 changes: 10 additions & 3 deletions include/simulationsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class RobotSettings {
double AccBrakeAngularMax;
double VelAbsoluteMax;
double VelAngularMax;
// Measured body-velocity response to local/global velocity commands.
double ForwardVelocityScale = 1;
double LeftVelocityScale = 1;
double AngularVelocityScale = 1;
double AngularVelocityScaleSlope = 0; // gain per absolute commanded rad/s
bool operator==(const RobotSettings& other) const {
for (auto member : members())
if (this->*member != other.*member) return false;
Expand All @@ -53,8 +58,8 @@ class RobotSettings {
}

private:
static const std::array<double RobotSettings::*, 32>& members() {
static const std::array<double RobotSettings::*, 32> values{{
static const std::array<double RobotSettings::*, 36>& members() {
static const std::array<double RobotSettings::*, 36> values{{
&RobotSettings::RobotCenterFromKicker, &RobotSettings::RobotRadius,
&RobotSettings::RobotHeight, &RobotSettings::BottomHeight,
&RobotSettings::KickerZ, &RobotSettings::KickerThickness,
Expand All @@ -70,7 +75,9 @@ class RobotSettings {
&RobotSettings::MaxChipKickSpeed, &RobotSettings::AccSpeedupAbsoluteMax,
&RobotSettings::AccSpeedupAngularMax, &RobotSettings::AccBrakeAbsoluteMax,
&RobotSettings::AccBrakeAngularMax, &RobotSettings::VelAbsoluteMax,
&RobotSettings::VelAngularMax
&RobotSettings::VelAngularMax, &RobotSettings::ForwardVelocityScale,
&RobotSettings::LeftVelocityScale, &RobotSettings::AngularVelocityScale,
&RobotSettings::AngularVelocityScaleSlope
}};
return values;
}
Expand Down
33 changes: 33 additions & 0 deletions src/configwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)

#include <memory>
#include <QTimer>
#include <QFile>
#include <QFileInfo>
#include <QXmlStreamReader>
#include <stdexcept>
#include <cmath>

#define ADD_ENUM(type,name,Defaultvalue,namestring) \
v_##name = std::shared_ptr<VarTypes::Var##type>(new VarTypes::Var##type(namestring,Defaultvalue)); \
Expand Down Expand Up @@ -49,9 +54,26 @@ static QString robotConfigDirectory()
return executable.absoluteFilePath("../config");
}

// Explicit settings are configuration input, not a request to silently use
// defaults. The implicit personal settings path keeps its historical fallback.
static void validateSettingsFile(const QString& path)
{
QFile input(path);
if (!QFileInfo(path).isFile() || !input.open(QIODevice::ReadOnly))
throw std::runtime_error("Requested settings must be an existing readable regular file");
QXmlStreamReader xml(&input);
if (!xml.readNextStartElement() || xml.qualifiedName() != QLatin1String("VarXML") ||
!xml.namespaceUri().isEmpty())
throw std::runtime_error("Requested settings must have a VarXML root");
while (!xml.atEnd()) xml.readNext();
if (xml.hasError())
throw std::runtime_error("Requested settings contain invalid XML");
}

ConfigWidget::ConfigWidget(bool persist, const QString& settingsPath)
: persistSettings(persist), settingsFile(settingsPath.isEmpty()
? QDir::homePath() + QString("/.grsim.xml") : settingsPath) {
if (!settingsPath.isEmpty()) validateSettingsFile(settingsPath);
tmodel=new VarTreeModel();
this->setModel(tmodel);
geo_vars = std::make_shared<VarList>("Geometry");
Expand Down Expand Up @@ -332,6 +354,17 @@ void ConfigWidget::loadRobotSettings(QString team)
robotSettings.AccBrakeAngularMax = robot_settings->value("Physics/AccBrakeAngularMax", 50).toDouble();
robotSettings.VelAbsoluteMax = robot_settings->value("Physics/VelAbsoluteMax", 5).toDouble();
robotSettings.VelAngularMax = robot_settings->value("Physics/VelAngularMax", 20).toDouble();
auto velocityScale = [&](const char* name) {
const double value = robot_settings->value(QString("Actuation/") + name, 1.0).toDouble();
if (std::isfinite(value) && value > 0) return value;
qWarning("Invalid %s in robot model; using unit response", name);
return 1.0;
};
robotSettings.ForwardVelocityScale = velocityScale("ForwardVelocityScale");
robotSettings.LeftVelocityScale = velocityScale("LeftVelocityScale");
robotSettings.AngularVelocityScale = velocityScale("AngularVelocityScale");
const double slope = robot_settings->value("Actuation/AngularVelocityScaleSlope", 0.0).toDouble();
robotSettings.AngularVelocityScaleSlope = std::isfinite(slope) && slope >= 0 ? slope : 0;
}

SimulationSettings ConfigWidget::simulationSettings()
Expand Down
20 changes: 17 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)
*/
#include <QtWidgets/QApplication>
#include "mainwindow.h"
#include <cstdio>
#include <stdexcept>

#ifdef GRSIM_BUILD_SMOKE_TEST
int runApplicationSmokeTest(QApplication& app);
int runApplicationSmokeTest(QApplication& app, const QString& settingsPath);
#endif

int main(int argc, char *argv[])
Expand All @@ -37,16 +39,28 @@ int main(int argc, char *argv[])
QCommandLineOption headlessOption(QStringList() << "H" << "headless",
QCoreApplication::translate("main", "Run without a UI"));
parser.addOption(headlessOption);
QCommandLineOption settingsOption("settings",
"Read an XML configuration for this run without changing saved settings.", "file");
parser.addOption(settingsOption);
#ifdef GRSIM_BUILD_SMOKE_TEST
QCommandLineOption smokeOption("smoke-test", "Check application resources, rendering and UDP, then exit.");
parser.addOption(smokeOption);
#endif
parser.process(a);
ConfigWidget* config = nullptr;
try {
if (parser.isSet(settingsOption) && parser.value(settingsOption).isEmpty())
throw std::runtime_error("Expected a nonempty settings filename");
#ifdef GRSIM_BUILD_SMOKE_TEST
if (parser.isSet(smokeOption)) return runApplicationSmokeTest(a);
if (parser.isSet(smokeOption)) return runApplicationSmokeTest(a, parser.value(settingsOption));
#endif
if (parser.isSet(settingsOption)) config = new ConfigWidget(false, parser.value(settingsOption));
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
return 2;
}

MainWindow w;
MainWindow w(nullptr, config);
if (parser.isSet(headlessOption)) {
// enable headless mode
w.hide();
Expand Down
10 changes: 9 additions & 1 deletion src/robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,16 @@ void Robot::setSpeed(int i,dReal s)
wheels[i]->speed = s;
}

void Robot::setSpeed(dReal vx, dReal vy, dReal vw)
void Robot::setSpeed(dReal vx, dReal vy, dReal vw, bool applyResponse)
{
if (applyResponse) {
vx *= settings.ForwardVelocityScale;
vy *= settings.LeftVelocityScale;
const double angularScale = settings.AngularVelocityScaleSlope == 0
? settings.AngularVelocityScale
: settings.AngularVelocityScale + settings.AngularVelocityScaleSlope * std::abs(vw);
vw *= angularScale;
}
dReal _DEG2RAD = M_PI / 180.0;

dReal v = sqrt(vx * vx + vy * vy);
Expand Down
3 changes: 2 additions & 1 deletion src/sslworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,8 @@ void SSLWorld::processTeleportRobot(const TeleportRobot &teleBot, Robot *robot)

dReal vxLocal = (vx * cos(-orientation)) - (vy * sin(-orientation));
dReal vyLocal = (vy * cos(-orientation)) + (vx * sin(-orientation));
robot->setSpeed(vxLocal, vyLocal, vAngular);
// Teleport velocities are state targets, not hardware actuation commands.
robot->setSpeed(vxLocal, vyLocal, vAngular, false);

if (teleBot.has_present()) {
robot->on = teleBot.present();
Expand Down
13 changes: 8 additions & 5 deletions tests/application_smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@

// Run through the real executable and its installed resources; never read or
// write personal settings. CTest and the relocated macOS artifact use this path.
int runApplicationSmokeTest(QApplication& app)
int runApplicationSmokeTest(QApplication& app, const QString& settingsPath)
{
QUdpSocket vision, feedback, reserve;
if (!vision.bind(QHostAddress(QHostAddress::LocalHost), 0) ||
!feedback.bind(QHostAddress(QHostAddress::LocalHost), 0) ||
!reserve.bind(QHostAddress(QHostAddress::LocalHost), 0)) return 2;
const quint16 controlPort = reserve.localPort();
reserve.close();
auto* config = new ConfigWidget(false);
config->v_BlueTeam->setString("Parsian");
config->v_YellowTeam->setString("Parsian");
config->loadRobotsSettings();
auto* config = new ConfigWidget(false, settingsPath);
if (settingsPath.isEmpty()) {
config->v_BlueTeam->setString("Parsian");
config->v_YellowTeam->setString("Parsian");
config->loadRobotsSettings();
}
std::printf("Settings: rolling_deceleration=%.2f\n", config->BallRollingDeceleration());
const auto model = config->simulationSettings().blueSettings;
const bool resources = std::abs(model.RobotHeight - 0.147) < 1e-9 &&
std::abs(model.WheelRadius - 0.027) < 1e-9;
Expand Down
Loading
Loading