HUD-Farbe konfigurierbar, Neigungskalibrierung, Auto-Rotate verbessert
- HUD-Farbe per Farbwähler im Admin einstellbar (localStorage) - Schwarze Kontur auf HUD-Elementen via CSS drop-shadow und canvas shadowBlur - Himmelsrichtungen auf Deutsch (O statt E, etc.) - Roll/Pitch-Neigung kann im Admin genullt werden (imu_tilt_calibration.json) - Neigungsoffset wird im Kamera-Overlay berücksichtigt - Auto-Rotate läuft jetzt nativ als rospy-Script im Docker-Container - Auto-Rotate erkennt aktuellen Locomotion-Mode und stellt ihn danach wieder her - Auto-Rotate pausiert Web-GUI-Joystick via localStorage-Flag - Feste 20%-Geschwindigkeit für Auto-Rotate (vel=4, Expo-äquivalent) - Vignette entfernt Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+23
-21
@@ -85,6 +85,7 @@ IMU_ROS_LOCK = threading.Lock()
|
||||
IMU_ROS_THREAD = None
|
||||
IMU_ROS_CLIENT = None
|
||||
IMU_ROS_TOPICS = []
|
||||
LAST_LOCOMOTION_MODE = 1 # ACKERMANN als Fallback
|
||||
IMU_ROS_CACHE = {
|
||||
'state': 'unknown',
|
||||
'status': 'Warte auf ROS',
|
||||
@@ -241,27 +242,23 @@ def _connect_imu_ros():
|
||||
mag_topic = roslibpy.Topic(client, '/imu/mag', 'sensor_msgs/MagneticField')
|
||||
status_topic = roslibpy.Topic(client, '/imu/status', 'std_msgs/String')
|
||||
rover_cmd_topic = roslibpy.Topic(client, '/rover_command', 'exomy/RoverCommand')
|
||||
def _on_rover_cmd_message(message):
|
||||
global LAST_LOCOMOTION_MODE
|
||||
import imu_rotate
|
||||
if not imu_rotate.get_rotate_status()['running']:
|
||||
mode = message.get('locomotion_mode')
|
||||
if mode is not None:
|
||||
LAST_LOCOMOTION_MODE = int(mode)
|
||||
|
||||
imu_topic.subscribe(_on_imu_data_message)
|
||||
mag_topic.subscribe(_on_imu_mag_message)
|
||||
status_topic.subscribe(_on_imu_status_message)
|
||||
rover_cmd_topic.subscribe(_on_rover_cmd_message)
|
||||
rover_cmd_topic.advertise()
|
||||
IMU_ROS_CLIENT = client
|
||||
IMU_ROS_TOPICS = [imu_topic, mag_topic, status_topic, rover_cmd_topic]
|
||||
_imu_ros_cache_update(status='ROS verbunden', error='')
|
||||
|
||||
def _publish_rover_cmd(locomotion_mode, vel, steering):
|
||||
try:
|
||||
rover_cmd_topic.publish(roslibpy.Message({
|
||||
'connected': True,
|
||||
'motors_enabled': True,
|
||||
'locomotion_mode': int(locomotion_mode),
|
||||
'vel': int(vel),
|
||||
'steering': int(steering),
|
||||
}))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
imu_rotate.set_publish_fn(_publish_rover_cmd)
|
||||
|
||||
|
||||
def _imu_ros_worker():
|
||||
@@ -1976,7 +1973,17 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
if self.path == '/api/imu/rotate-status':
|
||||
import imu_rotate
|
||||
self.write_json(200, {'rotate': imu_rotate.get_rotate_status()})
|
||||
status = imu_rotate.get_rotate_status()
|
||||
if status.get('running') and status.get('target_deg') is not None:
|
||||
calibration = read_imu_heading_calibration()
|
||||
with IMU_ROS_LOCK:
|
||||
raw = IMU_ROS_CACHE.get('heading_deg')
|
||||
corrected = get_corrected_heading_deg(raw, calibration['offset_deg']) if raw is not None else None
|
||||
status['current_deg'] = round(corrected, 1) if corrected is not None else None
|
||||
if corrected is not None:
|
||||
err = (status['target_deg'] - corrected + 540) % 360 - 180
|
||||
status['error_deg'] = round(err, 1)
|
||||
self.write_json(200, {'rotate': status})
|
||||
return
|
||||
if self.path == '/api/delay':
|
||||
self.write_json(200, {'delay_seconds': get_delay()})
|
||||
@@ -2326,15 +2333,10 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
return
|
||||
import imu_rotate
|
||||
heading_offset = read_imu_heading_calibration()['offset_deg']
|
||||
|
||||
def _get_corrected_heading():
|
||||
with IMU_ROS_LOCK:
|
||||
raw = IMU_ROS_CACHE.get('heading_deg')
|
||||
return get_corrected_heading_deg(raw, heading_offset) if raw is not None else None
|
||||
|
||||
status = imu_rotate.start_rotate(
|
||||
target_deg=target_deg,
|
||||
get_heading_fn=_get_corrected_heading,
|
||||
heading_offset=heading_offset,
|
||||
restore_mode=LAST_LOCOMOTION_MODE,
|
||||
)
|
||||
self.write_json(200, {'status': 'Drehung gestartet', 'rotate': status})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user