Skip to content

Commit

Permalink
osgar/platforms/yuhesen.py - SW limit for max speed and steering angle (
Browse files Browse the repository at this point in the history
  • Loading branch information
m3d authored Apr 10, 2024
1 parent 7bdc4f7 commit fd433f5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions osgar/platforms/yuhesen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class FR07(Node):
def __init__(self, config, bus):
super().__init__(config, bus)
bus.register('can', 'emergency_stop', 'pose2d')
self.max_speed = config.get('max_speed', 0.5)
self.max_steering_deg = config.get('max_steering_deg', 45.0)
self.last_steering = None
self.last_speed = None
self.last_emergency_stop = None
Expand Down Expand Up @@ -212,7 +214,12 @@ def on_desired_steering(self, data):
else:
pass # for zero leave it as it is now
self.desired_speed = speed_mm_per_sec/1000 # m/s
if self.max_speed is not None:
self.desired_speed = min(self.max_speed, max(-self.max_speed, self.desired_speed))
self.desired_steering_angle_deg = steering_deg_hundredth/100 # degrees
if self.max_steering_deg is not None:
self.desired_steering_angle_deg = min(self.max_steering_deg,
max(-self.max_steering_deg, self.desired_steering_angle_deg))

def draw(self):
import matplotlib.pyplot as plt
Expand Down

0 comments on commit fd433f5

Please sign in to comment.