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:
Wed Mar 29 21:19:27 2017 +0000
Revision:
44:15de535c4005
Parent:
11:676ea42afd56
Child:
46:a5eb9bd3bb55
Made the car move!...

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
Bobymicjohn 8:92f6baeea027 5 #define MotorDir unsigned char
hazheng 44:15de535c4005 6 #define MDIR_Forward 0
hazheng 44:15de535c4005 7 #define MDIR_Backward 1
Bobymicjohn 8:92f6baeea027 8
Bobymicjohn 11:676ea42afd56 9 namespace SW
Bobymicjohn 11:676ea42afd56 10 {
Bobymicjohn 11:676ea42afd56 11 class Core;
Bobymicjohn 11:676ea42afd56 12 }
Bobymicjohn 4:25e028102625 13
Bobymicjohn 4:25e028102625 14 class Motor{
Bobymicjohn 4:25e028102625 15
Bobymicjohn 4:25e028102625 16 public:
Bobymicjohn 11:676ea42afd56 17 Motor(SW::Core& core);
Bobymicjohn 4:25e028102625 18
Bobymicjohn 4:25e028102625 19 ~Motor();
Bobymicjohn 4:25e028102625 20
Bobymicjohn 8:92f6baeea027 21 void Update(float deltaTime);
Bobymicjohn 8:92f6baeea027 22
hazheng 44:15de535c4005 23 void setLeftSpeed(const float speed);
Bobymicjohn 8:92f6baeea027 24
hazheng 44:15de535c4005 25 void setRightSpeed(const float speed);
Bobymicjohn 4:25e028102625 26
hazheng 44:15de535c4005 27 void setSpeeds(const float speedLeft, const float speedRight);
Bobymicjohn 8:92f6baeea027 28
Bobymicjohn 8:92f6baeea027 29 void setLeftDirection(MotorDir dir);
Bobymicjohn 4:25e028102625 30
Bobymicjohn 8:92f6baeea027 31 void setRightDirection(MotorDir dir);
Bobymicjohn 8:92f6baeea027 32
Bobymicjohn 8:92f6baeea027 33 void setDirections(MotorDir dirL, MotorDir dirR);
Bobymicjohn 4:25e028102625 34
Bobymicjohn 4:25e028102625 35 private:
Bobymicjohn 11:676ea42afd56 36
Bobymicjohn 11:676ea42afd56 37 SW::Core& m_core;
Bobymicjohn 11:676ea42afd56 38
Bobymicjohn 8:92f6baeea027 39 DigitalOut m_dirL;
Bobymicjohn 8:92f6baeea027 40 DigitalOut m_dirR;
Bobymicjohn 4:25e028102625 41
Bobymicjohn 8:92f6baeea027 42 PwmOut m_pwmL;
Bobymicjohn 8:92f6baeea027 43 PwmOut m_pwmR;
Bobymicjohn 8:92f6baeea027 44
Bobymicjohn 11:676ea42afd56 45 Motor();
Bobymicjohn 4:25e028102625 46 };