Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
davidt315 committed Nov 22, 2019
2 parents a3da01d + 2d8b774 commit 4091927
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
13 changes: 6 additions & 7 deletions src-analysis/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:]
Expand Down
4 changes: 2 additions & 2 deletions src/drivetrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

struct Speeds {
// struct
float linvel = 30;
float linvel = 75;
float l;
float r;
};

#endif
#endif
11 changes: 8 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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,");
Expand All @@ -150,6 +153,8 @@ void loop() {
default:
drive_all(0);
break;
// l_motor.setSpeed(200);
// r_motor.setSpeed(200);
}
} else {
drive_all(0);
Expand Down
3 changes: 3 additions & 0 deletions start-arduino.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

python3 src-analysis/main.py
3 changes: 3 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

python3 src-analysis/main.py

0 comments on commit 4091927

Please sign in to comment.