Complete software solution for the Unitree G1 EDU humanoid robot to autonomously charge electric vehicles. The robot approaches a charging station, retrieves the charger, navigates to the car, and precisely inserts the plug into the charging port. This project encompasses the entire process: from navigation and computer vision to advanced humanoid arm manipulation.
This ROS2-based system enables the Unitree G1 humanoid robot to perform autonomous electric vehicle charging. The robot executes a mission through four main states:
- APPROACH_STATION - Navigate to the charging station
- GRASP_CHARGER - Detect and grasp the charger handle
- APPROACH_CAR - Navigate to the vehicle while carrying the charger
- INSERT_PLUG - Precisely insert the charger plug into the vehicle's charging port
The system uses ROS2 Actions for robust, asynchronous communication between subsystems. It consists of five main ROS2 packages:
Defines custom action interfaces for the system.
Actions:
Navigate.action- Navigation goals with pose targetsManipulate.action- Manipulation tasks (grasp_handle, insert_plug)Detect.action- Object detection requests
Handles computer vision for detecting the charger handle and car charging port.
Nodes:
charger_detector- Detects and localizes the charging handleport_detector- Detects and localizes the car's charging portperception_action_server- Action Server for object detection
Actions:
- Serves:
/detectaction (Detect.action)
Topics:
- Publishes:
/perception/charger_pose,/perception/port_pose - Subscribes:
/camera/image_raw
Manages walking logic and path planning for the humanoid robot.
Nodes:
walking_controller- Controls the robot's walking gait and movementpath_planner- Plans collision-free pathsnavigation_action_server- Action Server for navigation tasks
Actions:
- Serves:
/navigateaction (Navigate.action)
Topics:
- Publishes:
/cmd_vel,/navigation/planned_path - Subscribes:
/odom,/navigation/goal
Controls arm inverse kinematics for grasping and insertion operations.
Nodes:
arm_controller- Manages arm movements using IKgripper_controller- Controls gripper open/close operationsmanipulation_action_server- Action Server for manipulation tasks
Actions:
- Serves:
/manipulateaction (Manipulate.action)
Topics:
- Publishes:
/right_arm/joint_trajectory,/right_gripper/position_command - Subscribes:
/joint_states,/manipulation/right_arm/target_pose
Coordinates the entire mission using a finite state machine acting as an Action Client.
Nodes:
state_machine- Original topic-based coordinator (deprecated)state_machine_action_client- Main coordinator using ROS2 Actions
Mission Sequence:
NAV_TO_STATION- Navigate to charging stationDETECT_HANDLE- Detect charger handleMANIPULATE_GRASP- Grasp the handleNAV_TO_CAR- Navigate to carDETECT_PORT- Detect charging portMANIPULATE_INSERT- Insert plug into port
Actions (as Client):
- Calls:
/navigate,/manipulate,/detectactions
Topics:
- Publishes:
/mission_control/state
- ROS2 Humble (or later)
- Ubuntu 22.04 (or compatible)
- Unitree SDK for G1 robot
- Python 3.10+
- OpenCV and cv_bridge
# Create a workspace
mkdir -p ~/unitree_ws/src
cd ~/unitree_ws/src
# Clone this repository
git clone https://github.com/AI-robot-lab/unitree-g1-auto-charger-plugging.git
# Install dependencies
cd ~/unitree_ws
rosdep install --from-paths src --ignore-src -r -y
# Build the workspace
colcon build --symlink-install
# Source the workspace
source ~/unitree_ws/install/setup.bashTo test the action-based system with mock servers:
# Terminal 1 - Start Navigation Action Server
ros2 run navigation navigation_action_server
# Terminal 2 - Start Manipulation Action Server
ros2 run manipulation manipulation_action_server
# Terminal 3 - Start Perception Action Server
ros2 run perception perception_action_server
# Terminal 4 - Start Mission Control (Action Client)
ros2 run mission_control state_machine_action_clientThe mission will automatically start and execute through all states.
Launch all nodes with default configuration:
ros2 launch launch/bringup.launch.pyLaunch with auto-start enabled:
ros2 launch launch/bringup.launch.py auto_start:=trueLaunch with custom configuration:
ros2 launch launch/bringup.launch.py config_file:=/path/to/custom_config.yamlValidate the architecture:
python3 validate_architecture.pyMonitor action servers:
# List available actions
ros2 action list
# Get info about a specific action
ros2 action info /navigate
ros2 action info /manipulate
ros2 action info /detectSend a test goal to an action server:
# Test navigation
ros2 action send_goal /navigate charging_interfaces/action/Navigate "{target_pose: {position: {x: 2.0, y: 0.0, z: 0.0}, orientation: {w: 1.0}}}"
# Test manipulation
ros2 action send_goal /manipulate charging_interfaces/action/Manipulate "{task_type: 'grasp_handle'}"
# Test detection
ros2 action send_goal /detect charging_interfaces/action/Detect "{object_name: 'charger_handle'}"If not using auto-start, trigger the mission manually:
ros2 topic pub /mission_control/start std_msgs/Bool "data: true" --onceMonitor the current mission state:
ros2 topic echo /mission_control/stateView perception results:
ros2 topic echo /perception/charger_pose
ros2 topic echo /perception/port_poseCheck gripper status:
ros2 topic echo /manipulation/right_gripper/grasp_statusAll parameters are configured in config/g1_params.yaml. Key parameters include:
- Perception: Camera topics, detection thresholds, model paths
- Navigation: Velocity limits, position tolerances, planning algorithms
- Manipulation: Arm control rates, force limits, gripper positions
- Mission Control: Station/car positions, state timeouts
This system integrates with the Unitree SDK to control the G1 robot's low-level functions:
- Install the Unitree SDK:
# Follow Unitree's official SDK installation guide
# Typically involves:
git clone https://github.com/unitreerobotics/unitree_sdk2.git
cd unitree_sdk2
mkdir build && cd build
cmake ..
make
sudo make install- Configure network settings in
config/g1_params.yaml:
unitree_sdk:
ros__parameters:
robot_ip: "192.168.123.10" # Robot's IP address
local_ip: "192.168.123.100" # Your computer's IP
sdk_port: 8080The system interfaces with the Unitree SDK at several points:
- Walking Controller: Uses SDK's locomotion interface for gait control
- Arm Controller: Interfaces with SDK's arm control for joint commands
- Gripper Controller: Uses SDK's gripper interface for grasp control
- State Machine: Monitors robot state via SDK status messages
The SDK integration includes safety mechanisms:
- Emergency stop functionality
- Joint limit enforcement
- Collision detection
- Balance monitoring
- Battery level checks
unitree-g1-auto-charger-plugging/
├── src/
│ ├── charging_interfaces/ # NEW: Action interface definitions
│ │ ├── action/
│ │ │ ├── Navigate.action
│ │ │ ├── Manipulate.action
│ │ │ └── Detect.action
│ │ ├── CMakeLists.txt
│ │ └── package.xml
│ ├── perception/
│ │ ├── perception/
│ │ │ ├── __init__.py
│ │ │ ├── charger_detector.py
│ │ │ ├── port_detector.py
│ │ │ └── perception_action_server.py # NEW: Action server
│ │ ├── package.xml
│ │ └── setup.py
│ ├── navigation/
│ │ ├── navigation/
│ │ │ ├── __init__.py
│ │ │ ├── walking_controller.py
│ │ │ ├── path_planner.py
│ │ │ └── navigation_action_server.py # NEW: Action server
│ │ ├── package.xml
│ │ └── setup.py
│ ├── manipulation/
│ │ ├── manipulation/
│ │ │ ├── __init__.py
│ │ │ ├── arm_controller.py
│ │ │ ├── gripper_controller.py
│ │ │ └── manipulation_action_server.py # NEW: Action server
│ │ ├── package.xml
│ │ └── setup.py
│ └── mission_control/
│ ├── mission_control/
│ │ ├── __init__.py
│ │ ├── state_machine.py
│ │ └── state_machine_action_client.py # NEW: Action client
│ ├── package.xml
│ └── setup.py
├── launch/
│ └── bringup.launch.py
├── config/
│ └── g1_params.yaml
├── validate_architecture.py # NEW: Validation script
└── README.md
To extend the system with custom behaviors:
- New Perception Algorithms: Add to perception package
- Alternative Path Planning: Modify navigation package
- Advanced Manipulation: Extend manipulation package
- Additional Mission States: Update state machine action client in mission_control
- New Action Types: Add action definitions to charging_interfaces package
-
Robot not responding
- Check network connectivity to robot
- Verify SDK IP configuration
- Ensure SDK is properly installed
-
Perception not detecting objects
- Check camera topic names
- Verify detection thresholds
- Ensure adequate lighting
-
Navigation issues
- Check odometry data
- Verify position tolerances
- Review path planning parameters
-
Manipulation problems
- Verify IK solver configuration
- Check joint limits
- Ensure proper gripper calibration
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Unitree Robotics for the G1 robot platform and SDK
- ROS2 community for the excellent robotics middleware
- Contributors and maintainers of this project
For questions, issues, or suggestions, please open an issue on GitHub or contact the maintainers.