Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T800
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vytor Calixto
T800
Commits
b9e06ce4
Commit
b9e06ce4
authored
9 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Arrumado angulo e feita saída pro gráfico
parent
09902102
Branches
Branches containing commit
No related tags found
1 merge request
!2
Out files
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
main.c
+15
-4
15 additions, 4 deletions
main.c
with
17 additions
and
4 deletions
.gitignore
+
2
−
0
View file @
b9e06ce4
robot
graph
table
This diff is collapsed.
Click to expand it.
main.c
+
15
−
4
View file @
b9e06ce4
...
...
@@ -2,6 +2,7 @@
#include
<math.h>
#include
<stdlib.h>
#define PI 3.14159265
#define L 0.15
// L = Distancia centro da roda - eixo em cm
...
...
@@ -38,10 +39,10 @@ double angleFromOrigin(int x, int y) {
* |
* 1. Sabendo os valores de x e y, calculamos a hipotenusa
* 2. Com o valor de X e da Hip, temos o seno do ângulo formado entre a hipotenusa e o eixo X
* 3. Fazemos a função arco seno para pegar o valor do ângulo (em ra
diano
s)
* 3. Fazemos a função arco
cos
seno para pegar o valor do ângulo (em
g
ra
u
s)
*/
double
hip
=
x
*
x
+
y
*
y
;
return
a
sin
(
x
/
hip
);
double
hip
=
sqrt
(
x
*
x
+
y
*
y
)
;
return
a
cos
(
x
/
hip
)
*
180
/
PI
;
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
...
...
@@ -49,6 +50,12 @@ int main(int argc, char const *argv[]) {
double
velocidade
,
distancia
;
Tuple
*
tuplas
;
Robot
r
=
{
0
,
0
,
0
};
FILE
*
graph
=
fopen
(
"./graph"
,
"w"
);
FILE
*
out
=
fopen
(
"./table"
,
"w"
);
if
(
graph
==
NULL
||
out
==
NULL
)
{
puts
(
"Erro ao criar arquivos de saída."
);
exit
(
1
);
}
puts
(
"Quantos pontos há na lista? Mínimo de 10 elementos."
);
scanf
(
"%d"
,
&
t_size
);
if
(
t_size
<
10
)
{
...
...
@@ -69,13 +76,17 @@ int main(int argc, char const *argv[]) {
for
(
int
i
=
0
;
i
<
t_size
;
++
i
)
{
// Pega o ângulo entre a posição do robô e o próximo ponto
double
angle
=
angleFromOrigin
(
tuplas
[
i
].
x
,
tuplas
[
i
].
y
);
fprintf
(
graph
,
"r %f
\n
"
,
angle
-
r
.
theta
);
// Gira o robô
r
.
theta
=
angle
;
// calcula a velocidade para as rodas
distancia
=
distance
(
r
.
x
,
r
.
y
,
tuplas
[
i
].
x
,
tuplas
[
i
].
y
);
velocidade
=
velocity
(
distancia
,
tuplas
[
i
].
t
);
fprintf
(
graph
,
"w %f
\n
"
,
velocidade
);
}
// gerar tabela e grafico
fclose
(
graph
);
fclose
(
out
);
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment