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 the ability to reset the position of the motors in odometry_start() #758

Open
wants to merge 1 commit into
base: ev3dev-stretch
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion ev3dev2/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2695,7 +2695,7 @@ def turn_to_angle(self, speed, angle_target_degrees, brake=True, block=True, err
def odometry_coordinates_log(self):
log.debug("%s: odometry angle %s at (%d, %d)" % (self, math.degrees(self.theta), self.x_pos_mm, self.y_pos_mm))

def odometry_start(self, theta_degrees_start=90.0, x_pos_start=0.0, y_pos_start=0.0, sleep_time=0.005): # 5ms
def odometry_start(self, theta_degrees_start=90.0, x_pos_start=0.0, y_pos_start=0.0, sleep_time=0.005, reset_position=False): # 5ms
"""
Ported from:
http://seattlerobotics.org/encoder/200610/Article3/IMU%20Odometry,%20by%20David%20Anderson.htm
Expand All @@ -2704,6 +2704,9 @@ def odometry_start(self, theta_degrees_start=90.0, x_pos_start=0.0, y_pos_start=
which will set odometry_thread_run to False
"""
def _odometry_monitor():
if (reset_postion == True): # resets the positions of the motors for a clena slate
self.left_motor.position = 0
self.right_motor.position = 0
left_previous = 0
right_previous = 0
self.theta = math.radians(theta_degrees_start) # robot heading
Expand Down