mirror of
https://github.com/PotentiaRobotics/engine-software.git
synced 2025-04-17 18:40:18 -04:00
Specify which degree for PID possible!
This commit is contained in:
parent
ba534ad8ac
commit
f5a5693023
|
@ -16,12 +16,16 @@ void setup(){
|
||||||
|
|
||||||
void loop(){
|
void loop(){
|
||||||
|
|
||||||
|
|
||||||
if(Serial.available() > 0) {
|
if(Serial.available() > 0) {
|
||||||
String data = Serial.readStringUntil('\n');
|
String data = Serial.readStringUntil('\n');
|
||||||
if(data=="Data"){
|
if(data=="Data"){
|
||||||
Serial.print("Hi Raspberry Pi! You sent me: ");
|
Serial.print("Hi Raspberry Pi! You sent me: ");
|
||||||
Serial.println(String(i));
|
Serial.println(String(i));
|
||||||
i+=1;}
|
i+=1;}
|
||||||
|
else{
|
||||||
|
Serial.println(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ MPU6050 mpu(0x69); // <-- use for AD0 high
|
||||||
depends on the MPU-6050's INT pin being connected to the Arduino's
|
depends on the MPU-6050's INT pin being connected to the Arduino's
|
||||||
external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is
|
external interrupt #0 pin. On the Arduino Uno and Mega 2560, this is
|
||||||
digital I/O pin 2.
|
digital I/O pin 2.
|
||||||
* ========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
NOTE: Arduino v1.0.1 with the Leonardo board generates a compile error
|
NOTE: Arduino v1.0.1 with the Leonardo board generates a compile error
|
||||||
|
@ -54,7 +54,7 @@ MPU6050 mpu(0x69); // <-- use for AD0 high
|
||||||
|
|
||||||
http://arduino.cc/forum/index.php/topic,109987.0.html
|
http://arduino.cc/forum/index.php/topic,109987.0.html
|
||||||
http://code.google.com/p/arduino/issues/detail?id=958
|
http://code.google.com/p/arduino/issues/detail?id=958
|
||||||
* ========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ myservo.attach(3);
|
||||||
// initialize serial communication
|
// initialize serial communication
|
||||||
// (115200 chosen because it is required for Teapot Demo output, but it's
|
// (115200 chosen because it is required for Teapot Demo output, but it's
|
||||||
// really up to you depending on your project)
|
// really up to you depending on your project)
|
||||||
Serial.begin(115200);
|
Serial.begin(9600);
|
||||||
while (!Serial); // wait for Leonardo enumeration, others continue immediately
|
while (!Serial); // wait for Leonardo enumeration, others continue immediately
|
||||||
|
|
||||||
// NOTE: 8MHz or slower host processors, like the Teensy @ 3.3V or Arduino
|
// NOTE: 8MHz or slower host processors, like the Teensy @ 3.3V or Arduino
|
||||||
|
@ -191,10 +191,6 @@ myservo.attach(3);
|
||||||
|
|
||||||
// wait for ready
|
// wait for ready
|
||||||
Serial.println(F("\nSend any character to begin DMP programming and demo: "));
|
Serial.println(F("\nSend any character to begin DMP programming and demo: "));
|
||||||
while (Serial.available() && Serial.read()); // empty buffer
|
|
||||||
while (!Serial.available()); // wait for data
|
|
||||||
while (Serial.available() && Serial.read()); // empty buffer again
|
|
||||||
|
|
||||||
// load and configure the DMP
|
// load and configure the DMP
|
||||||
Serial.println(F("Initializing DMP..."));
|
Serial.println(F("Initializing DMP..."));
|
||||||
devStatus = mpu.dmpInitialize();
|
devStatus = mpu.dmpInitialize();
|
||||||
|
@ -250,6 +246,13 @@ myservo.attach(3);
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
tic = toc;
|
tic = toc;
|
||||||
|
if (Serial.available() > 0) {
|
||||||
|
String data = Serial.readStringUntil('\n');
|
||||||
|
int data2 = data.toInt();
|
||||||
|
goal = data2;
|
||||||
|
}
|
||||||
|
Serial.print(goal);
|
||||||
|
Serial.print("\t");
|
||||||
// if programming failed, don't try to do anything
|
// if programming failed, don't try to do anything
|
||||||
if (!dmpReady) return;
|
if (!dmpReady) return;
|
||||||
// read a packet from FIFO
|
// read a packet from FIFO
|
||||||
|
@ -271,7 +274,9 @@ void loop() {
|
||||||
|
|
||||||
toc = millis();
|
toc = millis();
|
||||||
//dererr = (properr - (goal-ypr[0]))/(toc-tic);
|
//dererr = (properr - (goal-ypr[0]))/(toc-tic);
|
||||||
properr = goal-ypr[0];
|
properr = goal * M_PI / 180 - ypr[0];
|
||||||
|
Serial.print(ypr[0]);
|
||||||
|
Serial.print("\t");
|
||||||
//interr += properr * (toc-tic);
|
//interr += properr * (toc-tic);
|
||||||
Serial.println(properr * kp);
|
Serial.println(properr * kp);
|
||||||
int toRot = properr * kp;
|
int toRot = properr * kp;
|
||||||
|
|
13
RaspPi-flask-recieve/server-nosend.py
Normal file
13
RaspPi-flask-recieve/server-nosend.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import socket
|
||||||
|
host=''
|
||||||
|
port=2345
|
||||||
|
s=socket.socket()
|
||||||
|
s.bind((host,port))
|
||||||
|
s.listen(10)
|
||||||
|
while True:
|
||||||
|
conn,addr=s.accept()
|
||||||
|
print("Connected by",addr)
|
||||||
|
data=conn.recv(1024)
|
||||||
|
print("received data:",data)
|
||||||
|
conn.send(data)
|
||||||
|
conn.close()
|
|
@ -28,5 +28,5 @@ while True:
|
||||||
receive_string = ser.readline().decode('utf-8').rstrip()
|
receive_string = ser.readline().decode('utf-8').rstrip()
|
||||||
print(receive_string)
|
print(receive_string)
|
||||||
|
|
||||||
conn.send(receive_string.encode())
|
conn.send(data)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user