-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
55 lines (45 loc) · 1.29 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* MIT License
*/
/*
* File: main.cpp
* Author: josh
*
* Created on May 24, 2020, 7:40 PM
* This is just a test program to exercise the motor_jetson library during
* development.
*/
#include "definitions.h"
#include "Motor_Jetson.hpp"
#include <unistd.h>
int main(int argc, char** argv) {
Motor_Jetson mj(JETSON_DRIVE_PIN, JETSON_IN1_PIN,
JETSON_IN2_PIN,JETSON_STEER_PIN,
MAX_RIGHT_STEERING_US,
MAX_LEFT_STEERING_US,
MIN_STEERING_INPUT, MAX_STEERING_INPUT);
while (true){
mj.setDirection(Motor_Jetson::FORWARD);
std::cout << "Driving Forward " << std::endl;
mj.run();
for (int i=0; i < 255; i++){
mj.setDriveSpeed(i/2.6);
usleep(1000);
mj.turnAbsolute(i);
usleep(10000);
}
mj.setDirection(Motor_Jetson::STOP);
usleep(1000);
std::cout << "Stopping " << std::endl;
for (int i=255; i>0;i--){
mj.setDriveSpeed(i/2.6);
usleep (1000);
mj.turnAbsolute(i);
usleep(10000);
}
mj.setDirection(Motor_Jetson::BACKWARD);
std::cout << "going backwards " << std::endl;
usleep(1000000);
}
return 0;
}