Repository navigation
Marsy Skills
Marsy Skills is the high-level capability layer used by missions and intended for future LLM-based planning.
The layer provides bounded movement, ultrasonic sensing, mapping, camera operations, visual search, marker navigation, status LEDs, and user interaction through one consistent API.
Skills are short, bounded actions. Continuous manual driving remains a separate mission.
Mission or LLM planner
β
βΌ
MarsySkills
β
βββ MarsyMotion
βββ MarsySensors
βββ VisionSystem
βββ SparseOccupancyGrid
βββ Telemetry
β
βΌ
Real or simulator backend
The main implementation is located in:
skills/
βββ __init__.py
βββ marsy_skills.py
βββ mapping.py
βββ models.py
βββ registry.py
βββ vision.py
| File | Purpose |
|---|---|
marsy_skills.py |
Implements the high-level skills and safety logic |
registry.py |
Defines tool schemas for LLM/function-calling integration |
models.py |
Shared models such as Pose2D, RangeSample, Detection, and SkillResult
|
mapping.py |
Sparse occupancy grid, path tracking, JSON export, and SVG export |
vision.py |
Camera capture, detector adapters, and optional ArUco detection |
__init__.py |
Public imports for the skills package |
from marsy_backends.loader import load_rover
from marsy_core.motion import MarsyMotion
from marsy_core.sensors import MarsySensors
from skills import MarsySkills, SkillsConfig, SparseOccupancyGrid
rover = load_rover()
rover.init(25)
motion = MarsyMotion(rover)
sensors = MarsySensors(rover)
config = SkillsConfig(
safe_distance_cm=40,
danger_distance_cm=24,
)
occupancy_map = SparseOccupancyGrid(
resolution_cm=5,
max_range_cm=200,
)
skills = MarsySkills(
rover,
motion=motion,
sensors=sensors,
occupancy_map=occupancy_map,
config=config,
)
try:
result = skills.move_forward(distance_cm=10, speed=25)
print(result.to_dict())
finally:
skills.stop()
rover.cleanup()The backend is selected through MARSY_MODE:
MARSY_MODE=simor:
MARSY_MODE=realEvery skill returns a SkillResult.
Typical fields:
{
"skill": "move_forward",
"ok": true,
"status": "completed",
"message": "Moved forward about 10.0 cm",
"data": {
"travelled_cm": 10.0
}
}| Field | Meaning |
|---|---|
skill |
Skill name |
ok |
Whether the operation completed successfully |
status |
Machine-readable result status |
message |
Human-readable explanation |
data |
Skill-specific data |
started_at |
Start timestamp |
finished_at |
Finish timestamp |
Common statuses include:
completed
cautious
bounded
blocked
clear
found
not_found
stopped
timeout
unavailable
invalid_arguments
error
Skills can be called directly:
skills.rotate(angle_deg=30, speed=25)They can also be dispatched by name:
result = skills.call(
"move_forward",
distance_cm=10,
speed=25,
)The list of available names is exposed by:
MarsySkills.names()The LLM-compatible function schemas are exposed by:
MarsySkills.schemas()The schemas are defined in skills/registry.py and can be passed to a planner that supports tool or function calling.
Movement skills stop automatically. A single command cannot run indefinitely.
The default upper bound is:
MARSY_SKILLS_MAX_MOTION_S=5.0
Longer requested movement is truncated and reported with the bounded status.
Marsy uses two separate safety thresholds:
| Threshold | Default | Purpose |
|---|---|---|
| Safe distance | 35 cm | Normal minimum clearance for movement |
| Danger distance | 22 cm | Hard-stop zone for any real close echo |
Mission-specific values can override these defaults.
Distance measurements are collected as a short series and summarized with a median.
Possible quality labels:
| Quality | Meaning |
|---|---|
measured |
Enough consistent valid readings |
no_echo |
No valid ultrasonic echo |
insufficient |
Too few valid readings |
unstable |
Readings vary too much |
suspicious_far |
Isolated far reading inconsistent with nearby scan sectors |
Unknown or unreliable measurements are preserved as uncertainty. They are not silently converted into clear space.
The current working real-rover configuration permits a cautious forward creep when the front range is uncertain:
Distance: 6 cm
Speed: 22
This behavior is controlled by:
MARSY_UNCERTAIN_STEP_CM=6
MARSY_UNCERTAIN_SPEED=22
A real echo inside the danger zone still stops the rover immediately, even when the rest of the measurement series is unstable.
Only trusted ultrasonic rays update the occupancy grid.
Untrusted rays do not mark a long free corridor. This avoids creating false free space from missing echoes, unstable readings, or reflections from distant objects.
move_forward(
distance_cm: float = 10.0,
speed: int = 35,
require_recent_scan: bool = False,
)Moves forward for a bounded estimated distance.
Behavior:
- centers the mast before movement;
- collects a three-reading front measurement;
- refuses normal movement for a trusted obstacle inside the safe distance;
- stops immediately for any real echo inside the danger distance;
- uses the current 6 cm / speed 22 cautious creep when the front range is uncertain;
- continues checking the sonar while moving;
- updates the estimated pose and map path.
When require_recent_scan=True, a recent front corridor assessment is required.
Important result data:
travelled_cm
requested_distance_cm
commanded_distance_cm
commanded_speed
cautious
uncertain_checks
pose
move_backward(
distance_cm: float = 8.0,
speed: int = 25,
)Moves backward for a bounded estimated distance.
The rover currently has no rear ultrasonic sensor, so reverse movement does not have the same obstacle protection as forward movement.
Use short reverse distances.
turn_left(
angle_deg: float = 35.0,
speed: int = 30,
steer_angle: float = 28.0,
)Drives a bounded forward steering arc to the left.
This is an Ackermann-like moving turn, not a rotation around the rover center.
turn_right(
angle_deg: float = 35.0,
speed: int = 30,
steer_angle: float = 28.0,
)Drives a bounded forward steering arc to the right.
rotate(
angle_deg: float,
speed: int = 30,
)Rotates approximately in place.
Angle convention:
positive angle β right / clockwise
negative angle β left / counter-clockwise
Before rotation, the four steerable corner wheels are placed in the rotation pose. The wheels are returned to the neutral pose afterwards.
The middle wheel pair does not steer, so some tire scrub remains on high-friction surfaces.
stop(
brake: bool = False,
reset_pose: bool = True,
)Stops the motors.
Options:
-
brake=False: normal stop; -
brake=True: active braking; -
reset_pose=True: return steering and mast to their neutral positions.
measure_distance(
samples: int = 3,
sample_delay_s: float = 0.04,
)Collects multiple ultrasonic readings and reports:
distance_cm
quality
readings
spread_cm
minimum_valid_cm
The returned distance is the median of valid readings.
scan_arc(
start_deg: float = -60.0,
end_deg: float = 60.0,
step_deg: float = 30.0,
samples: int = 3,
angles: list[float] | None = None,
on_sample=None,
)Sweeps the mast-mounted ultrasonic sensor across an arc.
Example with generated angles:
scan = skills.scan_arc(
start_deg=-60,
end_deg=60,
step_deg=30,
)Example with explicit angles:
scan = skills.scan_arc(
angles=[0, -25, 25, -50, 50, -75, 75],
samples=3,
)Each result is stored as a RangeSample with:
mast_angle_deg
global_angle_deg
distance_cm
quality
readings
spread_cm
pose
A callback can receive partial scan results:
def on_sample(sample, collected):
print(sample.mast_angle_deg, sample.distance_cm)
skills.scan_arc(
angles=[0, -25, 25],
on_sample=on_sample,
)The dashboard uses partial results to update the camera distance arc during a mission.
scan_360(
step_deg: float = 45.0,
rotate_speed: int = 30,
)Builds a 360-degree sonar observation by repeatedly:
- scanning at
-45Β°,0Β°, and+45Β°; - rotating the rover by one sector;
- adding trusted measurements to the occupancy map.
This is a rover rotation plus multiple mast scans, not a single instantaneous 360-degree sensor measurement.
assess_forward_corridor(
samples=None,
max_age_s=None,
)Internal helper used by movement and missions.
It evaluates the front sectors near:
-25Β°, 0Β°, +25Β°
Possible outcomes:
| Status | Safe | Meaning |
|---|---|---|
clear |
Yes | Trusted front readings are above the safe distance |
uncertain_clear |
Yes, cautious only | One or more front sectors are unknown or unstable |
blocked |
No | Trusted obstacle inside the safe distance or real echo inside the danger distance |
stale_scan |
No | A recent scan is required but unavailable |
avoid_obstacle()Performs one bounded obstacle-avoidance action using behaviors/avoid_obstacle.py.
The behavior:
- reads the front distance;
- stops when an obstacle is close;
- reverses when dangerously close;
- scans left, center, and right;
- chooses the more open direction;
- performs one bounded turn.
This is a single behavior step, not a complete mission loop.
capture_image(
filename: str | None = None,
)Captures one image into:
artifacts/captures/
The camera layer tries:
- Picamera2;
-
rpicam-still; -
libcamera-still.
The configured camera rotation is applied. For the current physical Marsy camera:
MARSY_CAMERA_ROTATION=90
search_visual(
query: str,
step_deg: float = 30.0,
max_rotation_deg: float = 360.0,
min_confidence: float = 0.25,
)Captures images while rotating until the requested object is detected or the rotation limit is reached.
General object search requires a configured detector, VLM adapter, or CallableDetector.
track_object(
query: str,
tolerance: float = 0.10,
max_iterations: int = 8,
)Attempts to center a detected object horizontally in the camera image using small rover rotations.
The detector must provide a normalized bounding box.
approach_object(
query: str,
target_distance_cm: float = 35.0,
step_distance_cm: float = 8.0,
max_steps: int = 12,
)Repeatedly:
- tracks and centers the object;
- measures the front sonar distance;
- moves forward in bounded steps;
- stops at the requested stand-off distance.
The sonar measures the nearest reflecting object in its beam. It does not prove that the measured distance belongs to the visual target.
find_marker(
marker_id: int | None = None,
search: bool = True,
step_deg: float = 30.0,
)Searches for an ArUco marker.
Requirements:
OpenCV
cv2.aruco
camera access
When marker_id is omitted, any supported marker may match.
go_to_marker(
marker_id: int,
target_distance_cm: float = 35.0,
)Combines marker search, centering, and approach.
set_led_status(status: str)Supported semantic states:
| Status | RGB |
|---|---|
off |
(0, 0, 0) |
idle |
(0, 70, 180) |
moving |
(255, 255, 255) |
exploring |
(0, 180, 160) |
waiting |
(150, 50, 180) |
obstacle |
(255, 120, 0) |
success |
(0, 220, 70) |
error |
(255, 0, 0) |
return_home(
tolerance_cm: float = 12.0,
)Returns toward the pose recorded when the MarsySkills object was created or when home_pose was explicitly reset.
The skill uses the current pose estimate, bounded rotations, forward motion, and obstacle avoidance.
On the simulator, the pose can come from simulator ground truth.
On the physical rover, the pose is currently based on time-based dead reckoning. Error accumulates with wheel slip, steering error, and rotation.
return_home is experimental on the real rover.
wait_for_user(
prompt: str = "Press Enter to continue",
timeout_s: float | None = None,
source: str = "either",
)Supported sources:
terminal
switch
either
The skill waits without blocking safety-stop handling.
The main environment variables are:
| Variable | Default | Meaning |
|---|---|---|
MARSY_FULL_SPEED_CM_S |
9.0 |
Estimated speed at motor speed 100 |
MARSY_FULL_SPIN_DEG_S |
36.0 |
Estimated rotation rate at speed 100 |
MARSY_WHEELBASE_CM |
16.0 |
Wheelbase used for arc estimation |
MARSY_SKILLS_SAFE_DISTANCE_CM |
35.0 |
Normal forward safety distance |
MARSY_SKILLS_DANGER_DISTANCE_CM |
22.0 |
Hard-stop distance |
MARSY_SKILLS_MAX_MOTION_S |
5.0 |
Maximum duration of one movement command |
MARSY_SKILLS_MOTION_SLICE_S |
0.12 |
Interval between movement safety checks |
MARSY_SKILLS_SCAN_SETTLE_S |
0.35 |
Mast settling time before measurement |
MARSY_SKILLS_MAX_RANGE_CM |
200.0 |
Maximum accepted sonar range |
MARSY_DISTANCE_SPREAD_ABS_CM |
12.0 |
Absolute allowed spread between samples |
MARSY_DISTANCE_SPREAD_RATIO |
0.25 |
Relative allowed spread |
MARSY_SUSPICIOUS_FAR_CM |
140.0 |
Start of suspicious-far detection |
MARSY_SUSPICIOUS_JUMP_CM |
50.0 |
Large difference from neighboring sectors |
MARSY_SUSPICIOUS_RATIO |
1.5 |
Suspicious-far ratio |
MARSY_RECENT_SCAN_MAX_AGE_S |
8.0 |
Maximum age of a scan used for corridor assessment |
MARSY_UNCERTAIN_STEP_CM |
6.0 |
Current cautious movement distance |
MARSY_UNCERTAIN_SPEED |
22 |
Current cautious movement speed |
MARSY_CAMERA_ROTATION |
90 |
Rotation of the physical rover camera |
Environment variables can be set before launching the dashboard:
MARSY_UNCERTAIN_STEP_CM=6 \
MARSY_UNCERTAIN_SPEED=22 \
./scripts/run_real_dashboard.shThe skills layer maintains:
current pose
home pose
visited cells
free cells
occupied cells
travel path
Pose sources:
| Mode | Pose source |
|---|---|
| Simulator | Simulator x_cm, y_cm, and heading_deg
|
| Real rover | Time-based dead reckoning |
The map is an occupancy grid, not full SLAM.
It currently has no:
wheel encoder correction
visual odometry
loop closure
global pose optimization
- Ultrasonic sensors may miss soft materials such as sofas, curtains, and clothing.
- Angled surfaces can reflect the ultrasonic pulse away from the sensor.
- A high-mounted sensor can miss low obstacles.
- Reverse movement has no rear sonar protection.
- Real-rover distance and angle estimates are time based.
- Rotation can slip on high-friction surfaces.
- General visual search requires a configured detector or VLM adapter.
- Marker detection requires an OpenCV build with
cv2.aruco. - The occupancy map is useful for observation and debugging, but it is not yet reliable enough for global autonomous navigation.
When testing a new skill on the physical rover:
- use low speed;
- use short distances;
- keep the dashboard STOP control available;
- test in a clear area;
- do not rely on sonar alone for soft or very low obstacles;
- stop immediately if steering servos move in an unexpected direction.
For reliable close-range protection against soft furniture, a low-mounted ToF sensor or mechanical bumper is recommended.