Doing this project with voice recognition only

Doing this project strictly with voice recognition I ran into a problem I want the forward button to keep the rover moving forward until I tell it to stop. Since I have no use of my arms I want to start automating it. I'm thinking it has to do with how many cycles per click

piborg's picture

Without knowing how your voice recognition works it is a little tricky to help with this one.
Hopefully I can point you in the right direction :)

In our diddyWeb.py script we have two variations on how the controls work.
Using 192.168.0.198 as an example IP address for the robot:

  1. http://192.168.0.198 - Provides buttons which have to be pressed to change speed.
    This means clicking Forward will keep going along until Stop is clicked.
  2. http://192.168.0.198/hold - Provides buttons which have to be held to keep going.
    This does not work on all devices and may behave strangely with voice controls.

In this case the difference between the two in code is:

  1. Sends a single command when the button is pressed to perform the movement
  2. Sends one command when the button is pressed down to perform the movement, a second is sent when the button is released to stop the movement

The code in diddyWeb.py should only change speeds when:

  • A command is sent from the device to make a change
  • No communication has happened for over a second

The script communicates regularly to grab the camera image, so "no communication" should only happen when the device is not trying to control the robot any more.

I am using windows speech recognition. So when I open up the web UI in my browser I just say " forward" or any other button and the browser button gets clicked. I've tried changing the onmouseup from off() to on() that didn't work since I'm not using a mouse. I've also tried onmouseover on() so maybe if I hover over it, it would stay on, still the forward button stops after a few revolutions or seconds. I want it so when I say the command like "forward" it would go forward until I say " left" " right" or any other button command, I probably need a while loop . How can I change the time the motors go on per click?

piborg's picture

Which version of the controls are you using:

  1. The standard controls: http://192.168.0.198
  2. The alternative controls: http://192.168.0.198/hold

I've tried both. Also tried to look at the pico reverse python file, but I'm stuck.

piborg's picture

I think we should stick with the http://192.168.0.198 version, this only sends single command when each button is pressed.

I suspect your problem is the watchdog timer in the script deciding your browser has disconnected.
If you comment out the following lines in diddyWeb.py it should stop the watchdog running:

print 'Setup the watchdog'
watchdog = Watchdog()

and

watchdog.terminated = True

To comment a line out add a # symbol to the start of the line.

I tried commenting out what you told me but I got the following error(uploaded below):
Watchdog not defined! So I tried leaving watchdog= watchdog() alone and comment out the others you told me. Still not working.

What is watchdog and where is it defined? I've also been looking at the other examples like Diddy sequence.py code and there's a part there I took a snippet of the section I uploaded down there. It's under #movement settings, "timeForward1m=5.7" #number of seconds to move. Is there a way to incorporate this code to webui.

Another idea I got was to experiment with under the "httptext+= Drive(1,1)", what is drive and where is it defined?

Images: 
piborg's picture

My mistake, there are a couple more lines which need to be commented out.

The full list is:

        watchdog.event.set()
print 'Setup the watchdog'
watchdog = Watchdog()
watchdog.terminated = True
watchdog.join()

All the watchdog does is check if the browser is still talking to the script.
If it has not seen any messages from the browser for more than 1 second it stops the DiddyBorg moving.
This is why I suspect it may be the cause of your problem.

Thank you so much. Works like a charm. Next I think I wanna make it to avoid obstacles semiautomatic, maybe work with opencv with an extra camera for stereo vision or ultrasonic sensors.

How would I a dd buttons that would control the speed, just by calling out the speed like 100% or 75%. Since I'm only doing this by voice the speed bar at the bottom is kind of complicated to operate by voice.

piborg's picture

What you will need to do is add a button which changes the position of the slider.

For example this is the HTML code for a button which sets the slider to 50% speed:

<button onclick="speed.value=50" style="width:200px;height:100px;"><b>50%</b></button>

You will need to add this to the httpText values in the elif getPath == '/': section.
This is the finished line for a 50% speed button:

            httpText += '<button onclick="speed.value=50" style="width:200px;height:100px;"><b>50%</b></button>\n'

The speed set is the =50 part, the values are from 0 to 100.
The text on the button is the 50% part.
You should be able to add as many buttons as you like :)

The new speed will be used on the next direction button clicked.

Hi, using the above modifications to the Web gui script i.e. adding an extra speed/direction control button. How could I use this to control the speed of the motors on a second picoborg reverse connected by daisy chain.
Thanks.

piborg's picture

Are you trying to control the two boards independently, or do they operate as a pair?

Hi thanks for the reply. Once again I'm trying to get my ROV working. The two boards would operate independently of each other. board 1would move the ROV forward and back whilst board 2 would allow the ROV to ascend and descend.
I like the web gui as it would allow me access to the ROV via an CAT5 cable tether and streams video from the raspberry pi.
Yes there are other methods and product out there but I'm trying to soley use a raspberry pi and piborg products.
I've reposted this as a new post so please ignore that one.

piborg's picture

This will probably need a few changes to get the behaviour you want to work.

First you will want to duplicate the section that starts:

elif getPath.startswith('/set/'):

and give it a new name, such as set2. This should be made to set the power levels on the second board.

Second you will want another slider to select the speed for the board. Look for these lines:

httpText += '<input id="speed" type="range" min="0" max="100" value="100" style="width:600px" />\n'

and duplicate them with an id of speed2 instead.

Third you will want a second drive function. Look for these sections:

            httpText += 'function Drive(left, right) {\n'
            httpText += ' var iframe = document.getElementById("setDrive");\n'
            httpText += ' var slider = document.getElementById("speed");\n'
            httpText += ' left *= speed.value / 100.0;'
            httpText += ' right *= speed.value / 100.0;'
            httpText += ' iframe.src = "/set/" + left + "/" + right;\n'
            httpText += '}\n'

Make a copy of each with the following changes:

  1. Change Drive to Drive2
  2. Change speed to speed2
  3. Change set to set2

Finally when you add your new buttons call the new Drive2 function just like the existing ones do with Drive. For example:

httpText += '<button onclick="Drive2(-1,0)" style="width:200px;height:100px;"><b>Descend</b></button>\n'

This should allow you to control both the speed and operation of the third axis separately from the first board. You should also be able to create speed buttons in the same way as mentioned earlier in this thread but setting speed2 instead.

.

Hi Adam, (or anyone else that can help)
This is exactly what i am trying to do, i am fairly new to all this raspberry pi stuff but loving everything so far,
basically i work with children with additional needs in a school and i am trying to create a buggy (like the diddy borg) to run on voice commands so the children just need to speak to get it to move etc. so far due to my lack of knowlage i am stuck.
please could you tell me (i am using a diddy borg thats all built up and runs perect using the diddyjoy.py sode using a rock candy controller) so basically how do i get that setup to run on voice commands.
you may need to explain it in a very basic way for me as i am still learning lol
many thanks
Tim.

Subscribe to Comments for &quot;Doing this project with voice recognition only&quot;