Simple Pythonscript

I make this script but it does not sleep and the wheels only goes forward not backward.
Have someboy an idea ?

from gopigo import *
import time
fwd ()
time.sleep (2)
bwd ()
print volt ()
stop ()

Hey,
Can you try out the basic_test_all.py example here https://github.com/DexterInd/GoPiGo/blob/master/Software/Python/basic_test_all.py and give it “w”,“s”,“d”,“a” commands and see if it works properly for you.

-Karan

He karan,
The basic_test_all.py work by me properly.

Hey,
Were you able to take pointers from the basic_teat_all and to get your script working.

-Karan

He karan,
karan if you watch this video you can see that time.sleep is not working properly.
http://pythonprogramming.net/programming-autonomous-robot-gopigo-tutorial/
Are there no technics at Dexter inudstries to solve the problem wit time.sleep.
If you open a terminal and exute sudo python and then fwd() and then time.sleep(2) the weels keep spinning because time.sleep won’t listen. And what do yo mean by taking pointers from the basic_test_all.

Thanks

Hey,
Just saw the video. It does look awesome and it’s great to see that GoPiGo working well.

So there are a few pointers that you can use with the GoPiGo, the GoPiGo does not stop after you the time.sleep(2) is because the GoPiGo expects a stop() command to stop. If you just give the sleep and don’t call any function after it, the GoPiGo won’t stop.

What we have with the software right now is encoder_targeting, where you tell how many times you want the wheels to rotate, and the GoPiGo stops after that many rotations. Here is the test code for it: https://github.com/DexterInd/GoPiGo/blob/master/Software/Python/other_scripts/encoder_tgt_complete_test.py .

Also, I don’t remember exactly, but the ultrasonic sensor might be returning the distance in mm and it starts giving out bad values if the obstacle is very far away. It might easy to test out what distance it gives and then tune the distance you want to use.
Do let us know if this is what you were looking for and if we could help you with anything else.

Feel free to suggest improvements to the functionality in or features that we can add for the GoPiGo.

-Karan

He Karan,
I am glad that the examplescript works fine with time.sleep. But do you have also examples with “import time” in it.
I have also another question about the ultrasonic sensor i saw on the internet the hc-sr04 sensor
But it says it is for Arduino can i use that to for the GoPiGo. here is the link:
http://www.miniinthebox.com/nl/ultrasone-module-hc-sr04-afstand-meetomvormer-sensor-voor-arduino-201211270080054_p478889.html

thanks

Hey,
Almost every GoPiGo example does use time.sleep in some way. You can check out the projects here to have a look: https://github.com/DexterInd/GoPiGo/tree/master/Software/Python/Examples.

The ultrasonic sensor that we use is made by Seeedstudio and from the looks of it, it does look like a variant of HC-SR04: http://www.seeedstudio.com/depot/Grove-Ultrasonic-Ranger-p-960.html. There is one big difference though, the sensor that we sell, has only 1 pin for input and output. When we were selecting the Ultrasonic sensors, we found that we got the best performance from the Seeed sensors and that’s why we stuck to them. The sensor that you have linked might work but you might face problems with bad data too.

-Karan