Repository navigation
Simulator
The Marsy simulator is the recommended environment for testing rover control, autonomous missions, sonar-based navigation, mapping, and LLM-generated plans before running the same code on the physical rover.
Marsy uses its own simulator. It is part of the main repository and uses the same high-level motion, skills, behaviors, mission, and safety layers as the real rover.
The simulator is designed as a practical software-development environment. It is not intended to reproduce Martian terrain or rover physics with scientific accuracy.
The simulator supports:
- manual rover control;
- steering and in-place rotation;
- mast movement and ultrasonic scanning;
- obstacle avoidance;
- cautious forward movement;
- mission start and stop behavior;
-
Explore area; - SLAM-lite map generation;
-
AI Agent; - Groq-generated plans;
- LLM replanning after recoverable failures;
- live mission status and sonar telemetry;
- generated-plan inspection;
- latest-map viewing;
- emergency stop and cleanup behavior.
Mission code can normally be moved from simulator mode to real-rover mode without changing the mission itself. The selected backend determines where the commands are sent.
Dashboard or CLI mission
β
Marsy mission / agent executor
β
Skills and reusable behaviors
β
Marsy core and safety checks
β
marsy_backends.sim_backend
β
Simulator HTTP API
β
PyQt simulator window
For the AI Agent:
Natural-language goal
β
Groq planner
β
Validated JSON plan
β
Agent executor
β
Marsy skills
β
Simulator backend
The LLM does not control motors directly. It may only select skills from the Marsy whitelist, and every plan is validated before execution.
marsy/
βββ scripts/
β βββ run_simulator.sh # starts simulator and dashboard together
βββ simulator/
β βββ marsy_sim_ui.py # PyQt simulator and simulator HTTP API
βββ marsy_backends/
β βββ sim_backend.py # simulator backend adapter
βββ marsy_web/
β βββ server.py # dashboard server and mission control
βββ behaviors/
β βββ explore_area.py # shared exploration behavior
βββ missions/
β βββ explore_area.py
β βββ agent_mission.py
βββ marsy_agent/ # planning, validation, execution, and cache
The simulator should be treated as a first-class Marsy development tool, not as an external demo.
Use the Python environment prepared for Marsy. It must include PyQt6 and the project dependencies.
For example:
conda activate marsyCheck PyQt6:
python -c "import PyQt6; print('PyQt6 OK')"To use the AI Agent with new Groq plans or replanning, the same environment must also include the Groq SDK:
python -m pip install groqDetailed Groq setup is documented on the AI Agent Mission page.
From the Marsy project root:
chmod +x scripts/run_simulator.sh
./scripts/run_simulator.shThis is the recommended way to use the simulator.
The launcher automatically:
- selects the active Conda Python, the project
.venv, or another available Python; - loads the stored Groq key when available;
- starts the PyQt simulator;
- waits for the simulator API;
- starts the Marsy web dashboard in
simmode; - opens the dashboard in the default browser;
- stops both processes when the simulator closes or
Ctrl+Cis pressed.
The default addresses are:
Simulator API: http://127.0.0.1:8523/
Dashboard: http://127.0.0.1:8080/
Map viewer: http://127.0.0.1:8080/maps
The terminal should show messages similar to:
Simulator ready: http://127.0.0.1:8523/state
Dashboard ready: http://127.0.0.1:8080/api/state
Marsy simulator is running.
Dashboard: http://127.0.0.1:8080/
Maps: http://127.0.0.1:8080/maps
Keep this terminal open while using the simulator.
MARSY_OPEN_BROWSER=0 ./scripts/run_simulator.shThen open the dashboard manually:
http://127.0.0.1:8080/
MARSY_PYTHON="/path/to/python" ./scripts/run_simulator.shThis is useful when several Conda or virtual environments exist.
The dashboard runs against marsy_backends.sim_backend, so its controls and missions operate on the simulated rover rather than GPIO hardware.
The dashboard provides:
- manual movement controls;
- speed and steering settings;
- mast controls;
- live simulated telemetry;
- sonar scan values over the camera/HUD area;
- current mode and mission status;
- mission timer;
- mission stop controls;
- mission-specific parameters;
- generated AI plan display;
- latest-map access.
The simulator window and dashboard represent the same simulated rover state.
Use the dashboard manual controls to verify that the simulator stack is working before starting an autonomous mission.
Check:
- forward and reverse movement;
- left and right steering;
- in-place rotation;
- wheel centering;
- mast movement;
- STOP;
- emergency stop and reset behavior.
The dashboard safety layer remains active in simulator mode. Forward movement may be stopped if the simulated sonar reports an obstacle within the configured safety distance.
Open:
Missions β Explore area
The mission uses the shared exploration behavior from:
behaviors/explore_area.py
It can:
- scan the simulated environment;
- select a movement or turn action;
- avoid nearby obstacles;
- use cautious movement when some sonar readings are unknown;
- continue a committed turn instead of oscillating between directions;
- save a SLAM-lite occupancy map;
- stop after the configured time or number of steps.
Typical controls include:
- maximum steps;
- run time;
- step distance;
- forward speed;
- safe distance;
- danger distance;
- map resolution;
- optional return-home behavior.
For cautious testing, a useful starting point is:
Step distance: 6 cm
Speed: 22
Start with a short duration and a small number of steps.
Detailed mission behavior is documented on the Explore Area Mission page.
Open:
Missions β AI Agent
The AI Agent card contains:
- a multiline Mission goal field;
- a Groq model dropdown;
- Maximum replans;
- Generate a fresh plan;
- mission start and stop controls;
- the Generated plan panel;
- an Open map button.
The currently available model choices are:
GPT-OSS 20B β fast
GPT-OSS 120B β stronger
openai/gpt-oss-20b is the recommended default for most simulator tests.
Look around, choose the clearest direction, make one cautious 6 cm step,
scan again, choose the clearest direction again, make one more cautious
6 cm step, wait for 2 seconds, and stop. If a path is blocked, try another
direction.
For a new goal, enable:
Generate a fresh plan
For repeated tests with exactly the same goal and model, the cached plan can be reused.
After planning, the dashboard displays:
- plan source: Groq, cache, or Groq replan;
- selected model;
- plan revision;
- number of steps;
- skill names;
- skill arguments;
- the currently executing step;
- the full raw JSON plan.
If replanning occurs, the panel updates to show the replacement remaining plan.
A typical plan may contain:
turn_to_clear_direction
move_forward
scan_arc
wait
explore_for
stop
The plan is validated locally before any movement begins.
New plans and replanning require:
GROQ_API_KEY
The launcher automatically loads the key from:
~/.config/marsy/groq.env
The file should contain:
export GROQ_API_KEY="YOUR_GROQ_API_KEY"Protect it with:
chmod 600 ~/.config/marsy/groq.envA different key file can be selected with:
MARSY_GROQ_ENV="/path/to/groq.env" ./scripts/run_simulator.shA matching cached initial plan may run without a new Groq request, but replanning still requires the key.
Explore area and AI Agent plans that use explore_for can generate a SLAM-lite occupancy map.
Open the viewer from the mission card or directly:
http://127.0.0.1:8080/maps
The current map files are:
artifacts/maps/explore_area_latest.json
artifacts/maps/explore_area_latest.svg
Marsy keeps the latest map rather than creating a permanent pair for every run.
The map viewer can show:
- the rover path;
- visited cells;
- free cells;
- occupied cells;
- map resolution;
- mapping metadata.
A mission that only scans, turns, or makes isolated movement steps may not generate a map. Use Explore area or include explore_for in the AI Agent goal when map generation is required.
The latest AI plan cache is stored in:
artifacts/agent_cache/agent_plan_latest.json
A cache hit requires the same:
- normalized goal;
- planner;
- model;
- planner prompt/schema fingerprint.
The latest AI mission journal is stored in:
artifacts/agent_runs/agent_mission_latest.json
It contains:
- goal;
- model;
- plan source;
- initial plan;
- executed steps;
- observations;
- replans;
- final result;
- errors, when present.
Only the latest cache and latest mission journal are retained.
The unified launcher keeps only the latest simulator-stack logs:
artifacts/logs/simulator_latest.log
artifacts/logs/simulator_dashboard_latest.log
Follow the simulator log:
tail -f artifacts/logs/simulator_latest.logFollow the dashboard log:
tail -f artifacts/logs/simulator_dashboard_latest.logThese files are useful when the browser only reports a generic mission error.
Preferred methods:
- close the PyQt simulator window; or
- press
Ctrl+Cin the terminal runningscripts/run_simulator.sh.
The launcher then stops both the dashboard and simulator processes.
The dashboard's Stop current mission button stops the active mission but leaves the simulator stack running.
The unified script is recommended, but the components can be started separately for debugging.
First terminal:
python simulator/marsy_sim_ui.pySecond terminal:
MARSY_MODE=sim python -m marsy_web.server \
--host 127.0.0.1 \
--port 8080 \
--camera-rotation 0Then open:
http://127.0.0.1:8080/
A CLI mission can also be run while the standalone simulator is active:
MARSY_MODE=sim python -m missions.explore_areaor:
MARSY_MODE=sim python -m missions.agent_mission \
--goal "Look around, make one cautious step, and stop."Do not start a dashboard mission and a standalone CLI mission at the same time. Both would attempt to control the same simulated rover.
| Variable | Default | Purpose |
|---|---|---|
MARSY_PYTHON |
auto-detected | Python interpreter used by the launcher |
MARSY_SIM_HOST |
127.0.0.1 |
Simulator API host |
MARSY_SIM_PORT |
8523 |
Simulator API port |
MARSY_WEB_HOST |
127.0.0.1 |
Dashboard host |
MARSY_WEB_PORT |
8080 |
Dashboard port |
MARSY_OPEN_BROWSER |
1 |
Set to 0 to avoid opening a browser |
MARSY_GROQ_ENV |
~/.config/marsy/groq.env |
Groq environment file |
MARSY_CAMERA_ROTATION |
0 |
Dashboard camera rotation in simulator mode |
Example with custom ports:
MARSY_SIM_PORT=8524 \
MARSY_WEB_PORT=8081 \
./scripts/run_simulator.sh- Activate the Marsy Python environment.
- Start
./scripts/run_simulator.sh. - Verify manual movement and STOP.
- Run a short
Explore areamission. - Inspect sonar telemetry and the latest map.
- Run an AI Agent goal with one short movement.
- Inspect the generated plan before and during execution.
- Test a recoverable blocked condition and replanning.
- Stop the mission from the dashboard.
- Only after simulator behavior is understood, test the same mission on the physical rover at low speed.
Activate the correct Marsy environment:
conda activate marsy
./scripts/run_simulator.shCheck the selected interpreter printed by the launcher.
A specific interpreter can be forced with:
MARSY_PYTHON="/path/to/python" ./scripts/run_simulator.shAn earlier simulator or dashboard process may still be running.
Check:
ps aux | grep -E "marsy_sim_ui.py|marsy_web.server" | grep -v grepStop the matching processes:
pkill -f "simulator/marsy_sim_ui.py"
pkill -f "marsy_web.server"Then restart:
./scripts/run_simulator.shAlternatively, use different ports.
Check that the simulator API is available:
http://127.0.0.1:8523/state
Inspect:
tail -n 80 artifacts/logs/simulator_latest.log
tail -n 80 artifacts/logs/simulator_dashboard_latest.logBoth components must use the same MARSY_SIM_HOST and MARSY_SIM_PORT.
Load the key:
source ~/.config/marsy/groq.envCheck without printing it:
python -c "import os; print('Groq key loaded:', bool(os.getenv('GROQ_API_KEY')))"Then restart the simulator stack.
Enable:
Generate a fresh plan
The new plan replaces:
artifacts/agent_cache/agent_plan_latest.json
A map is generated by exploration behavior. Run Explore area, or use an AI Agent goal that includes exploration, for example:
Look around, choose the clearest direction, explore for 30 seconds, and stop.
Then reload:
http://127.0.0.1:8080/maps
Force-refresh the page:
macOS: Cmd + Shift + R
Windows: Ctrl + F5
Check:
ps aux | grep -E "marsy_sim_ui.py|marsy_web.server|missions" | grep -v grepStop only the matching Marsy processes:
pkill -f "simulator/marsy_sim_ui.py"
pkill -f "marsy_web.server"
pkill -f "python -m missions"Use pkill -9 only when normal termination fails.