MSPM0_ValvanoWare  1.0
ECE445L starter code
odometry.h
Go to the documentation of this file.
1 
23 /* This example accompanies the book
24  "Embedded Systems: Introduction to Robotics,
25  Jonathan W. Valvano, ISBN: 9781074544300, copyright (c) 2019
26  For more information about my classes, my research, and my books, see
27  http://users.ece.utexas.edu/~valvano/
28 
29 Simplified BSD License (FreeBSD License)
30 Copyright (c) 2019, Jonathan Valvano, All rights reserved.
31 
32 Redistribution and use in source and binary forms, with or without modification,
33 are permitted provided that the following conditions are met:
34 
35 1. Redistributions of source code must retain the above copyright notice,
36  this list of conditions and the following disclaimer.
37 2. Redistributions in binary form must reproduce the above copyright notice,
38  this list of conditions and the following disclaimer in the documentation
39  and/or other materials provided with the distribution.
40 
41 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
42 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
45 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
48 AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
50 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 
52 The views and conclusions contained in the software and documentation are
53 those of the authors and should not be interpreted as representing official
54 policies, either expressed or implied, of the FreeBSD Project.
55 */
56 #ifndef _ODOMETRY_H_
57 #define _ODOMETRY_H_
58 #include <stdint.h>
59 #define N 360
60 #define D 70000
61 #define W 140000
62 #define C 219910
63 #define PI 8192
64 #define TWOPI (2*PI)
65 #define NORTH 4096
66 #define EAST 0
67 #define SOUTH -4096
68 #define WEST -8192
69 #define XYTOLERANCE 10000
70 #define THETATOLERANCE (4096/90)
80 void Odometry_Init(int32_t initx, int32_t inity, int32_t initTheta);
81 
90 void Odometry_Update(int32_t LCount, int32_t RCount);
91 
101 void Odometry_SetPower(uint32_t fast, uint32_t slow);
102 
109 int32_t Odometry_GetX(void);
110 
117 int32_t Odometry_GetY(void);
118 
125 int32_t Odometry_GetAngle(void);
126 
127 
138 void Odometry_Get(int32_t *x, int32_t *y, int32_t *theta);
139 
140 
152  SOFTLEFT
153 };
154 
155 
156 
166 void UpdatePosition(void);
167 
175 void Display(void);
176 
185 
194 
202 uint32_t ForwardUntilCrash(void);
203 
211 uint32_t ForwardUntilX(int32_t desiredX);
212 
220 uint32_t ForwardUntilY(int32_t desiredY);
221 
229 uint32_t SoftLeftUntilTh(int32_t desiredTh);
230 
231 
239 void ForwardUntilXStart(int32_t thedesiredX);
240 
248 uint32_t ForwardUntilXStatus(void);
256 void ForwardUntilYStart(int32_t thedesiredY);
257 
265 uint32_t ForwardUntilYStatus(void);
266 
274 void SoftLeftUntilThStart(int32_t thedesiredTh);
275 
283 uint32_t ForwardUntilThStatus(void);
284 
295  RIGHTTOTH
296 };
297 
305 uint32_t CheckGoal(void);
306 #endif
int32_t Odometry_GetAngle(void)
Get theta angle.
void Odometry_Init(int32_t initx, int32_t inity, int32_t initTheta)
Initialize odometry module.
uint32_t ForwardUntilCrash(void)
Go until bumper touched.
void SoftLeftUntilThStart(int32_t thedesiredTh)
start going Forward Until Y
void ForwardUntilXStart(int32_t thedesiredX)
start going Forward Until X
void Odometry_Get(int32_t *x, int32_t *y, int32_t *theta)
Get the current robot position.
uint32_t ForwardUntilX(int32_t desiredX)
Forward Until X goal.
void StopUntilBumperTouched(void)
Stop and wait until bumper touched.
uint32_t ForwardUntilY(int32_t desiredY)
Forward Until Y goal.
int32_t Odometry_GetX(void)
Get X position.
uint32_t SoftLeftUntilTh(int32_t desiredTh)
Soft Left Until Theta.
void Odometry_Update(int32_t LCount, int32_t RCount)
Compute new position/angle of the robot.
void Odometry_SetPower(uint32_t fast, uint32_t slow)
Set power levels.
void WaitUntilBumperTouched(void)
Wait until bumper touched.
RobotState
robot state
Definition: odometry.h:146
uint32_t ForwardUntilYStatus(void)
check status of Forward Until Y command
void ForwardUntilYStart(int32_t thedesiredY)
start going Forward Until Y
void Display(void)
OLED output.
OdometryCommand
Odometry Commands.
Definition: odometry.h:290
uint32_t CheckGoal(void)
check status of odometry command
void UpdatePosition(void)
update position
uint32_t ForwardUntilXStatus(void)
check status of Forward Until X command
int32_t Odometry_GetY(void)
Get y position.
uint32_t ForwardUntilThStatus(void)
check status of soft left until theta command
@ SOFTLEFT
turning soft left
Definition: odometry.h:152
@ HARDLEFT
turning hard left
Definition: odometry.h:150
@ SOFTRIGHT
turning soft right
Definition: odometry.h:151
@ HARDRIGHT
turning hard right
Definition: odometry.h:149
@ ISSTOPPED
stopped
Definition: odometry.h:147
@ GOFORWARD
going forward
Definition: odometry.h:148
@ STOP
stop robot
Definition: odometry.h:291
@ RIGHTTOTH
turn right until theta is matched within tolerance THETATOLERANCE
Definition: odometry.h:295
@ FORWARDTOY
move forward straight until Y is matched within tolerance XYTOLERANCE
Definition: odometry.h:293
@ FORWARDTOX
move forward straight until X is matched within tolerance XYTOLERANCE
Definition: odometry.h:292
@ LEFTTOTH
turn left until theta is matched within tolerance THETATOLERANCE
Definition: odometry.h:294