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@11:676ea42afd56, 2017-02-07 (annotated)
- Committer:
- Bobymicjohn
- Date:
- Tue Feb 07 21:58:20 2017 +0000
- Revision:
- 11:676ea42afd56
- Parent:
- 9:b72e18f80f49
- Child:
- 44:15de535c4005
Finished Core, and Servo classes.
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 | |
Bobymicjohn | 8:92f6baeea027 | 5 | #define MotorDir unsigned char |
Bobymicjohn | 8:92f6baeea027 | 6 | #define MDIR_Forward 1 |
Bobymicjohn | 8:92f6baeea027 | 7 | #define MDIR_Backward 0 |
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 | |
Bobymicjohn | 8:92f6baeea027 | 23 | void setLeftSpeed(float speed); |
Bobymicjohn | 8:92f6baeea027 | 24 | |
Bobymicjohn | 8:92f6baeea027 | 25 | void setRightSpeed(float speed); |
Bobymicjohn | 4:25e028102625 | 26 | |
Bobymicjohn | 8:92f6baeea027 | 27 | void setSpeeds(float speedLeft, 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 | }; |