SITL: add JSON backend example for velocity commanded vehicles - #34078
Open
kenjiked wants to merge 1 commit into
Open
SITL: add JSON backend example for velocity commanded vehicles#34078kenjiked wants to merge 1 commit into
kenjiked wants to merge 1 commit into
Conversation
Walking robots sold as complete products keep their gait controller on board and do not expose their joints. The autopilot asks for a forward speed and a turn rate, and the on-board controller decides how to walk. Unitree's Go2 is one such vehicle. Tracked and differential platforms that take a velocity command over a serial or network link behave the same way. The existing pybullet example covers the other case, where ArduPilot drives the leg joints itself through twelve servo outputs. This adds a backend for the velocity commanded case so Rover navigation, missions and failsafes can be exercised without a physics engine. It uses only the Python standard library. Also included are the Rover parameters the model needs. ATC_STR_RAT_FF is the steering fraction required for one radian per second, so leaving it at the default while the model turns at 1.2 rad/s under states the gain by a factor of four and the vehicle yaws about the target heading without making progress. The model is a plain unicycle with a first order lag. It is not a model of any particular robot and no hardware has been driven from it. Tested by flying a two waypoint AUTO mission in Rover SITL.
kenjiked
force-pushed
the
sitl-json-velocity-example
branch
from
August 16, 2026 07:29
e2867ae to
ffc33d7
Compare
Georacer
reviewed
Aug 16, 2026
Georacer
left a comment
Contributor
There was a problem hiding this comment.
Hello! I've tested it with your instructions and it works: the rover moves around.
Also, nice to have a simple JSON+python demo.
It's a little awkward having to launch it from the simulator directory, but... eh. It's not the end of the world.
One thing: While I understand your argument about AP issuing desired velocity commands, you make it sound like this was the whole point of demonstration for this PR.
However, I don't see how this particular demo is different to any stock AP rover application.
Could you say a little more?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a dependency free JSON backend example for vehicles that ArduPilot commands by velocity rather than by joint angle, together with the Rover parameters that model needs.
Classification & Testing (check all that apply and add your own)
Tested in Rover SITL on macOS. Started the backend, ran
ardurover --model JSON:127.0.0.1with the includeddefault.parm, uploaded a two waypoint mission (30 m north, then 30 m east), armed and switched to AUTO. Both waypoints were reached, closest approach 0.27 m and 2.96 m. No hardware was driven from this.Nothing outside
libraries/SITL/examples/JSON/python/is touched, and no existing file is modified.flake8passes with the repository configuration.Description
libraries/SITL/examples/JSON/pybullet/walking_robot.pymodels a walking robot whose twelve leg joints ArduPilot drives directly through twelve servo outputs.Walking robots sold as complete products work the other way around: the gait controller stays on board and the joints are not exposed. The autopilot asks for a forward speed and a turn rate, and the on-board controller decides how to walk. Unitree's Go2 is one such vehicle. Tracked and differential platforms that accept a velocity command over a serial or network link present the same interface.
This adds a backend for that case, so Rover's navigation, mission and failsafe code can be exercised against a velocity commanded vehicle. The vehicle model is a plain unicycle with a first order lag standing in for the on-board controller. It uses only the Python standard library, so it runs without pybullet or any other simulator.
default.parmcarries the matching Rover parameters. Two are easy to get wrong and are documented in the readme:ATC_STR_RAT_FFis the steering fraction required for one radian per second, so it is1 / max turn rate. Left at the default while the model turns at 1.2 rad/s it under states the gain by a factor of four, and the vehicle yaws about the target heading without making meaningful forward progress.CRUISE_SPEEDandCRUISE_THROTTLEhave to describe the same vehicle as the model's maximum speed.The readme also records two things that cost me time and may help anyone writing a similar backend:
AP_MotorsUGVcomputesmotor_left = throttle + steering, so a positive turn rate means the left motor runs faster. With that sign inverted the vehicle settles pointing 180 degrees away from the target and yaws forever, which is not obvious to diagnose.