Connecting to Robot, Capturing Data & Obtaining Risk Scores

Before running inference with RideScan, ensure you have the correct robot connection details, collect data in a supported format, and upload it via the Python API package.

Spot Robot

Connect to Spot’s on-board PC over SSH, start a mission, record a rosbag, stop recording, transfer the file back, and send it to RideScan.

process = subprocess.Popen(
    [
        "python3",
        "-m",
        "replay_mission",
        "--username", self.username,
        "--password", self.password,
        self.robot_ip,
        "autowalk",
        self.walk_filename
    ],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
)
print("Mission objectives accomplished")
  1. Install dependencies (preferably inside a virtualenv).
  2. Set API key in environment variables or .env (API_KEY=...).
  3. Set server URL (FLASK_API_BASE_URL=...).
  4. Import the Python package and call calculate_risk_scores().
  5. Use list_files(robot, mission) to view risk scores.

UR Robot

Connect via RTDE, configure the XML recipe, capture joint states and TCP data into a CSV, and then send that CSV to RideScan.

ROBOT_IP = ""  # Fill in the Robot's IP here
RTDE_PORT = 30004
DASHBOARD_PORT = 29999
CONFIG_FILE = "record_config.xml"
FREQUENCY_HZ = 10

Sample XML recipe

<?xml version="1.0" encoding="UTF-8"?>
<rtde_config>
 <recipe key='out'>
  <field name="actual_q" type="VECTOR6D"/>
  <field name="target_q" type="VECTOR6D"/>
  <field name="actual_TCP_pose" type="VECTOR6D"/>
  <field name="speed_scaling" type="DOUBLE"/>
  <field name="runtime_state" type="UINT32"/>
  <field name="timestamp" type="DOUBLE"/>
 </recipe>
</rtde_config>
  1. Install dependencies (inside a virtualenv recommended).
  2. Set API_KEY and FLASK_API_BASE_URL in environment variables.
  3. Call calculate_risk_scores("YourUR", "YourMission", ["/path/to/*.csv"]).
  4. Use list_files(robot, mission) to view risk scores.

Important Notes

  • Always have robot IP and credentials/ports ready.
  • Collect data using rosbag (Spot) or RTDE (UR) or other supported methods.
  • API keys must be set via environment variables. Never commit them.
  • Supported upload formats: .bag, .zip, .csv

Troubleshooting

  • 401 Unauthorized: Ensure API_KEY is set. Client retries once if token refresh needed.
  • 404 Not Found: Verify robot/mission names. Use list_robots() and list_missions(robot).
  • 400 Bad Request: Upload files first; then call /api/process.
  • Invalid names: Follow regex rules (letters/digits/spaces/dashes).
  • Unsupported files: Only .bag, .zip, .csv allowed.
  • Spot issues: Check SSH credentials, ROS setup, rosbag availability.
  • UR issues: Verify ports 29999/30004 and running program on controller.

Installing Connectors & Pipeline Integration

  1. Install dependencies (pip install -r requirements.txt).
  2. Set environment variables: API_KEY=..., FLASK_API_BASE_URL=...
  3. Use Python API in your pipeline:
from risk_score_calculator.calculator import RiskScoreCalculator

calc = RiskScoreCalculator(api_key="your_API_KEY")
calc.calculate_risk_scores("RobotName", "MissionName", ["/path/to/file"])

ROS: record topics via rosbag (e.g., /spot/odometry, /joint_states).
UR: capture CSV via RTDE.
Pass resulting .bag or .csv to RideScan.