![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
pepe
Robot.h@0:a7324f51348d, 2019-03-13 (annotated)
- Committer:
- PedroMartins96
- Date:
- Wed Mar 13 23:04:14 2019 +0000
- Revision:
- 0:a7324f51348d
- Child:
- 1:2716ea33958b
444
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
PedroMartins96 | 0:a7324f51348d | 1 | /** @file */ |
PedroMartins96 | 0:a7324f51348d | 2 | #ifndef ROBOT_H_ |
PedroMartins96 | 0:a7324f51348d | 3 | #define ROBOT_H_ |
PedroMartins96 | 0:a7324f51348d | 4 | |
PedroMartins96 | 0:a7324f51348d | 5 | #include "mbed.h" |
PedroMartins96 | 0:a7324f51348d | 6 | |
PedroMartins96 | 0:a7324f51348d | 7 | extern int16_t countsLeft; |
PedroMartins96 | 0:a7324f51348d | 8 | extern int16_t countsRight; |
PedroMartins96 | 0:a7324f51348d | 9 | extern float De,Dd,T,pi,L,r,x,y,teta; |
PedroMartins96 | 0:a7324f51348d | 10 | |
PedroMartins96 | 0:a7324f51348d | 11 | /** \brief Sets the speed for both motors. |
PedroMartins96 | 0:a7324f51348d | 12 | * |
PedroMartins96 | 0:a7324f51348d | 13 | * \param leftSpeed A number from -300 to 300 representing the speed and |
PedroMartins96 | 0:a7324f51348d | 14 | * direction of the left motor. Values of -300 or less result in full speed |
PedroMartins96 | 0:a7324f51348d | 15 | * reverse, and values of 300 or more result in full speed forward. |
PedroMartins96 | 0:a7324f51348d | 16 | * \param rightSpeed A number from -300 to 300 representing the speed and |
PedroMartins96 | 0:a7324f51348d | 17 | * direction of the right motor. Values of -300 or less result in full speed |
PedroMartins96 | 0:a7324f51348d | 18 | * reverse, and values of 300 or more result in full speed forward. */ |
PedroMartins96 | 0:a7324f51348d | 19 | void setSpeeds(int16_t leftSpeed, int16_t rightSpeed); |
PedroMartins96 | 0:a7324f51348d | 20 | |
PedroMartins96 | 0:a7324f51348d | 21 | /** \brief Sets the speed for the left motor. |
PedroMartins96 | 0:a7324f51348d | 22 | * |
PedroMartins96 | 0:a7324f51348d | 23 | * \param speed A number from -300 to 300 representing the speed and |
PedroMartins96 | 0:a7324f51348d | 24 | * direction of the left motor. Values of -300 or less result in full speed |
PedroMartins96 | 0:a7324f51348d | 25 | * reverse, and values of 300 or more result in full speed forward. */ |
PedroMartins96 | 0:a7324f51348d | 26 | void setLeftSpeed(int16_t speed); |
PedroMartins96 | 0:a7324f51348d | 27 | |
PedroMartins96 | 0:a7324f51348d | 28 | /** \brief Sets the speed for the right motor. |
PedroMartins96 | 0:a7324f51348d | 29 | * |
PedroMartins96 | 0:a7324f51348d | 30 | * \param speed A number from -300 to 300 representing the speed and |
PedroMartins96 | 0:a7324f51348d | 31 | * direction of the right motor. Values of -300 or less result in full speed |
PedroMartins96 | 0:a7324f51348d | 32 | * reverse, and values of 300 or more result in full speed forward. */ |
PedroMartins96 | 0:a7324f51348d | 33 | void setRightSpeed(int16_t speed); |
PedroMartins96 | 0:a7324f51348d | 34 | |
PedroMartins96 | 0:a7324f51348d | 35 | /*! Returns the number of counts that have been detected from the both |
PedroMartins96 | 0:a7324f51348d | 36 | * encoders. These counts start at 0. Positive counts correspond to forward |
PedroMartins96 | 0:a7324f51348d | 37 | * movement of the wheel of the Romi, while negative counts correspond |
PedroMartins96 | 0:a7324f51348d | 38 | * to backwards movement. |
PedroMartins96 | 0:a7324f51348d | 39 | * |
PedroMartins96 | 0:a7324f51348d | 40 | * The count is returned as a signed 16-bit integer. When the count goes |
PedroMartins96 | 0:a7324f51348d | 41 | * over 32767, it will overflow down to -32768. When the count goes below |
PedroMartins96 | 0:a7324f51348d | 42 | * -32768, it will overflow up to 32767. */ |
PedroMartins96 | 0:a7324f51348d | 43 | void getCounts(); |
PedroMartins96 | 0:a7324f51348d | 44 | |
PedroMartins96 | 0:a7324f51348d | 45 | /*! This function is just like getCounts() except it also clears the |
PedroMartins96 | 0:a7324f51348d | 46 | * counts before returning. If you call this frequently enough, you will |
PedroMartins96 | 0:a7324f51348d | 47 | * not have to worry about the count overflowing. */ |
PedroMartins96 | 0:a7324f51348d | 48 | void getCountsAndReset(); |
PedroMartins96 | 0:a7324f51348d | 49 | |
PedroMartins96 | 0:a7324f51348d | 50 | void to_line(float a,float b,float c); |
PedroMartins96 | 0:a7324f51348d | 51 | |
PedroMartins96 | 0:a7324f51348d | 52 | void motion(); |
PedroMartins96 | 0:a7324f51348d | 53 | |
PedroMartins96 | 0:a7324f51348d | 54 | void pressed(); |
PedroMartins96 | 0:a7324f51348d | 55 | |
PedroMartins96 | 0:a7324f51348d | 56 | void to_point(float x1,float y1); |
PedroMartins96 | 0:a7324f51348d | 57 | |
PedroMartins96 | 0:a7324f51348d | 58 | void to_pos(float x2, float y2, float phi2); |
PedroMartins96 | 0:a7324f51348d | 59 | |
PedroMartins96 | 0:a7324f51348d | 60 | #endif /* ROBOT_H_ */ |