Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LEGO Group 8
LEGO
Commits
75669189
Commit
75669189
authored
Mar 03, 2015
by
Peder Kronsgaard Detlefsen
Browse files
Reverted some changes in PartyFinder to make robot more stable.
parent
663a1d6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
lesson3/ComplexPartyFinder/src/PartyFinder.java
View file @
75669189
...
...
@@ -38,12 +38,11 @@ public class PartyFinder extends Thread {
public
void
run
()
{
// Do initial setup before main loop.
int
counter
=
0
;
int
threshold
=
950
;
while
(
running
)
{
// Read values from the sensors.
// More noise from motors behind the robot.
soundLeft
=
sensorLeft
.
readRawValue
()
+
1
25
;
soundLeft
=
sensorLeft
.
readRawValue
()
+
1
00
;
// Less noise in front.
soundRight
=
sensorRight
.
readRawValue
();
...
...
@@ -89,17 +88,7 @@ public class PartyFinder extends Thread {
* 6. When average doens't get lower we are at the party.
*/
if
(
soundLeftAvg
>
threshold
+
125
&&
soundRightAvg
>
threshold
)
{
motorMode
=
Car
.
stop
;
}
else
if
(
soundLeftAvg
>
soundRightAvg
)
{
motorMode
=
Car
.
forward
;
}
else
if
(
soundLeftAvg
<
soundRightAvg
)
{
motorMode
=
Car
.
backward
;
}
if
(
counter
%
averageCount
==
0
)
{
threshold
=
(
motorMode
==
Car
.
stop
)
?
950
:
800
;
}
motorMode
=
(
soundLeftAvg
>
soundRightAvg
)
?
Car
.
forward
:
Car
.
backward
;
// Adjust angle based on difference between values.
if
(
motorMode
==
Car
.
forward
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment