Comments on: Programming a Raspberry Pi Robot Using Python and OpenCV http://blog.dawnrobotics.co.uk/2014/06/programming-raspberry-pi-robot-using-python-opencv/ Tutorials and updates from Dawn Robotics Tue, 30 Dec 2014 22:58:08 +0000 hourly 1 http://wordpress.org/?v=3.7.5 By: james martel http://blog.dawnrobotics.co.uk/2014/06/programming-raspberry-pi-robot-using-python-opencv/#comment-495 Sat, 27 Sep 2014 01:14:24 +0000 http://blog.dawnrobotics.co.uk/?p=554#comment-495 Hi
I have managed to get a few different types of sensors to report values back to my pi’s usi ng the latest SD image on both REVB and REVB+ 4 Wheeled drive robots. I have followed alan’s advice to tie the trig and echo pins on my 4 pin ultrasonic sensor together and got a reading that responded to my moving hand. I am also using some i2c sensors but I am using a linksprite raspberrypi hub/ interface with arduino IDE code to read them….not proficient or unable to find python example code. Basically now I know all my sensors work on this robot…but need to write up the sensor config.py files for each to get them to display via websockets. It displays temp…light or dark…lines…motion…compass…3 axis accelerometer…. now to get sound or speech recognition….HAL9000 here I come.

]]>
By: Mick F http://blog.dawnrobotics.co.uk/2014/06/programming-raspberry-pi-robot-using-python-opencv/#comment-464 Thu, 21 Aug 2014 23:57:26 +0000 http://blog.dawnrobotics.co.uk/?p=554#comment-464 Alan,
Amazing… All is working. (using IDLE, the command line failed)
It was the following line that confused me, (help=”The ip address of the robot”)
parser.add_argument( “hostname”, default=”localhost”, nargs=’?', help=”The ip address of the robot” )
I took it too literal and thought this was the ACTUAL IP address!!
I tried the battery_test.py to check and after changing the IP address, perfect.

Python 2.7 is actually IDLE for windows, confusing with the Raspberry pi have the same program name.

I Must remember not to try and browse the Internet when connected to the PI robot!!

I will now be setting up my grandsons PC for accessing the pi_robot :)

Really excellent work.
Mick

]]>
By: Alan http://blog.dawnrobotics.co.uk/2014/06/programming-raspberry-pi-robot-using-python-opencv/#comment-463 Thu, 21 Aug 2014 12:48:19 +0000 http://blog.dawnrobotics.co.uk/?p=554#comment-463 Actually, thinking about it, on windows, the thing you may need to type at the command line could be

c:\Python27\python.exe motor_test.py 192.168.42.1

As python may not have been added to your PATH environment variable.

Sorry, I’ve got a bit tied into Linux/Ubuntu over the last 5 years. :D

Regards

Alan

]]>
By: Alan http://blog.dawnrobotics.co.uk/2014/06/programming-raspberry-pi-robot-using-python-opencv/#comment-462 Thu, 21 Aug 2014 12:43:53 +0000 http://blog.dawnrobotics.co.uk/?p=554#comment-462 Hi Mick,

You would need to restore the line to the original

parser.add_argument( "hostname", default="localhost", nargs='?', help="The ip address of the robot" )

Basically this is configuring a command line parser for the script so that it has an argument called hostname that takes the network address of the robot. The default value of localhost means that it will try to attach to a version of the robot web server running on the same computer (this is for when scripts are running on the Pi robot).

I’ve not had a huge amount of experience with running IDLE, but the way I’d run this to begin with is to open up a command line prompt, navigate to the directory containing motor_test.py and then run

python motor_test.py 192.168.42.1

Where 192.168.42.1 is the IP address of the robot (this may be different if you’ve plugged it into ethernet)

Once you’ve confirmed that that works, then it may be possible to configure IDLE so that it passes command line arguments to the program. Alternatively, to set the default network address to be the robot’s address you would change that line to be

parser.add_argument( "hostname", default="192.168.42.1", nargs='?', help="The ip address of the robot" )

Hope that helps.

Regards

Alan

]]>
By: Mick F http://blog.dawnrobotics.co.uk/2014/06/programming-raspberry-pi-robot-using-python-opencv/#comment-461 Thu, 21 Aug 2014 11:07:09 +0000 http://blog.dawnrobotics.co.uk/?p=554#comment-461 Hi, I think I have installed correctly to windows 7 laptop… (Your instructions were quite good on a fairly “messy” installation)

I have connected my laptop from my normal router to the Pi_Mini_Robot.
I am trying to get a simple example program that you wrote will or should expect it to work the way I have done it.
i.e. after opening “IDLE Python GUI” and opening the “motor_test.py”, then amending the line to:
parser.add_argument( “hostname”, default=”Pi_Mini_Robot”, nargs=’?', help=”192.168.41.1″ )
(I have tried a few other permutations!!)
Pressing F5 to run the program/ code.
I get the following response in the “Python Shell”

******* message shell response ***********
Connecting to ws://Pi_Mini_Robot:80/robot_control/websocket

Traceback (most recent call last):
File “C:\opencv231\DawnRobotics-py_websockets_bot-2cf9c47ea171\examples\motor_test.py”, line 20, in
bot = py_websockets_bot.WebsocketsBot( args.hostname )
File “C:\Python27\py_websockets_bot\__init__.py”, line 244, in __init__
self._websocket = websocket.create_connection( url )
File “C:\Python27\py_websockets_bot\websocket\__init__.py”, line 214, in create_connection
websock.connect(url, **options)
File “C:\Python27\py_websockets_bot\websocket\__init__.py”, line 464, in connect
self.sock.connect((hostname, port))
File “C:\Python27\lib\socket.py”, line 224, in meth
return getattr(self._sock,name)(*args)
gaierror: [Errno 11004] getaddrinfo failed
>>>
***************************************************

From this, can you tell me what could be wrong, I assume it would be quite a simple oversight/ error?

Hopefully, this may help others in the same (how the hell do I get started) position! :)
Thanks
Mick

Incidentally, I am using a BEC from hobbyKing (I fly model aircraft) and It has a low voltage beeper on it, therefore get an indication when the 5v drops too low.

]]>
By: Alan http://blog.dawnrobotics.co.uk/2014/06/programming-raspberry-pi-robot-using-python-opencv/#comment-374 Fri, 13 Jun 2014 22:26:57 +0000 http://blog.dawnrobotics.co.uk/?p=554#comment-374 Hi Marcel,

Sorry, I think I wasn’t clear enough in the raspberry_pi_camera_streamer instructions. It sounds like the camera streamer is working. It’s just that http://RASPBERRY_PI_IP_ADDRESS:8080/?action=stream won’t work in Chrome, in fact I’ve only tested it properly in Firefox…

Something like the following html file will hopefully work better in more browsers



Hope that helps. If there are problems, then you can download our SD card image and use it in a Pi with a camera, even when not attached to a robot. This should hopefully give a working example for a web page at least.

Regards

Alan

]]>
By: Marcel http://blog.dawnrobotics.co.uk/2014/06/programming-raspberry-pi-robot-using-python-opencv/#comment-373 Fri, 13 Jun 2014 20:28:43 +0000 http://blog.dawnrobotics.co.uk/?p=554#comment-373 Very interesting!
I tried to follow along but got stuck on the streamer. Compiling went fine but running raspberry_pi_camera_streamer didn’t work. I see the camera’s light come on and I see this output:
Image encoder buffer num 3, buffer size 81920
Image encoder buffer num 3, buffer size 81920

but nothing loads in the browser.
The pi is full updated (incl a regular dpi-update).

Any ideas?

PS maybe it’s a good idea to enable a bug tracker on bitbucket?

]]>
By: Benjamin http://blog.dawnrobotics.co.uk/2014/06/programming-raspberry-pi-robot-using-python-opencv/#comment-366 Thu, 12 Jun 2014 12:03:42 +0000 http://blog.dawnrobotics.co.uk/?p=554#comment-366 So awesome, can’t wait to implement it :) Great job!

]]>