From 72e8012d8fde68c0f71e18114b3030f29710d062 Mon Sep 17 00:00:00 2001 From: Dieter Brehm Date: Thu, 21 Nov 2019 03:22:39 -0500 Subject: [PATCH 1/3] not working, but testing --- src-analysis/main.py | 13 ++++++------- src/drivetrain.h | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src-analysis/main.py b/src-analysis/main.py index 1bf6c48..018eb63 100755 --- a/src-analysis/main.py +++ b/src-analysis/main.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import serial #import numpy as np -#import pandas as pd +# import pandas as pd #import matplotlib.pyplot as plt #from mpl_toolkits.mplot3d import Axes3D import math @@ -15,7 +15,7 @@ def setup_serial(): """ Setup serial connection object""" - arduino_com_port = "/dev/ttyACM0" + arduino_com_port = "/dev/cu.usbmodem14201" baud_rate = 115200 serial_port = serial.Serial(arduino_com_port, baud_rate, timeout=1) return serial_port @@ -70,8 +70,7 @@ def main(): # as a daemon input_queue = queue.Queue() kbd_thread = threading.Thread(target=read_kbd, - args=(input_queue,), - daemon=True) + args=(input_queue,)) kbd_thread.start() # setup the serial object @@ -101,10 +100,10 @@ def main(): print("python side end\n") # convert to dataframe and write to a csv when # we stop the program! - df = pd.DataFrame(data_recorder[1:], columns=data_recorder[0]) - df.to_csv("robot_run", sep=',', encoding='utf-8') + # df = pd.DataFrame(data_recorder[1:], columns=data_recorder[0]) + # df.to_csv("robot_run", sep=',', encoding='utf-8') # print it out to see if that worked - print(df) + # print(df) elif (input_reading[0] == "V" or input_reading[0] == "v"): # change the speed of the robot output = "V" + input_reading[1:] diff --git a/src/drivetrain.h b/src/drivetrain.h index 5f60fab..c423aa9 100644 --- a/src/drivetrain.h +++ b/src/drivetrain.h @@ -3,9 +3,9 @@ struct Speeds { // struct - float linvel = 30; + float linvel = 75; float l; float r; }; -#endif \ No newline at end of file +#endif From a9947ed0f4168e7c9cbb72ff32ce5cf59c3fcb76 Mon Sep 17 00:00:00 2001 From: Dieter Brehm Date: Thu, 21 Nov 2019 18:05:43 -0500 Subject: [PATCH 2/3] program works over usb serial --- src/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c1df803..e63fb7b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,13 +1,15 @@ /* - * Line Following Robot - * By Sam Daitzman, David Tarazi, and Dieter Brehm + * Stair climber + * By Caroline Rausch, Sam Daitzman, David Tarazi, and Dieter Brehm */ #include "Arduino.h" #include "Wire.h" #include "pid.h" #include "drivetrain.h" #include "CytronMotorDriver.h" +#include "Adafruit_MS_PWMServoDriver.h" +#include "Adafruit_MotorShield.h" CytronMD l_motor(PWM_DIR, 3, 4); // PWM = Pin 3, DIR = Pin 4 CytronMD r_motor(PWM_DIR, 5, 6); // PWM = Pin 3, DIR = Pin 4 @@ -29,6 +31,7 @@ void send_motor_cmd(int l, int r) { // handles negative values as reverse direction l_motor.setSpeed(l); r_motor.setSpeed(-r); + delay(10); } void drive_all(int speed) { @@ -124,7 +127,7 @@ void loop() { // S = run // E = stop running - // log values + // log values // LOG,time,left,right,sensor_left, sensor_right Serial.print("LOG,Motors,"); @@ -150,6 +153,8 @@ void loop() { default: drive_all(0); break; + // l_motor.setSpeed(200); + // r_motor.setSpeed(200); } } else { drive_all(0); From 2d8b77401e8ad0c905412e94eb0b5de206a5c4c8 Mon Sep 17 00:00:00 2001 From: Dieter Brehm Date: Thu, 21 Nov 2019 19:10:51 -0500 Subject: [PATCH 3/3] Add two scripts which make running the robot easier just run start.sh to run the python script, and start-arduino.sh to direct connect to serial --- start-arduino.sh | 3 +++ start.sh | 3 +++ 2 files changed, 6 insertions(+) create mode 100755 start-arduino.sh create mode 100755 start.sh diff --git a/start-arduino.sh b/start-arduino.sh new file mode 100755 index 0000000..a587184 --- /dev/null +++ b/start-arduino.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +python3 src-analysis/main.py diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..a587184 --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +python3 src-analysis/main.py