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

921 kinematics pose estimation #1089

Merged
merged 29 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1ce5b00
Add tachometer, odometer and kinematics part
Ezward Jan 1, 2023
deeb6fc
refactor pose estimation into a single part
Ezward Jan 8, 2023
d31b163
comment out logging of pose to quiet the console
Ezward Jan 8, 2023
9710c16
add arduino encoder sketches
Ezward Jan 16, 2023
6d66d2c
remove unicode characters that prevent compilation of arduino sketch
Ezward Jan 17, 2023
ff95fdf
clean up comments a little
Ezward Jan 17, 2023
e2a9a54
Add more documentation to the quadrature_encoder.ino sketch
Ezward Jan 18, 2023
325e89b
Add interrupt mode to the mono encoder
Ezward Jan 24, 2023
a5c6a44
Remove spurious unicode beta character
Ezward Jan 24, 2023
ae4ab8f
removed digital write high in mono encoder
Ezward Jan 24, 2023
8f2f859
Fix syntax error if only using one channel in int mode
Ezward Jan 26, 2023
e6eb5cf
Added a quadrature encoder sketch with no libraries
Ezward Jan 28, 2023
162ff35
Fix bug in mono encoder sketch
Ezward Jan 28, 2023
5d05b11
Fix bug in quadrature nolib sketch
Ezward Jan 28, 2023
a4ede0a
minor change to quadrature nolib
Ezward Jan 28, 2023
896cc26
Updated quadrature_encoder.ino to not require library
Ezward Jan 31, 2023
1cf569d
fix merge error in path_follow.py
Ezward Feb 4, 2023
a90421d
Fix RPi_GPIO_Servo part so it does not need GPIO in constructor
Ezward Feb 5, 2023
92af322
added non-threaded run() to UnicyclePose and BicyclePose for testing
Ezward Feb 8, 2023
4e6c371
Improved accuracy of MockEncoder by propagating fractional ticks
Ezward Feb 8, 2023
6d4f506
Updated add_odometry() so we could add as non-threaded for testing.
Ezward Feb 8, 2023
9f2ab20
Vehicle loop prints out number of iterations and total time
Ezward Feb 8, 2023
e9cac78
Rewrite of the kinematics unit tests
Ezward Feb 8, 2023
0cda9b0
Adjust bicycle kinematics to use front wheel reference
Ezward Feb 9, 2023
a1d4f78
relax orientation test to 3% accuracy
Ezward Feb 9, 2023
024fc0f
updated based on PR feedback
Ezward Feb 9, 2023
0ae8db9
removed hard-coded logging level
Ezward Feb 12, 2023
ee22a1b
Update vehicle.py
Ezward Feb 13, 2023
78711a7
Update setup.py version="4.4.dev5"
Ezward Feb 13, 2023
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
Next Next commit
Add tachometer, odometer and kinematics part
- tachometer takes an encoder and returns revolutions
- odometer coverts revolutions to distance and velocity
- kinematics converts odometry to pose estimates
- BicyclePose part implements the pose estimation pipeline for a
  car-like vehicle (fixed back wheels, turnable front wheels)
- UnicyclePose part implements the pose estimation pipeline
  for differential drive vehicles.
  • Loading branch information
Ezward committed Feb 14, 2023
commit 1ce5b0072e57caab25d776c2f7a8266f667c4e09
5 changes: 3 additions & 2 deletions donkeycar/la.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ def normalize(self):
def normalized(self):
m = self.mag()
v = Vec3(self.x, self.y, self.z)
v.scale(1.0 / m)
if m > 0:
v.scale(1.0 / m)
return v

def subtract(self, v):
Expand Down Expand Up @@ -619,4 +620,4 @@ def __init__(self, a, b):
def vector_to(self, p):
delta = self.origin - p
dot = delta.dot(self.dir)
return self.dir.scaled(dot) - delta
return self.dir.scaled(dot) - delta
16 changes: 10 additions & 6 deletions donkeycar/parts/actuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ def __init__(self, controller, left_pulse, right_pulse):
set_pulse = getattr(controller, "set_pulse", None)
if set_pulse is None or not callable(set_pulse):
raise ValueError("controller must have a set_pulse method")
if not utils.is_number_type(left_pulse):
raise ValueError("left_pulse must be a number")
if not utils.is_number_type(right_pulse):
raise ValueError("right_pulse must be a number")

self.controller = controller
self.left_pulse = left_pulse
Expand Down Expand Up @@ -950,11 +954,12 @@ class RPi_GPIO_Servo(object):
'''
Servo controlled from the gpio pins on Rpi
'''
def __init__(self, pin, pin_scheme=None, freq = 50, min=5.0, max=7.8):
def __init__(self, pin, pin_scheme=GPIO.BCM, freq=50, min=5.0, max=7.8):
self.pin = pin
GPIO.setmode(GPIO.BCM if pin_scheme is None else pin_scheme)
GPIO.setmode(pin_scheme)
GPIO.setup(self.pin, GPIO.OUT)


self.throttle = 0
self.pwm = GPIO.PWM(self.pin, freq)
self.pwm.start(0)
self.min = min
Expand All @@ -965,12 +970,11 @@ def run(self, pulse):
Update the speed of the motor where 1 is full forward and
-1 is full backwards.
'''
#I've read 90 is a good max
# I've read 90 is a good max
self.throttle = dk.map_frange(pulse, -1.0, 1.0, self.min, self.max)
#logger.debug(pulse, self.throttle)
# logger.debug(pulse, self.throttle)
self.pwm.ChangeDutyCycle(self.throttle)


def shutdown(self):
self.pwm.stop()
GPIO.cleanup()
Expand Down
7 changes: 7 additions & 0 deletions donkeycar/parts/encoder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""
Deprecated in favor on donkeycar.parts.Tachometer and donkeycar.parts.Odometer.

Encoders and odometry
"""

from datetime import datetime
from donkeycar.utilities.deprecated import deprecated
import re
import time

Expand All @@ -18,6 +21,7 @@

# This samples the odometer at 10HZ and does a moving average over the past ten readings to derive a velocity

@deprecated("Deprecated in favor donkeycar.parts.tachometer.Tachometer(SerialEncoder)")
class ArduinoEncoder(object):
def __init__(self, mm_per_tick=0.0000599, debug=False):
import serial
Expand Down Expand Up @@ -60,6 +64,8 @@ def shutdown(self):
self.on = False
time.sleep(.5)


@deprecated("Deprecated as unused")
class AStarSpeed:
def __init__(self):
from donkeycar.parts.teensy import TeensyRCin
Expand Down Expand Up @@ -118,6 +124,7 @@ def shutdown(self):
time.sleep(.5)


@deprecated("Deprecated in favor of donkeycar.parts.tachometer.Tachometer(GpioEncoder)")
class RotaryEncoder():
def __init__(self, mm_per_tick=0.306096, pin=13, poll_delay=0.0166, debug=False):
import pigpio
Expand Down
6 changes: 5 additions & 1 deletion donkeycar/parts/explode.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#
# part that executes a no-arg method when a button is clicked
# part that explodes a dictionary argument into individually named arguments
#


class ExplodeDict:
"""
part that expands a dictionary input argument
into individually named output arguments
"""
def __init__(self, memory, output_prefix = ""):
"""
Break a map into key/value pairs and write
Expand Down
Loading