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 IMU_ADDRESS configuration #1064

Merged
merged 1 commit into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions donkeycar/templates/cfg_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@
#IMU
HAVE_IMU = False #when true, this add a Mpu6050 part and records the data. Can be used with a
IMU_SENSOR = 'mpu6050' # (mpu6050|mpu9250)
IMU_ADDRESS = 0x68 # if AD0 pin is pulled high them address is 0x69, otherwise it is 0x68
IMU_DLP_CONFIG = 0 # Digital Lowpass Filter setting (0:250Hz, 1:184Hz, 2:92Hz, 3:41Hz, 4:20Hz, 5:10Hz, 6:5Hz)

#SOMBRERO
Expand Down
1 change: 1 addition & 0 deletions donkeycar/templates/cfg_path_follow.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
# IMU for imu model
HAVE_IMU = False #when true, this add a Mpu6050 part and records the data. Can be used with a
IMU_SENSOR = 'mpu6050' # (mpu6050|mpu9250)
IMU_ADDRESS = 0x68 # if AD0 pin is pulled high them address is 0x69, otherwise it is 0x68
IMU_DLP_CONFIG = 0 # Digital Lowpass Filter setting (0:250Hz, 1:184Hz, 2:92Hz, 3:41Hz, 4:20Hz, 5:10Hz, 6:5Hz)


Expand Down
21 changes: 16 additions & 5 deletions donkeycar/templates/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,8 @@ def show_record_count_status():
s = Sombrero()

#IMU
if cfg.HAVE_IMU:
from donkeycar.parts.imu import IMU
imu = IMU(sensor=cfg.IMU_SENSOR, dlp_setting=cfg.IMU_DLP_CONFIG)
V.add(imu, outputs=['imu/acl_x', 'imu/acl_y', 'imu/acl_z',
'imu/gyr_x', 'imu/gyr_y', 'imu/gyr_z'], threaded=True)
add_imu(V, cfg)


# Use the FPV preview, which will show the cropped image output, or the full frame.
if cfg.USE_FPV:
Expand Down Expand Up @@ -802,6 +799,20 @@ def add_odometry(V, cfg):
else:
print("No supported encoder found")

#
# IMU setup
#
def add_imu(V, cfg):
imu = None
if cfg.HAVE_IMU:
from donkeycar.parts.imu import IMU

imu = IMU(sensor=cfg.IMU_SENSOR, addr=cfg.IMU_ADDRESS,
dlp_setting=cfg.IMU_DLP_CONFIG)
V.add(imu, outputs=['imu/acl_x', 'imu/acl_y', 'imu/acl_z',
'imu/gyr_x', 'imu/gyr_y', 'imu/gyr_z'], threaded=True)
return imu


#
# Drive train setup
Expand Down
10 changes: 9 additions & 1 deletion donkeycar/templates/path_follow.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
from donkeycar.parts.transform import PIDController
from donkeycar.parts.kinematics import TwoWheelSteeringThrottle
from donkeycar.templates.complete import add_odometry, add_camera, \
add_user_controller, add_drivetrain, add_simulator
add_user_controller, add_drivetrain, add_simulator, add_imu
from donkeycar.parts.logger import LoggerPart
from donkeycar.parts.transform import Lambda
from donkeycar.parts.explode import ExplodeDict
Expand Down Expand Up @@ -106,6 +106,14 @@ def drive(cfg, use_joystick=False, camera_type='single'):
#
add_simulator(V, cfg)

#
# IMU
#
add_imu(V, cfg)

#
# odometry/tachometer/speed control
#
if cfg.HAVE_ODOM:
#
# setup encoders, odometry and pose estimation
Expand Down