Skip to content

feat(gear_sonic_deploy): Add Python network setup script for Unitree G1 robot #237

Description

@klakhi

Summary

Add gear_sonic_deploy/scripts/setup_network.py — a Python script for configuring a static IP on the workstation NIC to communicate with the Unitree G1 robot over the 192.168.123.x subnet.

Motivation

The existing setup scripts are shell-based and lack:

  • Interactive interface discovery (lists all physical NICs with their state and current IP)
  • Scoped firewall handling — adds a targeted ufw rule per interface instead of disabling the firewall globally
  • Pre-change config backup to /tmp/network_backup_<timestamp>.txt
  • Post-setup connectivity ping to verify the robot is reachable
  • A --interface flag for non-interactive/scripted use

What this script does

  1. Robot selection — interactive menu (currently supports Unitree G1; extensible via ROBOT_CONFIGURATIONS dict)
  2. Interface discovery — enumerates physical NICs (skips loopback, Docker, veth, bridge interfaces), shows UP/DOWN state and current IP
  3. Config backup — saves existing IP/route state before making changes
  4. Static IP assignment — flushes existing addresses, brings the interface up, assigns 192.168.123.222/24 via iproute2
  5. Firewall — if ufw is active, adds scoped allow in/out on <interface> rules (does not disable ufw globally)
  6. Connectivity check — pings the robot at 192.168.123.164 to confirm end-to-end reachability

Usage

# Interactive (prompts for robot type + interface)
python3 gear_sonic_deploy/scripts/setup_network.py

# Skip interface selection
python3 gear_sonic_deploy/scripts/setup_network.py -i enp5s0

Requirements

  • Linux (Ubuntu 20.04 / 22.04 / 24.04)
  • iproute2, sudo privileges
  • ufw optional — skipped gracefully if not present

Files changed

  • gear_sonic_deploy/scripts/setup_network.py (new)

Branch

klakhi/setup_network_script on klakhi/GR00T-WholeBodyControl

Fixed by #238

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions