EE445M RTOS
Taken at the University of Texas Spring 2015
drivepp.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset: 4; -*- */
2 #ifndef __drivepp__
3 #define __drivepp__
4 
5 #include <stdint.h>
6 
7 #include "motorpp.hpp"
8 #include "direction.hpp"
9 
10 #define steps_to_wait 200
11 
16 typedef uint32_t distance; /* cm */
17 typedef uint16_t angle; /* 0 - 360 */
18 
19 class drive {
20 private:
25 
26  static const int32_t kp_oblique_num = 10;
27  static const int32_t kp_oblique_denom = 1;
28 
29  static const int32_t kp_side_num = 5;
30  static const int32_t kp_side_denom = 2;
31 
32  static const int32_t ki_oblique_num = 1;
33  static const int32_t ki_oblique_denom = 10000;
34 
35  static const int32_t ki_side_num = 1;
36  static const int32_t ki_side_denom = 2000;
37 
38  int32_t last_counter;
39 
40 public:
41  drive();
42  drive(motor* left, motor* right, percent_t speed = 0,
43  Direction direction = FORWARD);
44 
46  void forward(percent_t speed);
47 
49  void backward(percent_t speed);
50 
52  void set(percent_t speed, Direction dir);
53 
55  void stop(void);
56 
58  void start(void);
59 
61  void steer(uint32_t left_sens, uint32_t left_front_sens,
62  uint32_t right_sens, uint32_t right_front_sens,
63  uint32_t front_sens);
64 
65  void reset_history();
66 };
67 
68 #endif
69 
74 /* Local Variables: */
75 /* firestarter: (compile "make -k -j32 -C ~/workspace/ee445m-labs/build/") */
76 /* End: */
static const int32_t ki_oblique_num
Definition: drivepp.hpp:32
uint32_t distance
Definition: drivepp.hpp:16
static const int32_t kp_oblique_denom
Definition: drivepp.hpp:27
void set(percent_t speed, Direction dir)
Definition: drivepp.cpp:44
uint16_t angle
Definition: drivepp.hpp:17
motor * right
Definition: drivepp.hpp:22
static const int32_t ki_side_denom
Definition: drivepp.hpp:36
void steer(uint32_t left_sens, uint32_t left_front_sens, uint32_t right_sens, uint32_t right_front_sens, uint32_t front_sens)
Definition: drivepp.cpp:50
int32_t percent_t
Definition: motorpp.hpp:15
drive()
Definition: drivepp.cpp:10
int32_t integral_oblique_error
Definition: drivepp.hpp:23
static const int32_t kp_side_denom
Definition: drivepp.hpp:30
Direction
Definition: direction.hpp:8
void backward(percent_t speed)
Definition: drivepp.cpp:38
int32_t integral_side_error
Definition: drivepp.hpp:24
motor * left
Definition: drivepp.hpp:21
int32_t last_counter
Definition: drivepp.hpp:38
static const int32_t kp_side_num
Definition: drivepp.hpp:29
void stop(void)
Definition: drivepp.cpp:20
void start(void)
Definition: drivepp.cpp:26
void reset_history()
Definition: drivepp.cpp:122
static const int32_t ki_side_num
Definition: drivepp.hpp:35
static const int32_t kp_oblique_num
Definition: drivepp.hpp:26
void forward(percent_t speed)
Definition: drivepp.cpp:32
static const int32_t ki_oblique_denom
Definition: drivepp.hpp:33