If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.
You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!
Page history
last edited
by PBworks16 years, 4 months ago
Getting the robot to move
Most simple wheeled robots have two independently driven wheels, one mounted each side of the robot. The power and direction of each motor can be independently varied. Robotocists call this a differential drive. Differential drives are often found on tanks, where instead of two indepdently driven wheels, there are two independently driven tracks.
For convenience, we shall assume a common configuration for the robot buggy.
For a LEGO RCX buggy:
Connect the motor on the left side of the robot as it faces forwards to output A on the RCX brick.
Connect the motor on the right side of the robot to output C.
Use the manifest LEGO.RCX.Vehicle.manifest.xml in your program.
For a LEGO NXT buggy (such as the Tribot):
Connect the motor on the left side of the robot as it faces forwards to output 1 on the NXT brick.
Connect the motor on the right side of the robot to output 2.
Use the manifest LEGO.NXT.Tribot.manifest.xml in your program.
(*** Need to check this config ***)
For a simulated buggy:
Use the manifest LEGO.NXT.Tribot.Simulation.manifest.xml in your program.
Exercise: Moving the robot forwards
How would you make the robot move forwards in a straight line for 1, 2 or 3 seconds and then stop?
What units of time does the wait action use?
What value does the SetDrivePower expect for full power?
Programming tips
Use a GenericDifferentialDrive service to represent the drive system of your robot.
You will need two copies of the same GenericDifferentialDrive object on your diagram; drag one from the Services toolbox, select it and then copy/paste to get the second copy. That way both blocks will represent the same physical drive.
If you click on either GenericDifferentialDrive block, you should see a "properties" panel for it in the sidebar at the right hand side of VPL window. If you change the name of the GenericDifferentialDrive (for example, to MyDiffDrive (no spaces in the name!) then you should see that both blocks get renamed in your program becuase they both refer to the same thing,
When you make the connection to SetDrivePower, make sure you set the data connection so that the value is sent to both LeftMotorPower and RightMotorPower.
To check data connections are correct, hover your mouse over the connection, or select it and check the Properties toolbox.
Configuration
You can configure the GenericDifferentialDrive using a manifest.
Try LEGO.RCX.Vehicle.manifest.xml for a LEGO RCX buggy
Try LEGO.NXT.Tribot.manifest.xml for a LEGO NXT Tribot or similar design.
Again, you will need several copies of the same GenericDifferentialDrive service on your diagram.
You will also need several Variable blocks. Note that one is sent a Set message to initialise the variable; the others receive Get messages to get the value of the variable.
Here we really are using the variable as a constant because we won't change its value once it is set. Some programming languages distinguish between constants and variables, but VPL doesn't -- it is up to you to decide whether to use a variable as a constant or a variable. Find out more about Constants and Variables.
Exercise: turning the robot
What happens if you power the left and right motors at different power levels?
What happens if you drive one motor and stop the other (power = 0)?
What happens if you drive one motor forward and the other backward?
Download this for a complete project (not configured): act 5 turn.zip
Discussion question
What differences are there between the behaviour of a simulated robot and the behaviour of a real robot?
Comments (0)
You don't have permission to comment on this page.