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
Harbor Registry
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
c40c3977
Commit
c40c3977
authored
9 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Pegando angulo que o robô tem que girar
parent
88385fcc
No related branches found
No related tags found
1 merge request
!1
Turn
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.c
+21
-3
21 additions, 3 deletions
main.c
with
21 additions
and
3 deletions
main.c
+
21
−
3
View file @
c40c3977
...
...
@@ -20,6 +20,24 @@ double menorDistancia (int xa, int ya, int xb,int yb){
return
(
sqrt
((
xb
-
xa
)
*
(
xb
-
xa
)
+
(
yb
-
ya
)
*
(
yb
-
ya
)));
}
// Retorna o ângulo em relação a origem (0,0)
double
angleFromOrigin
(
int
x
,
int
y
)
{
/**
* Y
* ^
* |--*
* | /|
* |/ |
* +----------> X
* |
* 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 radianos)
*/
double
hip
=
x
*
x
+
y
*
y
;
return
asin
(
x
/
hip
);
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
int
t_size
;
Tuple
*
tuplas
;
...
...
@@ -41,10 +59,10 @@ int main(int argc, char const *argv[]) {
scanf
(
"%d %d %d"
,
&
tuplas
[
i
].
x
,
&
tuplas
[
i
].
y
,
&
tuplas
[
i
].
t
);
}
// calcular velocidade das rodas entre cada coordenada
for
(
int
i
=
0
;
i
<
t_size
;
++
i
)
{
// pega o ângulo entre a posição do robô e o próximo ponto
// gira o robô
// Pega o ângulo entre a posição do robô e o próximo ponto
double
turnAngle
=
angleFromOrigin
(
tuplas
[
i
].
x
,
tuplas
[
i
].
y
)
-
r
.
theta
;
// Gira o robô
// calcula a velocidade para as rodas
}
// gerar tabela e grafico
...
...
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