-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdds.pde
214 lines (154 loc) · 4.15 KB
/
dds.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import processing.opengl.*;
/*---->>>
This program maps joystick values X and Y to a differential drive system where two motors are used to drive a robot.
There is also a vizualization of a robot and path according to the motors differential rotation.
Author: Guilherme Martins
http://artica.cc
Credits:
The joystick program was based on a program entitled 'JoystickSimulation' by: Vince Thompson
http://diyroboticslab.wordpress.com/2009/06/17/joystick-simulation-with-processing/
The robot program was based on a program entitled 'Kephera Simulator' by Adam Matic of Croatia
http://gritsgroup.org/robotsimulator.htm
<<<----*/
/**************
VARIABLES
**************/
int displayWidth = 1200;
int displayHeight = 850;
/**************
JOYSTICK
**************/
int joyOutputRange = 90; //Maximum value for full horiz or vert position where centered is 0.
float curJoyDisplayWidth;
float curJoyDisplayHeight;
float maxJoyRange=200; //Maximum joystick range
float curJoyAngle; //Current joystick angle
float curJoyRange; //Current joystick range
float joyDisplayCenterX; //Joystick displayed Center X
float joyDisplayCenterY; //Joystick displayed Center Y
float dx, dy;
float joyHorizontalText, joyVerticalText;
/**************
RECTS
**************/
boolean activeXLeft, activeYLeft, activeInterpLeft;
boolean activeXRight, activeYRight, activeInterpRight;
float gXLeft, gYLeft, gXRight, gYRight;
/**************
COLORS
**************/
color color1;
color color2;
color color3;
color colorActive;
/**************
CONDITION
**************/
String condition;
float oneValLeft, oneValRight;
/**************
BOOLEAN VARIABLES
**************/
boolean drawRectsActive = false;
boolean displayConditionsRectsActive = false;
boolean drawRobot = true;
boolean drawMotorsValues = true;
boolean drawHelpStuff = true;
boolean robotMove = true;
boolean joystickActive = true;
boolean cameraActive = true;
boolean drawCameraDebug = true;
boolean gridActive = true;
boolean addPath = true;
boolean drawPath = true;
boolean activePath = true;
boolean hidef = true;
/**************
BROWNIAN
**************/
int brownianCounter = 0;
float maxBrownianCounter = random(300)+100;
/**************
CAMERA VARS
**************/
float inc = 5.0;
float eyeX = 375; //displayWidth/2.0;
float eyeY = 1200; //displayHeight/2.0;
float eyeZ = 622; //(displayHeight/2.0) / tan(PI*30.0 / 180.0);
float centerX = 405; //displayWidth/2.0;
float centerY = 320; //displayHeight/2.0;
float centerZ = 115; //0.0;
float upX = 0;
float upY = 1;
float upZ = 0;
float xpos = -240;
float ypos = 295;
float zpos = 350;
float rX = -0.276;
float rY = 0.0;
float rZ = 62.87;
/**************
DRAW ELEMENTS POSITIONS COORDS
**************/
int checkXpos = 25;
int checkYpos = 450;
color checkColor = color(76, 152, 227);
/********************************************************
SETUP
********************************************************/
void setup()
{
size(1200, 850, OPENGL);
// JOYSTICK
joyDisplayCenterX = 150;
joyDisplayCenterY = 50 + maxJoyRange/2;
curJoyDisplayWidth = maxJoyRange * .85;
curJoyDisplayHeight = curJoyDisplayWidth;
maxJoyRange = curJoyDisplayWidth / 2;
// COLORS
color1=color(0); //Color = Black
color2=color(150);
color3 = color(50, 200, 255);
colorActive = color(255, 0, 0);
smooth();
RobotSetup();
}
/********************************************************
DRAW
********************************************************/
void draw()
{
background(0);
joystickDraw();
joystickDetectInteraction();
robotDrawStage();
mainConditions();
}
/********************************************************
MAIN CONDITIONS
********************************************************/
void mainConditions()
{
if (joystickActive)
{
joystickConditions3();
joyStickDrawEllipse();
robotUpdater();
}
if (drawMotorsValues)
oneRect(oneValLeft, oneValRight);
if (drawRectsActive)
{
drawRectLeft();
drawRectRight();
}
if (drawCameraDebug)
drawCameraData();
if (keyPressed == true)
getKey();
if (drawHelpStuff)
{
drawHelpText();
drawRobotStatus();
}
}