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
Hardwares/Motor.h@46:a5eb9bd3bb55, 2017-03-30 (annotated)
- Committer:
- hazheng
- Date:
- Thu Mar 30 22:34:20 2017 +0000
- Revision:
- 46:a5eb9bd3bb55
- Parent:
- 44:15de535c4005
- Child:
- 52:078b521c9edf
Changed more code into pure C style. Finished driving complete circle! Both screen and camera works fine!
Who changed what in which revision?
User | Revision | Line number | New 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 | 46:a5eb9bd3bb55 | 10 | #ifdef __cplusplus |
hazheng | 46:a5eb9bd3bb55 | 11 | extern "C" { |
hazheng | 46:a5eb9bd3bb55 | 12 | #endif |
hazheng | 46:a5eb9bd3bb55 | 13 | |
hazheng | 46:a5eb9bd3bb55 | 14 | void motor_init(); |
hazheng | 46:a5eb9bd3bb55 | 15 | |
hazheng | 46:a5eb9bd3bb55 | 16 | void motor_set_left_speed(const float speed); |
hazheng | 46:a5eb9bd3bb55 | 17 | |
hazheng | 46:a5eb9bd3bb55 | 18 | void motor_set_right_speed(const float speed); |
hazheng | 46:a5eb9bd3bb55 | 19 | |
hazheng | 46:a5eb9bd3bb55 | 20 | inline void motor_set_speeds(const float speed_left, const float speed_right) |
Bobymicjohn | 11:676ea42afd56 | 21 | { |
hazheng | 46:a5eb9bd3bb55 | 22 | motor_set_left_speed(speed_left); |
hazheng | 46:a5eb9bd3bb55 | 23 | motor_set_right_speed(speed_right); |
Bobymicjohn | 11:676ea42afd56 | 24 | } |
Bobymicjohn | 4:25e028102625 | 25 | |
hazheng | 46:a5eb9bd3bb55 | 26 | void motor_set_left_direction(MotorDir dir); |
hazheng | 46:a5eb9bd3bb55 | 27 | |
hazheng | 46:a5eb9bd3bb55 | 28 | void motor_set_right_direction(MotorDir dir); |
Bobymicjohn | 4:25e028102625 | 29 | |
hazheng | 46:a5eb9bd3bb55 | 30 | inline void motor_set_direction(MotorDir dirL, MotorDir dirR) |
hazheng | 46:a5eb9bd3bb55 | 31 | { |
hazheng | 46:a5eb9bd3bb55 | 32 | motor_set_left_direction(dirL); |
hazheng | 46:a5eb9bd3bb55 | 33 | motor_set_right_direction(dirR); |
hazheng | 46:a5eb9bd3bb55 | 34 | } |
Bobymicjohn | 4:25e028102625 | 35 | |
hazheng | 46:a5eb9bd3bb55 | 36 | #ifdef __cplusplus |
hazheng | 46:a5eb9bd3bb55 | 37 | } |
hazheng | 46:a5eb9bd3bb55 | 38 | #endif |