Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SW limit max speed and steering angle for FR-07 platform #987

Merged
merged 1 commit into from
Apr 10, 2024
Merged
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
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
Loading