See movement... start rolling!

The manifest is ready, so onto recreating the first step of the Lego TriBot example "start driving as soon as you see a movement" using two motors and the ultrasonic sensor.

I first want to try this out using the Visual Programming Language that comes with Robotics Studio but has its own IDE. Using basic activities and Robotics services available on your machine you can visually create a program similar to a dataflow diagram. I will use the generic services which enable you to use the program on a different robot just by changing the manifest that is attached to the diagram.

VPL program to react to generic sonar

The image above shows the first part of the program, starting with the Generic Sonar. The Distance Measurement supplied by the Generic Sonar is used as the value of the variable Distance, this is necessary for the next step, comparing the variable with 30. The documentation is currently not very clear about the units this measurement is in, but based on the reactions of NXT, I guess it is centimetres. If the distance is less than 30, power is set to the Generic Differential Drive, that's the generic service for a two motor configuration used with a left and a right wheel.

Pretty simple... but how do you get to this stage? How do you know about DistanceMeasurement and SetDrivePower?

First there is some basic IntelliSense in the VPL. For instance when you have connected the Generic Sonar to the Calculate activity and explore the properties for the Calculate activity you'll get a pop-up which tells your which data is supplied by the Generic Sonar. Moving over the list will give you some indication of the meaning of the data.

Properties And Intellisense

Second when you connect two activities you'll have to specify a connection and in most cases the connection data. For instance you specify the input for the Generic Differential Drive by connecting the Data activity to the Generic Differential Drive. When you make the connection (or later by right-clicking on the connection) you will be asked to specify the connection by choosing one of the operations available on the Generic Differential Drive. And if the operation takes any parameters you will be asked to specify the data connection by selecting the value supplied by the output activity (in this case the Data activity) to the parameter(s) of the input activity (in this case the Generic Differential Drive). Needless to say that by specifying the same value to the left wheel as to the right wheel the Bot will move straight ahead.

Connections And Data Connections

So most of the information is there when you build the diagram and as a third option there is a help file included (which in version 1.0 is included in Visual Studio, VPL only includes a basic help file) in which the generic services are documented.

By now we have a generic diagram using all generic services. Here's where the manifest comes in again... the manifest will specify on which Bot we want to run this program. The manifest is specified in the properties of the generic services, in this case the MyBot manifest is specified for the Generic Sonar and the Generic Differential Drive by selecting it from the list of available manifests.

Import Manifest

And now we're ready to run... let's go... My Bot needs to be connected by BlueTooth to the machine running Robotics Studio and then I can run the program from the machine. The response is a bit slow sometimes, but when I get close to the "eyes" of My Bot, it starts driving... first step completed.

 

Published Sat, Dec 30 2006 12:50 PM by Ilske Verburg
Filed under: