Step 4: Controlling the Motors through Your Voice :
gMove Fasth gMove Slowh
This step shows you how you can control the motors on your robot through your voice.
1. Open the file created in step 3. (Step1.dlgxml)
2. Add a new dialogue.
Click on the New button.
A new dialogue Dialog 3 appears left to the Delete button.
3. Add Your Speech Sentences to the Dialogue.
Add two input sentences to this dialogue: "Move slow" and "Move fast" .
4. Add a variable
Depending on the input sentence, we want the motor to move slow or fast.
The speed of the motor is stored in a variable. Variables are managed in the variable box.
The functionality of the variable box is identical to the variable box in the Lego Mindstorm
software that can be reached through the "Edit / Define Variables" menu.
In the variable box, create a variable:
Change the name of the variable to Speed and its type to Number:
5. Associate variable values with Your Speech
If the user says 'move slow' you want the motor to turn at speed 50,
if the user says 'move fast' we want the motor to turn at speed 100.
To do so, you need to create variable assignments that assign these values to the variables.
Click on the sentence 'move fast' in the Dialog box, then create an equation in the equation box:
Then, set the name of the variable to 'Speed' and its value to 100:
Now, every time the user says 'move fast', the value of the variable Speed is set to 100.
Repeat the same steps to set the value for the variable Speed to 50 when the user says 'move slow'.
6. Add a motor command
In the command box, select the motor command:
After you selected the motor, the window shown below will appear.
Then now you can test the dialog by clicking a Robot Connection Command,
either With Cable or With Bluetooth.
When testing, you can observe the variable values in the variable list:
Next is the final step.
Step5
shows how to program for making your robot ask you back
and make a right action accordingly.
|