Robot Module

Intermediate RoboticsIntro Python plus classes, NumPy arrays, sensor data, physical units, and supervised robot use.

Before you start

  • Complete the SDK Overview and Camera Module guide
  • Understand meters per second and radians per second
  • Have an instructor present for every motion exercise
  • Know the location of the physical E-stop

Robot combines the beginner camera interface with the Gather motor controller. Opening it gives you sensor access, but it never enables the motors automatically.

Learning Goals

You will learn how to:

  • Read camera and safety state from one object.
  • Explain the difference between connecting and enabling motors.
  • Perform a short, supervised motion test.
  • Guarantee a stop and motor disable with try/finally.

Vocabulary

  • ECU: The electronic controller that receives motor commands and reports safety inputs.
  • Linear velocity: Forward or backward speed, measured in meters per second (m/s).
  • Angular velocity: Turning speed, measured in radians per second (rad/s).
  • Fail closed: Stop and disable motion when safety state cannot be confirmed.
  • E-stop: The physical emergency-stop circuit used to inhibit robot motion.

Before Running Motion

Do not run motion code until an instructor confirms the robot is in a clear, level area; the wheels and turn radius are clear; the physical E-stop is released and reachable; and everyone nearby knows the robot may move.

The SDK defaults to at most 0.25 m/s linear speed and 0.75 rad/s angular speed. It rejects commands outside those limits instead of silently changing them.

Read Sensors Without Moving

Create this program in ~/gather-sdk/projects:

from gather_sdk import Robot
 
with Robot() as robot:
    frame = robot.capture()
    safety = robot.safety_status()
 
    print("Image:", frame.rgb.shape)
    print("E-stop circuit healthy:", safety.estop_ok)
    print("Motors enabled:", safety.motors_enabled)

Opening Robot connects to the camera and ECU. The motors remain disabled, so reading sensors is a safe first exercise.

Build a sensor-only Robot project

AI coding promptbuild

Create code that reads CameraFrame and SafetyStatus while keeping motor output disabled.

Verify before running

Confirm the file contains no motor-enable or drive call before running it and inspect the reported safety fields.

Preview the prompt
Work as a coding agent inside ~/gather-sdk/projects on the assigned Gather robot. Create or update a sensor-only program using from gather_sdk import Robot. It may open Robot, capture camera data, and read SafetyStatus, but it must not call enable_motors or drive. Use the beginner Robot API before any advanced backend, keep the with Robot() cleanup pattern, and explain that opening Robot never enables motor output and estop_ok=True means the E-stop circuit reports healthy. Do not edit the installed SDK source. Run python3.10 -m py_compile on every changed Python file and use mocks for any automated runtime test. Never initiate physical motion, run the program against hardware on your own, or claim the camera or controller worked without actual output. Summarize the changed files and leave one sensor field or output for me to verify during the manual run.

Paste this into an AI coding tool opened in ~/gather-sdk/projects.

What Each Line Does

  1. from gather_sdk import Robot loads the combined beginner interface.
  2. with Robot() as robot opens the camera and ECU, then guarantees cleanup.
  3. robot.capture() reads one camera update.
  4. robot.safety_status() reads the E-stop, motor, and service-button states.
  5. The three print calls inspect sensors without enabling motion.

Understand The E-stop Name

Use safety.estop_ok in project code:

  • True means the E-stop circuit reports healthy.
  • False means motion must be inhibited.

The lower-level controller has a historically confusing key named estop_active. In that low-level dictionary, True also means the circuit is healthy. The beginner SDK renames it so the meaning is clear.

Supervised Motion Example

import time
 
from gather_sdk import Robot
 
with Robot() as robot:
    robot.enable_motors()
    try:
        robot.drive(linear_mps=0.10, angular_rps=0.0)
        time.sleep(1.0)
        robot.stop()
    finally:
        robot.disable_motors()

What Each Step Does

  1. with Robot() opens the camera and controller without enabling motion.
  2. enable_motors() rechecks the E-stop circuit before enabling output.
  3. drive() rechecks safety and validates both velocity limits.
  4. stop() commands zero linear and angular velocity.
  5. finally disables the motors even if another line raises an error.
  6. Leaving the with block repeats stop, disable, and device cleanup as a final safeguard.

Review and harden Robot motion code

AI coding promptreview

Inspect motion code, apply safety corrections, and validate syntax without executing the robot program.

Verify before running

Review every safety change and obtain instructor approval before deciding whether any physical run occurs.

Preview the prompt
Work as a coding agent inside ~/gather-sdk/projects. Inspect the Robot motion code I identify, but do not run it. Never initiate physical motion. Use from gather_sdk import Robot before any advanced backend and do not edit the installed SDK source. Apply the smallest code changes needed to enforce an instructor safety confirmation, a reachable E-stop, an estop_ok check, motor enable only after confirmation, no more than 0.25 m/s linear and 0.75 rad/s angular speed, and guaranteed stop and disable in finally or a context manager. Do not bypass SafetyError. Run only hardware-independent validation such as python3.10 -m py_compile or mocked tests. Never claim the robot moved, stopped, or passed a hardware test without direct evidence. Summarize the files changed, separate code guarantees from instructor-only physical checks, and leave one safety invariant for me to verify in the final diff.

Paste this into an AI coding tool opened in ~/gather-sdk/projects.

Safety State

robot.safety_status() returns:

FieldMeaning
estop_okTrue only when the E-stop circuit reports healthy
motors_enabledWhether motor output is currently enabled
service_button_0Left service-button latched state
service_button_1Right service-button latched state
service_button_2Middle service-button latched state

Method Summary

MethodWhat it does
open()Opens camera and ECU; does not enable motors
capture()Returns one CameraFrame
safety_status()Reads clear safety and service-button state
enable_motors()Enables only when the E-stop circuit is healthy
drive(linear_mps, angular_rps)Sends an in-range supervised velocity
stop()Sends zero velocity
disable_motors()Stops, then disables motor output
close()Best-effort stop, disable, and device cleanup

Try These Changes With An Instructor

  1. Reduce the forward speed from 0.10 to 0.05.
  2. Replace forward motion with angular_rps=0.20 in a clear turning area.
  3. Print all three service-button values without enabling the motors.
  4. Capture an image before and after a short motion test.

Keep Control Through Robot

Use the Gather wrapper for camera state, safety state, and motion:

from gather_sdk import Robot

The controller backend is an SDK implementation detail. Projects should not import it, edit its configuration, or depend on its raw state keys. Use SafetyStatus, enable_motors(), drive(), stop(), and disable_motors() instead.

Troubleshooting

Robot is not open

Call robot.open() first or use with Robot() as robot:.

Motor enable is blocked

Do not bypass the check. Ask the instructor to inspect and release the physical E-stop, then read robot.safety_status() again.

A velocity is rejected

Keep linear velocity between -0.25 and 0.25 m/s and angular velocity between -0.75 and 0.75 rad/s, unless the instructor deliberately configured smaller limits.

The ECU cannot be reached

Confirm the robot is powered and the ECU is reachable at the assigned address. Do not change network or controller settings without an instructor.