SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Committer:
hazheng
Date:
Thu Apr 06 18:57:54 2017 +0000
Revision:
52:078b521c9edf
Parent:
46:a5eb9bd3bb55
Child:
53:36d9335fec96
Clean the rear differential code.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bobymicjohn 4:25e028102625 1 #pragma once
Bobymicjohn 8:92f6baeea027 2
Bobymicjohn 8:92f6baeea027 3 #include <mbed.h>
Bobymicjohn 8:92f6baeea027 4
hazheng 46:a5eb9bd3bb55 5 #define MotorDir uint8_t
hazheng 44:15de535c4005 6 #define MDIR_Forward 0
hazheng 44:15de535c4005 7 #define MDIR_Backward 1
Bobymicjohn 8:92f6baeea027 8
hazheng 46:a5eb9bd3bb55 9
hazheng 52:078b521c9edf 10 #define MOTOR_MAX_SPEED_LIMIT 0.2f
hazheng 52:078b521c9edf 11 #define MOTOR_DIFF_MIN_SPEED 0.5f
hazheng 52:078b521c9edf 12
hazheng 46:a5eb9bd3bb55 13 #ifdef __cplusplus
hazheng 46:a5eb9bd3bb55 14 extern "C" {
hazheng 46:a5eb9bd3bb55 15 #endif
hazheng 46:a5eb9bd3bb55 16
hazheng 46:a5eb9bd3bb55 17 void motor_init();
hazheng 46:a5eb9bd3bb55 18
hazheng 46:a5eb9bd3bb55 19 void motor_set_left_speed(const float speed);
hazheng 46:a5eb9bd3bb55 20
hazheng 46:a5eb9bd3bb55 21 void motor_set_right_speed(const float speed);
hazheng 46:a5eb9bd3bb55 22
hazheng 46:a5eb9bd3bb55 23 inline void motor_set_speeds(const float speed_left, const float speed_right)
Bobymicjohn 11:676ea42afd56 24 {
hazheng 46:a5eb9bd3bb55 25 motor_set_left_speed(speed_left);
hazheng 46:a5eb9bd3bb55 26 motor_set_right_speed(speed_right);
Bobymicjohn 11:676ea42afd56 27 }
Bobymicjohn 4:25e028102625 28
hazheng 46:a5eb9bd3bb55 29 void motor_set_left_direction(MotorDir dir);
hazheng 46:a5eb9bd3bb55 30
hazheng 46:a5eb9bd3bb55 31 void motor_set_right_direction(MotorDir dir);
Bobymicjohn 4:25e028102625 32
hazheng 46:a5eb9bd3bb55 33 inline void motor_set_direction(MotorDir dirL, MotorDir dirR)
hazheng 46:a5eb9bd3bb55 34 {
hazheng 46:a5eb9bd3bb55 35 motor_set_left_direction(dirL);
hazheng 46:a5eb9bd3bb55 36 motor_set_right_direction(dirR);
hazheng 46:a5eb9bd3bb55 37 }
Bobymicjohn 4:25e028102625 38
hazheng 46:a5eb9bd3bb55 39 #ifdef __cplusplus
hazheng 46:a5eb9bd3bb55 40 }
hazheng 46:a5eb9bd3bb55 41 #endif