diff --git a/adapter_ard.h b/adapter_ard.h index fddd318..f9ef511 100644 --- a/adapter_ard.h +++ b/adapter_ard.h @@ -6,7 +6,10 @@ void loop(); void setup(); long millis(); long micros(); +void delay(unsigned long milli); int abs(int in); +double max(double a, double b); +double min(double a, double b); void pinMode(int pin, int mode); int analogRead(int pin); void digitalWrite(int pin, int level); @@ -21,6 +24,10 @@ class serial_c{ void print(std::string txt); void println(int nb); void print(int nb); + void print(float nb); + void println(float nb); + void print(double nb); + void println(double nb); }; extern serial_c Serial; diff --git a/laby.py b/laby.py index 6eaa439..d6ad512 100644 --- a/laby.py +++ b/laby.py @@ -22,7 +22,7 @@ class Laby: L17=0.20 walls = [ ((0,0),(0,L17)), - ((0,L17+L4),(0,L17+L4+L2)), + #((0,L17+L4),(0,L17+L4+L2)), ((0,0),(L8,0)), ((L8,0),(L8,L7)), ((L8,L7),(L8+L3,L7)), diff --git a/main.cpp b/main.cpp index 36eda96..17c28d9 100644 --- a/main.cpp +++ b/main.cpp @@ -43,11 +43,17 @@ int main(int argc, char** argv){ } printf("$dt,%ld;", micros()); loop(); + delay(10); printf("*"); fflush(stdout); } } +void delay(unsigned long milli){ + unsigned long end = millis() + milli; + while(millis() <= end); +} + long millis(){ clock_gettime(CLOCK_MONOTONIC_RAW, &end); uint64_t milli = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000; @@ -66,6 +72,13 @@ int abs(int in){ return abs(in); } +double min(double a, double b){ + return ab?a:b; +} + void pinMode(int pin, int mode){ printf("$pm,%d,%d;",pin, mode); } @@ -99,6 +112,23 @@ void serial_c::print(int nb){ printf("serial : %d", nb); } +void serial_c::print(float nb){ + printf("serial : %f", nb); +} + +void serial_c::println(float nb){ + this->print(nb); + printf("\n"); +} +void serial_c::print(double nb){ + printf("serial : %f", nb); +} + +void serial_c::println(double nb){ + this->print(nb); + printf("\n"); +} + void serial_c::println(int nb){ this->print(nb); printf("\n"); diff --git a/projet-tuteure-3a b/projet-tuteure-3a index c54363f..55b6ea6 160000 --- a/projet-tuteure-3a +++ b/projet-tuteure-3a @@ -1 +1 @@ -Subproject commit c54363fde2edebb39355ba264c1b85dd2258bef4 +Subproject commit 55b6ea6ff947589b354610e1d07d872e799be815 diff --git a/robot.py b/robot.py index 35b5dc9..aa1d45d 100644 --- a/robot.py +++ b/robot.py @@ -12,7 +12,7 @@ class Robot: # velocite des roues (non angulaire) wv=[0,0] # velocite max - wmv=0.1 + wmv=0.3 # espace entre les deux roues l=0.1 # time