We found this model of Laurens on the web:
http://ricquin.net/lego/laurens/
We got interested because of the use of the special Lego piece which we already used "in concept" for a gear box, see blog : gearbox of Jos. Here it is used to turn the model, the foot being attached to the inner circle, the motor to turn it, to the black outer half of this lego piece.
The Hopper is complicated and simple at the same time, the good thing of building models as examples is that you see how others use the Lego pieces to construct, there is always something to learn. For instance the use of the double black triangles.Also we see Pythagoras is still working in a small triangle: square 8 + square 6 = square 10: the famous 3:4:5 trangle!
Ingenious is the way to combine the two motors to get the Hopper movement.
The use of the sensor is reduced: the ultrasonic sensor measures the distance and the Hopper turns when the distance is too small.
This turning is really something nice: first the thing turns on the middle foot, then it lift itself half a cycle, and the foot is turned, then another half cycle and the Hopper continues its way.
With the building instructions comes the NXT-G or firmware program.
It is really a beauty programm: where the FIRMWARE can be very concise:

We redid this program in Lejos-Java, it become somewhat longer.
Think of the synchronisation: adding the true in the Motor.A.rotate(360, true);
Here is the Lejos JAVA version of this prog: (somehow it looks more complicated, it isn't of course...)
| //HOPPER JAVA import lejos.nxt.Button; import lejos.nxt.LCD; import lejos.nxt.Motor; import lejos.nxt.SensorPort; import lejos.nxt.Sound; import lejos.nxt.UltrasonicSensor; /** * leJOS version of the HOPPER program by Laurens * * * @author Five March * */ public class walker { public static void main(String[] args ) { Motor.A.smoothAcceleration(true); Motor.B.smoothAcceleration(true); Motor.C.smoothAcceleration(true); UltrasonicSensor sonar = new UltrasonicSensor(SensorPort.S1); Motor.A.setSpeed(200); Motor.B.setSpeed(200); Motor.C.setSpeed(200); //-------------------------------------------------------- Sound.beep();//we are starting LCD.clear(); while(!Button.ESCAPE.isPressed() ) { LCD.drawInt(sonar.getDistance(), 0, 2);//to test draw the distance on the LCD screen LCD.refresh(); if (sonar.getDistance() > 25) { Motor.A.rotate(360, true); Motor.B.rotate(-360, true); pause(1500); } else{ Sound.beep();//encounter an obstacle int rotateAngle = 0; while ( sonar.getDistance() <50)> |
Because of the middle foot turning around, we thought of adding the "radar" possibility, making a map of surrounding objects. We already did this using the fantom lib and a very simple model.
But then we have to shift the software, choose a lib, so fantom lib, why not, this is JAVA too.
Now we'll do the commanding from the PC.
We add a few other sensors, the compass sensor, to get a bearing when making the map, the time, and the sound.
The sound will be used to get from the "Hopper"-mode into the mapping - mode.
The sensors will be mounted at the side of the model, the inside, because at the start, the thing had a tendency to fall down....( i forgot one tiny bit of lego, :-)
This is the result (output from Eclipse, beautified in Photoshop...)
The red line gives the "hopps", then the hopper encounters an object, and starts a round of getting distances, then it decides to take a bearing without an object (white line: no object within range) and it continues till it senses another something near.The process of scouting a room is very slow. The sensors have to be not moving while reading a value.
Also you can see the compass is not very horizontal, because the lines around the "radaring" point should be regularly rotating around this point.
At the moment the nxt can avoid obstacles, but the track it follows is still random. The next step will be an "intelligent" way to search a room and make a map of the objects in it.
to be continued....
0 comments:
Post a Comment