Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions unitree_sdk2py/g1/status/g1_health_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
" service name
"""
HEALTH_SERVICE_NAME = "health"

"""
" service api version
"""
HEALTH_API_VERSION = "1.0.0"

"""
" api id
"""
ROBOT_API_ID_GET_HEALTH_STATUS = 9001
18 changes: 18 additions & 0 deletions unitree_sdk2py/g1/status/g1_health_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import json
from ...rpc.client import Client
from .g1_health_api import *

class G1HealthClient(Client):
def __init__(self):
super().__init__(HEALTH_SERVICE_NAME, False)
self._SetApiVerson(HEALTH_API_VERSION)
self._RegistApi(ROBOT_API_ID_GET_HEALTH_STATUS, 0)

def GetHealthStatus(self):
p = {}
parameter = json.dumps(p)
code, data = self._Call(ROBOT_API_ID_GET_HEALTH_STATUS, parameter)
if code == 0:
return code, json.loads(data)
else:
return code, None
Empty file.
16 changes: 16 additions & 0 deletions unitree_sdk2py/g1/visual_feedback/visual_feedback_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Visual Feedback API for G1 robot.
Defines sensor data structures and threshold values for obstacle detection.
"""

# Threshold distances in meters
SAFE_DISTANCE = 1.5 # Green zone
WARNING_DISTANCE = 0.7 # Yellow zone
CRITICAL_DISTANCE = 0.3 # Red zone

# Display colors
DISPLAY_COLORS = {
"SAFE": "GREEN",
"WARNING": "YELLOW",
"CRITICAL": "RED"
}
48 changes: 48 additions & 0 deletions unitree_sdk2py/g1/visual_feedback/visual_feedback_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""
Visual Feedback Client
Processes sensor data and provides visual feedback to the user.
"""

import time
import random # Simulated sensor data
from .visual_feedback_api import SAFE_DISTANCE, WARNING_DISTANCE, CRITICAL_DISTANCE, DISPLAY_COLORS

class VisualFeedbackClient:
def __init__(self):
self.initialized = False

def initialize(self):
# Initialize sensors or connections if needed
self.initialized = True
print("Visual Feedback Client initialized.")

def get_obstacle_distance(self):
"""
Simulate reading distance from sensors.
Replace with actual sensor reading in real implementation.
"""
# Random distance between 0.1 and 2.0 meters
return round(random.uniform(0.1, 2.0), 2)

def update_display(self, distance: float):
"""
Update visual feedback based on distance
"""
if distance >= SAFE_DISTANCE:
color = DISPLAY_COLORS["SAFE"]
elif distance >= WARNING_DISTANCE:
color = DISPLAY_COLORS["WARNING"]
else:
color = DISPLAY_COLORS["CRITICAL"]

# In real robot: send command to LED/display
print(f"[Visual Feedback] Distance: {distance} m → {color}")

# Example usage
if __name__ == "__main__":
client = VisualFeedbackClient()
client.initialize()
while True:
d = client.get_obstacle_distance()
client.update_display(d)
time.sleep(1)
Empty file.
37 changes: 37 additions & 0 deletions unitree_sdk2py/g1/voice_control/vui_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
VUIClient starter module
Processes voice commands and sends them to the robot
"""

from .vui_client_api import VOICE_COMMANDS
import random # Simülate

class VUIClient:
def __init__(self):
self.initialized = False

def initialize(self):
# Initialize voice recognition system (placeholder)
self.initialized = True
print("VUI Client initialized.")

def listen_command(self):
"""
Simulate listening to a voice command.
Replace with actual voice recognition in real implementation.
"""
return random.choice(list(VOICE_COMMANDS.keys()))

def execute_command(self, command):
if command in VOICE_COMMANDS:
print(f"[Voice Command] Executing: {VOICE_COMMANDS[command]}")
else:
print(f"[Voice Command] Unknown command: {command}")

# Example usage
if __name__ == "__main__":
client = VUIClient()
client.initialize()
while True:
cmd = client.listen_command()
client.execute_command(cmd)
13 changes: 13 additions & 0 deletions unitree_sdk2py/g1/voice_control/vui_client_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
VUIClient API for G1 robot.
Defines command structure and supported voice commands.
"""

# Supported commands
VOICE_COMMANDS = {
"move_forward": "Move forward",
"move_backward": "Move backward",
"turn_left": "Turn left",
"turn_right": "Turn right",
"stop": "Stop"
}