ROS Bridge Update

This commit is contained in:
2026-01-02 06:50:31 +00:00
parent 1bbd9c8377
commit 924d803e71
4 changed files with 60 additions and 137 deletions

View File

@@ -208,12 +208,28 @@ class DroneSimulator:
try:
command = json.loads(data.decode('utf-8'))
# Drone control commands
self._last_command = {
'thrust': float(command.get('thrust', 0.0)),
'pitch': float(command.get('pitch', 0.0)),
'roll': float(command.get('roll', 0.0)),
'yaw': float(command.get('yaw', 0.0))
}
# Rover position update (if provided)
if 'rover' in command:
rover_data = command['rover']
new_x = float(rover_data.get('x', self._rover_pos[0]))
new_y = float(rover_data.get('y', self._rover_pos[1]))
new_z = float(rover_data.get('z', self._rover_pos[2]))
self._rover_pos = [new_x, new_y, new_z]
p.resetBasePositionAndOrientation(
self._rover_id,
self._rover_pos,
[0, 0, 0, 1]
)
except (json.JSONDecodeError, ValueError) as e:
print(f"Invalid command received: {e}")