SlideShare a Scribd company logo
4. GT DRAWBOT
Control
GAZTEATECH 2015
ROBÓTICA
Svet Ivantchev
Jon Agüero
S1: 0º
S1: 90º
S2: 0ºS2: 180º
S1
S2
x
y
l1
l2
f1
q1
f2
Tenemos: x y y
Necesitamos: f1 y f2
S1
S2
x
y
b
l1
l2
f1
q2
q1
q1 = tan 1
(y/x)
b2
= x2
+ y2
f1 = q1 q2
l2
2 = l2
1 + b2
2l1b cos(q2)
q2 = cos 1
✓
l2
1 l2
2 + b2
2l1b
◆
S1
S2
x
y
b
l1
l2
f2
b2
b2 = cos 1
✓
l2
1 + l2
2 b2
2l1l2
◆
f2 = ⇡ b2
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
void setup() {
size(300,300);
arduino = new Arduino(this, "/dev/tty.usbmodem1421", 57600);
arduino.pinMode(4, Arduino.SERVO);
arduino.pinMode(7, Arduino.SERVO);
}
void draw() {
int x,y;
float l1=1000.0;
float l2=1000.0;
float q1,q2,f1,f2,b;
x = 1200;
y = 1200;
b = sqrt(x*x+y*y);
q1= atan2(y, x);
q2= acos((l1*l1 - l2*l2 + b*b)/(2.0*l1*b));
f1=degrees(q1+q2) ;
f2=degrees(acos((l1*l1 + l2*l2 -b*b)/(2*l1*l2)));
if (q1 > f1 ) {
f2 = (f2-90);
} else {
f2 = 180 - (f2-90);
};
println(f1, f2);
arduino.servoWrite(7, (int)f1);
arduino.servoWrite(4, (int)f2);
delay(30);
exit();
}
PREPARACIÓN DE IMAGEN
PREPARACIÓN DE IMAGEN
Imagen en JPEG
Fichero SVG
DrawBot
StippleGen2
Processing sketch
COMO LEER EL SVG
Instalar la librería geomerative: Sketch > Import Library … > Add Library …
COMO LEER EL SVG
import geomerative.*;
RShape s1;
void setup() {
size(500,500);
RG.init(this);
s1 = RG.loadShape("star.svg");
}
void draw() {
float x,y;
float maxx, maxy, minx, miny;
RPoint[] pa = s1.getPoints();
println(pa.length);
maxx = 0; maxy = 0;
minx = 10000; miny = 10000;
for (int i = 0; i < pa.length; i++) {
x = pa[i].x; y = pa[i].y;
if (x > maxx) { maxx = x;};
if (y > maxy) { maxy = y;};
if (x < minx) { minx = x;};
if (y < miny) { miny = y;};
}
println(minx,maxx, miny, maxy);
noFill();
beginShape();
for (int i = 0; i < pa.length; i++) {
x = map( pa[i].x, minx, maxx, 0, 499);
y = map( pa[i].y, miny, maxy, 0, 499);
vertex(x,y);
println(x,y);
}
endShape();
}
Combinando lectura de SVG y el control del Drawbot
import geomerative.*;
import processing.serial.*;
import cc.arduino.*;
RShape s1;
Arduino arduino;
void setup() {
size(300,300);
RG.init(this);
s1 = RG.loadShape("star.svg");
arduino = new Arduino(this, "/dev/tty.usbmodem1421", 57600);
arduino.pinMode(4, Arduino.SERVO);
arduino.pinMode(7, Arduino.SERVO);
}
void draw() {
float x,y;
float maxx, maxy, minx, miny;
float l1=1000.0;
float l2=1000.0;
float q1,q2,f1,f2,b;
RPoint[] pa = s1.getPoints();
println(pa.length);
maxx=0; maxy=0;
minx = 10000; miny = 10000;
for (int i = 0; i < pa.length; i++) {
x = pa[i].x;
y = pa[i].y;
if (x > maxx) { maxx = x;};
if (y > maxy) { maxy = y;};
if (x < minx) { minx = x;};
if (y < miny) { miny = y;};
}
println(minx,maxx, miny, maxy);
noFill();
beginShape();
for (int i = 0; i < pa.length; i++) {
x = map( pa[i].x, minx, maxx, 1050, 1450);
y = map( pa[i].y, miny, maxy, 1050, 1450);
vertex(x,y);
println(x,y);
b = sqrt(x*x+y*y);
q1= atan2(y, x);
q2= acos((l1*l1 - l2*l2 + b*b)/(2.0*l1*b));
f1=degrees(q1+q2) ;
f2=degrees(acos((l1*l1 + l2*l2 -b*b)/(2*l1*l2)));
if (q1 > f1 ) {
f2 = (f2-90);
} else {
f2 = 180 - (f2-90);
};
println(f1, f2);
arduino.servoWrite(7, (int)f1);
arduino.servoWrite(4, (int)f2);
delay(30);
}
endShape();
delay(500);
exit();
}

More Related Content

What's hot

Luis cuñas programacion
Luis cuñas programacionLuis cuñas programacion
Luis cuñas programacionluisitofranklin
 
c ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmc ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmIsaac Aquino
 
Week 7 unit3 (chapter 10-11)
Week 7   unit3 (chapter 10-11)Week 7   unit3 (chapter 10-11)
Week 7 unit3 (chapter 10-11)
aj.mapling
 
contoh Program C++ tentang fungsi for
contoh Program C++ tentang fungsi forcontoh Program C++ tentang fungsi for
contoh Program C++ tentang fungsi for
M Fahmi Ansori
 
Ejercicios resueltos Practica 4 informatica II
Ejercicios resueltos Practica 4 informatica IIEjercicios resueltos Practica 4 informatica II
Ejercicios resueltos Practica 4 informatica II
Alvin Jacobs
 
MUDA
MUDAMUDA
Configuracion para 877 con fuses
Configuracion para 877 con fusesConfiguracion para 877 con fuses
Configuracion para 877 con fusesRafael Duran
 
高師大 從無到有的Arduino車
高師大 從無到有的Arduino車高師大 從無到有的Arduino車
高師大 從無到有的Arduino車
趙 亨利
 
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習BopenFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習BAtsushi Tadokoro
 
Антон Полухин. C++17
Антон Полухин. C++17Антон Полухин. C++17
Антон Полухин. C++17
Sergey Platonov
 
vecotores programacion
vecotores programacionvecotores programacion
vecotores programacion
Alex Flores Avalos
 
Programación funcional en Haskell
Programación funcional en HaskellProgramación funcional en Haskell
Programación funcional en HaskellRoberto Bonvallet
 
Practica 4 errores
Practica 4 erroresPractica 4 errores
Practica 4 erroresUVM
 
Novatadas en java
Novatadas en javaNovatadas en java
Novatadas en java
wmca28
 
C++14 reflections
C++14 reflections C++14 reflections
C++14 reflections
corehard_by
 
Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)
santiagovargasm
 

What's hot (20)

Sbaw091013
Sbaw091013Sbaw091013
Sbaw091013
 
Luis cuñas programacion
Luis cuñas programacionLuis cuñas programacion
Luis cuñas programacion
 
c ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmc ++ informe Nº5 ucsm
c ++ informe Nº5 ucsm
 
Week 7 unit3 (chapter 10-11)
Week 7   unit3 (chapter 10-11)Week 7   unit3 (chapter 10-11)
Week 7 unit3 (chapter 10-11)
 
contoh Program C++ tentang fungsi for
contoh Program C++ tentang fungsi forcontoh Program C++ tentang fungsi for
contoh Program C++ tentang fungsi for
 
Ejercicios resueltos Practica 4 informatica II
Ejercicios resueltos Practica 4 informatica IIEjercicios resueltos Practica 4 informatica II
Ejercicios resueltos Practica 4 informatica II
 
All set1
All set1All set1
All set1
 
Programacion
ProgramacionProgramacion
Programacion
 
Assignment
AssignmentAssignment
Assignment
 
MUDA
MUDAMUDA
MUDA
 
Configuracion para 877 con fuses
Configuracion para 877 con fusesConfiguracion para 877 con fuses
Configuracion para 877 con fuses
 
高師大 從無到有的Arduino車
高師大 從無到有的Arduino車高師大 從無到有的Arduino車
高師大 從無到有的Arduino車
 
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習BopenFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B
 
Антон Полухин. C++17
Антон Полухин. C++17Антон Полухин. C++17
Антон Полухин. C++17
 
vecotores programacion
vecotores programacionvecotores programacion
vecotores programacion
 
Programación funcional en Haskell
Programación funcional en HaskellProgramación funcional en Haskell
Programación funcional en Haskell
 
Practica 4 errores
Practica 4 erroresPractica 4 errores
Practica 4 errores
 
Novatadas en java
Novatadas en javaNovatadas en java
Novatadas en java
 
C++14 reflections
C++14 reflections C++14 reflections
C++14 reflections
 
Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)
 

More from Svet Ivantchev

Machne Learning and Human Learning (2013).
Machne Learning and Human Learning (2013).Machne Learning and Human Learning (2013).
Machne Learning and Human Learning (2013).
Svet Ivantchev
 
Big Data: 
Some Questions in its Use in Applied Economics (2017)
Big Data: 
Some Questions in its Use in Applied Economics (2017)Big Data: 
Some Questions in its Use in Applied Economics (2017)
Big Data: 
Some Questions in its Use in Applied Economics (2017)
Svet Ivantchev
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
Svet Ivantchev
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
Svet Ivantchev
 
Gaztea Tech 2015: 3. Processing y Firmata
Gaztea Tech 2015: 3. Processing y FirmataGaztea Tech 2015: 3. Processing y Firmata
Gaztea Tech 2015: 3. Processing y Firmata
Svet Ivantchev
 
Gaztea Tech 2015: 2. El GT DrawBot
Gaztea Tech 2015: 2. El GT DrawBotGaztea Tech 2015: 2. El GT DrawBot
Gaztea Tech 2015: 2. El GT DrawBot
Svet Ivantchev
 
Gaztea Tech 2015: 1. Introducción al Arduino
Gaztea Tech 2015: 1. Introducción al ArduinoGaztea Tech 2015: 1. Introducción al Arduino
Gaztea Tech 2015: 1. Introducción al Arduino
Svet Ivantchev
 
Learning Analytics and Online Learning: New Oportunities?
Learning Analytics and Online Learning: New Oportunities?Learning Analytics and Online Learning: New Oportunities?
Learning Analytics and Online Learning: New Oportunities?Svet Ivantchev
 
How Machine Learning and Big Data can Help Us with the Human Learning
How Machine Learning and Big Data can Help Us with the Human LearningHow Machine Learning and Big Data can Help Us with the Human Learning
How Machine Learning and Big Data can Help Us with the Human Learning
Svet Ivantchev
 
Libros electrónicos IV: ePub 2
Libros electrónicos IV: ePub 2Libros electrónicos IV: ePub 2
Libros electrónicos IV: ePub 2Svet Ivantchev
 
Libros electrónicos III
Libros electrónicos IIILibros electrónicos III
Libros electrónicos IIISvet Ivantchev
 
Libros electrónicos II - ePub
Libros electrónicos II - ePubLibros electrónicos II - ePub
Libros electrónicos II - ePubSvet Ivantchev
 
Libros electrónicos I
Libros electrónicos ILibros electrónicos I
Libros electrónicos ISvet Ivantchev
 
Cloud Computing: Just Do It
Cloud Computing: Just Do ItCloud Computing: Just Do It
Cloud Computing: Just Do ItSvet Ivantchev
 
Cloud Computing: What it is, DOs and DON'Ts
Cloud Computing: What it is, DOs and DON'TsCloud Computing: What it is, DOs and DON'Ts
Cloud Computing: What it is, DOs and DON'TsSvet Ivantchev
 
Los mitos de la innovación
Los mitos de la innovaciónLos mitos de la innovación
Los mitos de la innovaciónSvet Ivantchev
 

More from Svet Ivantchev (20)

Machne Learning and Human Learning (2013).
Machne Learning and Human Learning (2013).Machne Learning and Human Learning (2013).
Machne Learning and Human Learning (2013).
 
Big Data: 
Some Questions in its Use in Applied Economics (2017)
Big Data: 
Some Questions in its Use in Applied Economics (2017)Big Data: 
Some Questions in its Use in Applied Economics (2017)
Big Data: 
Some Questions in its Use in Applied Economics (2017)
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
 
Gaztea Tech 2015: 3. Processing y Firmata
Gaztea Tech 2015: 3. Processing y FirmataGaztea Tech 2015: 3. Processing y Firmata
Gaztea Tech 2015: 3. Processing y Firmata
 
Gaztea Tech 2015: 2. El GT DrawBot
Gaztea Tech 2015: 2. El GT DrawBotGaztea Tech 2015: 2. El GT DrawBot
Gaztea Tech 2015: 2. El GT DrawBot
 
Gaztea Tech 2015: 1. Introducción al Arduino
Gaztea Tech 2015: 1. Introducción al ArduinoGaztea Tech 2015: 1. Introducción al Arduino
Gaztea Tech 2015: 1. Introducción al Arduino
 
Learning Analytics and Online Learning: New Oportunities?
Learning Analytics and Online Learning: New Oportunities?Learning Analytics and Online Learning: New Oportunities?
Learning Analytics and Online Learning: New Oportunities?
 
How Machine Learning and Big Data can Help Us with the Human Learning
How Machine Learning and Big Data can Help Us with the Human LearningHow Machine Learning and Big Data can Help Us with the Human Learning
How Machine Learning and Big Data can Help Us with the Human Learning
 
Vienen los Drones!
Vienen los Drones!Vienen los Drones!
Vienen los Drones!
 
Data Science
Data ScienceData Science
Data Science
 
Libros electrónicos IV: ePub 2
Libros electrónicos IV: ePub 2Libros electrónicos IV: ePub 2
Libros electrónicos IV: ePub 2
 
Libros electrónicos III
Libros electrónicos IIILibros electrónicos III
Libros electrónicos III
 
Libros electrónicos II - ePub
Libros electrónicos II - ePubLibros electrónicos II - ePub
Libros electrónicos II - ePub
 
Libros electrónicos I
Libros electrónicos ILibros electrónicos I
Libros electrónicos I
 
Cloud Computing: Just Do It
Cloud Computing: Just Do ItCloud Computing: Just Do It
Cloud Computing: Just Do It
 
Cloud Computing: What it is, DOs and DON'Ts
Cloud Computing: What it is, DOs and DON'TsCloud Computing: What it is, DOs and DON'Ts
Cloud Computing: What it is, DOs and DON'Ts
 
BigData
BigDataBigData
BigData
 
Los mitos de la innovación
Los mitos de la innovaciónLos mitos de la innovación
Los mitos de la innovación
 
eFaber en 5 minutos
eFaber en 5 minutoseFaber en 5 minutos
eFaber en 5 minutos
 

Gaztea Tech 2015: 4. GT Drawbot Control

  • 1. 4. GT DRAWBOT Control GAZTEATECH 2015 ROBÓTICA Svet Ivantchev Jon Agüero
  • 2.
  • 3. S1: 0º S1: 90º S2: 0ºS2: 180º
  • 4. S1 S2 x y l1 l2 f1 q1 f2 Tenemos: x y y Necesitamos: f1 y f2
  • 5. S1 S2 x y b l1 l2 f1 q2 q1 q1 = tan 1 (y/x) b2 = x2 + y2 f1 = q1 q2 l2 2 = l2 1 + b2 2l1b cos(q2) q2 = cos 1 ✓ l2 1 l2 2 + b2 2l1b ◆
  • 6. S1 S2 x y b l1 l2 f2 b2 b2 = cos 1 ✓ l2 1 + l2 2 b2 2l1l2 ◆ f2 = ⇡ b2
  • 7. import processing.serial.*; import cc.arduino.*; Arduino arduino; void setup() { size(300,300); arduino = new Arduino(this, "/dev/tty.usbmodem1421", 57600); arduino.pinMode(4, Arduino.SERVO); arduino.pinMode(7, Arduino.SERVO); } void draw() { int x,y; float l1=1000.0; float l2=1000.0; float q1,q2,f1,f2,b; x = 1200; y = 1200; b = sqrt(x*x+y*y); q1= atan2(y, x); q2= acos((l1*l1 - l2*l2 + b*b)/(2.0*l1*b)); f1=degrees(q1+q2) ; f2=degrees(acos((l1*l1 + l2*l2 -b*b)/(2*l1*l2))); if (q1 > f1 ) { f2 = (f2-90); } else { f2 = 180 - (f2-90); }; println(f1, f2); arduino.servoWrite(7, (int)f1); arduino.servoWrite(4, (int)f2); delay(30); exit(); }
  • 10.
  • 11. Imagen en JPEG Fichero SVG DrawBot StippleGen2 Processing sketch
  • 12. COMO LEER EL SVG Instalar la librería geomerative: Sketch > Import Library … > Add Library …
  • 13. COMO LEER EL SVG import geomerative.*; RShape s1; void setup() { size(500,500); RG.init(this); s1 = RG.loadShape("star.svg"); } void draw() { float x,y; float maxx, maxy, minx, miny; RPoint[] pa = s1.getPoints(); println(pa.length); maxx = 0; maxy = 0; minx = 10000; miny = 10000; for (int i = 0; i < pa.length; i++) { x = pa[i].x; y = pa[i].y; if (x > maxx) { maxx = x;}; if (y > maxy) { maxy = y;}; if (x < minx) { minx = x;}; if (y < miny) { miny = y;}; } println(minx,maxx, miny, maxy); noFill(); beginShape(); for (int i = 0; i < pa.length; i++) { x = map( pa[i].x, minx, maxx, 0, 499); y = map( pa[i].y, miny, maxy, 0, 499); vertex(x,y); println(x,y); } endShape(); }
  • 14. Combinando lectura de SVG y el control del Drawbot
  • 15. import geomerative.*; import processing.serial.*; import cc.arduino.*; RShape s1; Arduino arduino; void setup() { size(300,300); RG.init(this); s1 = RG.loadShape("star.svg"); arduino = new Arduino(this, "/dev/tty.usbmodem1421", 57600); arduino.pinMode(4, Arduino.SERVO); arduino.pinMode(7, Arduino.SERVO); } void draw() { float x,y; float maxx, maxy, minx, miny; float l1=1000.0; float l2=1000.0; float q1,q2,f1,f2,b; RPoint[] pa = s1.getPoints(); println(pa.length); maxx=0; maxy=0; minx = 10000; miny = 10000; for (int i = 0; i < pa.length; i++) { x = pa[i].x; y = pa[i].y; if (x > maxx) { maxx = x;}; if (y > maxy) { maxy = y;}; if (x < minx) { minx = x;}; if (y < miny) { miny = y;}; } println(minx,maxx, miny, maxy); noFill(); beginShape(); for (int i = 0; i < pa.length; i++) { x = map( pa[i].x, minx, maxx, 1050, 1450); y = map( pa[i].y, miny, maxy, 1050, 1450); vertex(x,y); println(x,y); b = sqrt(x*x+y*y); q1= atan2(y, x); q2= acos((l1*l1 - l2*l2 + b*b)/(2.0*l1*b)); f1=degrees(q1+q2) ; f2=degrees(acos((l1*l1 + l2*l2 -b*b)/(2*l1*l2))); if (q1 > f1 ) { f2 = (f2-90); } else { f2 = 180 - (f2-90); }; println(f1, f2); arduino.servoWrite(7, (int)f1); arduino.servoWrite(4, (int)f2); delay(30); } endShape(); delay(500); exit(); }