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
09902102
Commit
09902102
authored
9 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Plain Diff
Merge branch 'turn' into 'master'
Turn down for what? See merge request
!1
parents
35d4123c
486ac124
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.c
+22
-3
22 additions, 3 deletions
main.c
with
22 additions
and
3 deletions
main.c
+
22
−
3
View file @
09902102
...
...
@@ -26,6 +26,24 @@ double distance(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
;
double
velocidade
,
distancia
;
...
...
@@ -48,10 +66,11 @@ 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
angle
=
angleFromOrigin
(
tuplas
[
i
].
x
,
tuplas
[
i
].
y
);
// 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
);
...
...
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