Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • L LEGO
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • René Søndergaard Nilsson
  • LEGO
  • Wiki
  • Lesson 8 Journal 2

Lesson 8 Journal 2 · Changes

Page history
move description of turning implementation. authored May 04, 2015 by Lasse Brøsted Pedersen's avatar Lasse Brøsted Pedersen
Hide whitespace changes
Inline Side-by-side
Lesson-8-Journal-2.markdown
View page @ e329bfc5
......@@ -114,34 +114,6 @@ switch (nextAction) {
```
The FSM is responsible for performing all turns on the track using an instance of the `Car` class provided by the Arbiter. The methods of the `Car` class is described below. By letting the FSM control the stopping mechanism we avoid having a third behavior that uses the light sensor or an additional color sensor to detect when the LEGO car is in the green end zone.
The 180 degree rotation is implemented using the `rotate(degree)` method of the `NXTRegulatedMotor` as follows:
```java
public void Rotate180()
{
leftMotor.setSpeed((int)(getMaxSpeed()*0.7));
rightMotor.setSpeed((int)(getMaxSpeed()*0.7));
leftMotor.rotate(370,true);
rightMotor.rotate(-370,true);
leftMotor.waitComplete();
rightMotor.waitComplete();
}
```
Each turn is hard coded by imposing a certain power to each motor in a fixed amount of time. The amount of power and the time interval is then adjusted according to manual inspection. Turning is different whether the robot is ascending or descending, and left and right turns are not implemented precisely symmetrical, because the left and right motors run slightly different. All turns follow the same pattern and is implemented as follows:
```java
public void TurnRightUp()
{
final int innerPower = 37;
final int outerPower = 100;
Forward(innerPower, outerPower);
Delay.msDelay(1350);
}
```
The hardware setup is identical to previously.
The PlateauPilot performs an action every time a plateau is reached. This is sensed using the gyroscope. In the code snippet below the run function of the PlateauPilot is shown. This function sets the boolean ´isPlatueaReached´, which triggers the Arbiter to perform the next action, as described by the state machine above.
......@@ -221,7 +193,37 @@ The final construction is shown in the following figure.
![Final constructionn](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson8/Images/FinalCar.JPG)
A link to the final code is also found in the references section.
### Implementing turns
The 180 degree rotation is implemented using the `rotate(degree)` method of the `NXTRegulatedMotor` as follows:
```java
public void Rotate180()
{
leftMotor.setSpeed((int)(getMaxSpeed()*0.7));
rightMotor.setSpeed((int)(getMaxSpeed()*0.7));
leftMotor.rotate(370,true);
rightMotor.rotate(-370,true);
leftMotor.waitComplete();
rightMotor.waitComplete();
}
```
Each turn is hard coded by imposing a certain power to each motor in a fixed amount of time. The amount of power and the time interval is then adjusted according to manual inspection. Turning is different whether the robot is ascending or descending, and left and right turns are not implemented precisely symmetrical, because the left and right motors run slightly different. All turns follow the same pattern and is implemented as follows:
```java
public void TurnRightUp()
{
final int innerPower = 37;
final int outerPower = 100;
Forward(innerPower, outerPower);
Delay.msDelay(1350);
}
```
A link to the final code is also found in the references section.
## Conclusion
......
Clone repository
  • Lesson 1
  • Lesson 2
  • Lesson 3
  • Lesson 4
  • Lesson 5
  • Lesson 6
  • Lesson 7
  • Lesson 8 Journal 2
  • Lesson 8
  • Lesson 9
  • Lesson10
  • Lesson11
  • Home