Skip to content
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,22 @@ bin/grSim_replay --replay /tmp/pushing.json --helpers 0 > /tmp/serial.json
bin/grSim_replay --replay /tmp/pushing.json --helpers 3 > /tmp/workers.json
```

Both fixture modes use six robots per side. For a bounded loopback command
All fixture modes use six robots per side. `pushing-turning` and
`pushing-turning-fast` add sustained pushing with alternating 2 and 4 rad/s
turn commands for first-impact collision coverage. For a bounded loopback command
capture, use `--record FILE --duration-ms 5000 --blue-port 10301 --yellow-port
10302 --sim-port 10300`. The tool announces its ports, returns command feedback,
and records command-watchdog expiry as explicit events. `--settings FILE` uses
an existing grSim configuration when recording; replay reads its saved settings.
The capture is a fresh headless physics session, with no vision publication,
GUI edits, world configuration changes or arbitrary mid-match checkpoints.
Replays retain the direct double-precision solver and five substeps. Compare
Replays retain the direct double-precision solver. New v2 recordings store the
integration policy. The default adaptive policy uses two steps for settled,
distant motion, at least five during acceleration, turning, sliding or flight,
and finer steps for predicted robot, ball and wall impacts. All bodies share
the same evenly divided fixed tick; short settling guards avoid rapidly
switching the resolution. Historical v1 recordings retain their fixed-five path; older binaries reject v2 rather than silently changing it.
Compare
numerical trajectories within a chosen tolerance across backends; identical
bits on different CPUs are not promised.

Expand Down Expand Up @@ -207,6 +215,10 @@ 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.

The radio 1 profile also uses 125 rad/s² angular speedup/braking limits, selected
from comparisons that held out entire recordings. This is a fitted simulator
control setting; it is not a direct measurement of hardware acceleration.

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.
Expand All @@ -217,4 +229,4 @@ 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.
change the fixed timestep or recorded integration policy.
8 changes: 5 additions & 3 deletions config/Utama-Radio-1.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
; Utama physical robot on radio 1, 27-28 October2026 field logs.
; Geometry/mass are inherited Parsian assumptions; only body-response gains were fitted.
; Geometry/mass are inherited Parsian assumptions.
; Body-response gains and angular control limits were fitted.
[Geometery]
CenterFromKicker= 0.073
Radius = 0.09
Expand Down Expand Up @@ -30,9 +31,10 @@ WheelMotorMaximumApplyingTorque= 0.2
MaxLinearKickSpeed=10
MaxChipKickSpeed=10
AccSpeedupAbsoluteMax=4
AccSpeedupAngularMax=50
; Fitted simulator limits from grouped turn/stop checks, not direct hardware measurements.
AccSpeedupAngularMax=125
AccBrakeAbsoluteMax=4
AccBrakeAngularMax=50
AccBrakeAngularMax=125
VelAbsoluteMax=5
VelAngularMax=20

Expand Down
1 change: 1 addition & 0 deletions include/physics/pworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PWorld
public:
struct StepStatistics {
unsigned contacts = 0;
unsigned integrationSteps = 0;
double maxPenetration = 0;
unsigned callbacks = 0, narrowPhaseCalls = 0, createdContacts = 0;
bool measureTimings = false;
Expand Down
13 changes: 12 additions & 1 deletion include/sslworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ Copyright (C) 2011, Parsian Robotic Center (eew.aut.ac.ir/~parsian/grsim)
class RobotsFormation;
// Alternate values support controlled offline experiments without changing
// networking or personal settings. Legacy friction is only a comparison mode.
enum class IntegrationPolicy { Fixed, NearShellSix, Adaptive };

struct PhysicsStepOptions {
unsigned substeps = 5;
unsigned substeps = 2; // Minimum; activity and predicted impacts select finer steps.
unsigned quickStepIterations = 0;
bool legacyBallFriction = false;
bool finiteWheelRotation = false;
IntegrationPolicy integrationPolicy = IntegrationPolicy::Adaptive;
};

class SendingPacket {
Expand Down Expand Up @@ -82,6 +85,12 @@ class SSLWorld : public QObject
static void processMoveCommand(RobotControlResponse &robotControlResponse, const RobotMoveCommand &robotCommand,
Robot *robot) ;
void releaseBallHolds() const;
bool shellsMayMeet(dReal frameStep) const;
unsigned adaptiveSubsteps(dReal frameStep, unsigned minimum);
dReal previousWheelSpeeds[MAX_ROBOT_COUNT*2][4]{};
dReal previousHorizontalVelocity[MAX_ROBOT_COUNT*2][2]{};
unsigned quietFrames = 0, resolutionDecayFrames = 0, adaptiveResolution = 5;
dReal adaptiveWarmupUntil = 1;
void processTeleportBall(SimulatorResponse &simulatorResponse, const TeleportBall &teleBall) const;
static void processTeleportRobot(const TeleportRobot &teleBot, Robot *robot);
public:
Expand All @@ -96,6 +105,8 @@ class SSLWorld : public QObject
PWorld::StepStatistics* statistics = nullptr);
// Apply the same ball material, mass and optional damping on startup/edit.
void updateBallPhysics();
// Restart fine integration after any externally applied pose/reset edit.
void restartIntegrationSettling();
std::shared_ptr<SceneSnapshot> snapshot(quint64 generation) const;
SSL_WrapperPacket* generatePacket(int cam_id=0);
void addFieldLinesArcs(SSL_GeometryFieldSize *field);
Expand Down
1 change: 1 addition & 0 deletions src/physics/pworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ PSurface* PWorld::findSurface(PObject* o1,PObject* o2)
bool PWorld::step(dReal dt, unsigned quickStepIterations, StepStatistics* statistics)
{
activeStatistics = statistics;
if (statistics) ++statistics->integrationSteps;
bool success = false;
try {
updateCollisionMasks();
Expand Down
13 changes: 11 additions & 2 deletions src/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,26 @@ void SimulationWorker::act(SimulationAction action)
auto releaseBall = [this]() {
for (int i = 0; i < settings.Robots_Count() * 2; ++i) world->robots[i]->kicker->unholdBall();
};
bool placed = false;
switch (action.kind) {
case SimulationActionKind::ResetRobot: if (robot) robot->resetRobot(); break;
case SimulationActionKind::SetRobotEnabled: if (robot) robot->on = action.enabled; break;
case SimulationActionKind::ResetRobot:
if (robot) { robot->resetRobot(); placed = true; }
break;
case SimulationActionKind::SetRobotEnabled:
if (robot) { robot->on = action.enabled; placed = true; }
break;
case SimulationActionKind::PlaceRobot:
if (robot) {
robot->setXY(action.x, action.y);
if (action.reset) robot->resetRobot();
if (action.reset) robot->setDir(action.direction);
placed = true;
}
break;
case SimulationActionKind::PlaceBall:
releaseBall();
world->ball->setBodyPosition(action.x, action.y, action.z);
placed = true;
dBodySetForce(world->ball->body, 0, 0, 0);
dBodySetTorque(world->ball->body, 0, 0, 0);
dBodySetLinearVel(world->ball->body, 0, 0, 0);
Expand Down Expand Up @@ -318,13 +325,15 @@ void SimulationWorker::act(SimulationAction action)
if (action.team < 0 || action.team > 1 || action.formation < 0 || action.formation > 3) break;
RobotsFormation formation(static_cast<E_FORMATION>(action.formation), &settings);
formation.resetRobots(world->robots, action.team);
placed = true;
break;
}
case SimulationActionKind::EnableTeam:
if (action.team >= 0 && action.team < 2)
for (int i = 0; i < count; ++i) world->robots[world->robotIndex(i, action.team)]->on = action.enabled;
break;
}
if (placed) world->restartIntegrationSettling();
publish();
}

Expand Down
Loading
Loading