Activity #1
Figuring out NXJ
Your next assignment
Prior to this activity we will have discussed the VERY basics of
leJOS NXJ in class. Using what you learned about this,
- write a fairly simple class(es) which use the
Motor class to create a robot that traces out a square with sides of a
predetermined length. You can do this all in one class (from main) or by
creating a primary class which is called from main.
- When you get started you may assume that I want sides of length 50
centimeters. However, your code should be flexible enough that this
value can be modified
In addition to simply figuring out how to write, compile and upload your
code, there are two main challenges to this assignment:
- Figuring out how long to run the motors to move forward N centimeters
- Figuring out how long to run the motors to rotate 90 degrees (the corners
of the square)
I would like you to do this through simple old trial and error. For
example, run the robot forward for some predetermined amount of time (say 5000
ms) and measure how far the robot went. Repeat this several times to
calculate a rough ratio between time and distance.
Similarly, have the robot turn/spin for some predetermined amount of time and
calculate a comparable ratio between turn angle and time. Use these ratios
to help you solve this problem. It won't be perfect, but that is part of
this assignment.