Browser Controlled Robot Problems

I just got my GoPiGo robot and was very excited to set it up but I am totally stuck on the Web Browser Robot.

I’m using the Dexter image I downloaded last night and built the pi with that image this morning.

The test program works, the mouse driving program works…

I can not get the streaming video to work. I get to a point where it says: “Starting Web Server” and that looks good but when I try and get into it from a computer or mobile device either with raspberrypi.local/ or its actual IP address it just says “page not found”.

I"m running on a local wifi intranet and have had no other wifi problems or internet connectivity issues.

I have read everything I can and saw 2 similar posts with similar issues…one was resolved with no explanation.

Can anyone help me get this to work? I’m in a hurry for this project development to work…building an OpenCV project with it.

Thanks

Mark

It seems Midori crashes when I try and get into the Pi…sometimes…and it takes a while before the server terminates and I get this error log:

$ sudo python robot_web_server.py
sockjs.tornado will use json module
/www
Starting web server…
Uncaught exception GET / (192.168.1.5)
HTTPServerRequest(protocol=‘http’, host=‘192.168.1.16’, method=‘GET’, uri=’/’, version=‘HTTP/1.1’, remote_ip=‘192.168.1.5’, headers={‘Connection’: ‘keep-alive’, ‘Accept-Language’: ‘en-US,en;q=0.8’, ‘Accept-Encoding’: ‘gzip, deflate, sdch’, ‘Cache-Control’: ‘max-age=0’, ‘Host’: ‘192.168.1.16’, ‘Accept’: ‘text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8’, ‘User-Agent’: ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36’})
Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 1332, in _execute
result = method(self.path_args, **self.path_kwargs)
File “robot_web_server.py”, line 163, in get
self.render( webPath + “/index.html” )
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 665, in render
html = self.render_string(template_name, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 769, in render_string
t = loader.load(template_name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 343, in load
self.templates[name] = self._create_template(name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 370, in _create_template
with open(path, “rb”) as f:
IOError: [Errno 2] No such file or directory: ‘/www/index.html’
500 GET / (192.168.1.5) 27.25ms
404 GET /favicon.ico (192.168.1.5) 4.40ms
404 GET /favicon.ico (192.168.1.5) 4.23ms
Uncaught exception GET / (192.168.1.5)
HTTPServerRequest(protocol=‘http’, host=‘192.168.1.16’, method=‘GET’, uri=’/’, version=‘HTTP/1.1’, remote_ip=‘192.168.1.5’, headers={‘Connection’: ‘keep-alive’, ‘Accept-Language’: ‘en-US,en;q=0.8’, ‘Accept-Encoding’: ‘gzip, deflate, sdch’, ‘Cache-Control’: ‘max-age=0’, ‘Host’: ‘192.168.1.16’, ‘Accept’: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,
/*;q=0.8’, ‘User-Agent’: ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36’})
Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 1332, in _execute
result = method(*self.path_args, **self.path_kwargs)
File “robot_web_server.py”, line 163, in get
self.render( webPath + “/index.html” )
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 665, in render
html = self.render_string(template_name, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 769, in render_string
t = loader.load(template_name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 343, in load
self.templates[name] = self._create_template(name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 370, in _create_template
with open(path, “rb”) as f:
IOError: [Errno 2] No such file or directory: '/www/index.html’
500 GET / (192.168.1.5) 7.65ms

Please Help!

I thought I might add that I tested the camera module with raspistill -o test.jpg and it worked fine. Also, while the camera was active the red light went on. I also did OpenCV work with the camera on a previous build and the camera worked fine.

But…I expected the red light to turn on once “starting web server” is displayed but in no case of all the things I tried did the light come on.

I wondered if I should get any activity messages after “starting web server” like I saw in some other posts.

Following something I saw in another post, I decided to run the web serer setup .py file (which I know takes a while since I did it on a non Dexter previous build) over again and now instead of the webserver just hanging and seeming to do nothing, I got a page of errors similar to that post…where he said making progress. Then I rebooted and now it goes back to just hanging at starting web server with no apparent way to get into the raspberry pi.

I have tried running the browser robot code through sudo python as well as sudo ./browser…robot… and I never seem to get a web browser started or the camera light to turn on.

I tested other programs like the mouse driving, test all, etc and everything else seems to be working perfect.

Please help!!!

Mark

Hey Mark,
I’ll try out the project on a fresh SD card just to make sure that it works and would let you know how it goes for me.

-Karan

Karen,
I will do so, but that is EXACTLLY what I did. I even ERASED the sd-card first. Formatted it, imaged it with the Dexter image, expanded the partition size to fill the card with Raspi config…then I went and tried it and I had the same errors I had when I was using the non Dexter and older build that I had OpenCV running on.

For all the data I gave you, I did everything in order from scratch and still can not get video streaming to work.

I’m not sure why you expect different results the second time since I’m not changing anything…but if we need a fresh build to start debugging from I understand that.

I will do a totally clean dexter install tomorrow and let you know. If it doesn’t work I’ll let you know.

Mark

Karen,…oops…I aciddentally read that as you wanted me to try…which I am going to anyway…but I see that you said you would try.

One thing I forgot to mention…I’m using a Pi2 if that makes any difference…

I will use the Dexter image, Firmware V13 on the GoPiGo board (I think that is pre-loaded with the current Dexter image).

Should I do a sudo apt-get update and sudo apt-get upgrade before I start…I’m thinking of just using your image as is.

I will try and load the minimum libraries or scripts to make this work with your build and also let you know.

Just to be clear…I had been able to have my pi stream video over X11 ssh while running openCV on a non dexter build and it worked fine. I have never had any problems getting into or out of the pi except I believe that for some reason the video streaming server is just not starting…also evidenced by the red light not turning on on the camera after “starting web server” is displayed.

Also questions:

  1. Should there be any other dialog in the launch window other than text stopping at “starting web server”, or should there be some status messages as in other peoples posts?

  2. What is the root password for your image? I see I have a special option to run a root shell, but I simply just don’t like not having the root password for my machine…wondering if you keep that locked away for some reason or if you would let us know what it is. I don’t need it for anything in particular right now thought.

  3. With the Dexter image, do we have to run any of the setup.py files, or setup.sh scripts or are those only if you cloned the library without the Dexter image?

I will work on a new install and am anxiously awaiting any news on if you have similar problems…I’m honestly wondering if this could be some kind of a Pi vs Pi2 thing but don’t have the technical depth on the exact differences when it comes to video streaming.

Thanks in advance Karen! I’m hoping you can get this done today!

Mark

Todays build log.

Here is what I did today. Pretty much exactly the same behavior. I highly doubt it is a network issue since I believe the red light should go on on the camera module when streaming and it doesn’t turn on.

I also went to run the video streaming example and that didn’t work either…same problem and no red light.

Here is today’s build and error log:

Download Dexter V 5.2 disk image
Image this to SD card
Boot RPi
Run sudo raspi-config
Expand File size to match card (32gig)
Reboot
Go strait /Desktop/GoPiGo/Software/Python/Examples/Browser controlled robot
Run it with sudo python robot_web_browser.py

After “Starting Web Browser” one wheel on the robot was continuously going.

Kill process.

sudo apt-get update
sudo apt-get upgrade

Reboot

Run Dexter Software Updater.

Reboot

Run basic_test_all and check firmware version (it is V13)

All motors work properly.

test camera module with raspistill -o testfile.jpg
Light turns on…picture taken.

Open .jpg with picture viewr.
Pic looks good. Camera module works.

Rerun robot_web_server.py

Same behavior same problems…gets to the point where the dialog states "webserver started"
Then no additional information.

I tried to get into it from several avenues using http://raspberrypi.local/ as well as http://192.168.1.16/ which is its address on my local intranet.

After trying to get into it for a while it eventuall it crashes and I get this error log (this usually happens after trying to start up another Midori session after I have tried to access the web server.

The error log comes after Web server started here it is in this case:

pi@raspberrypi ~/Desktop/GoPiGo/Software/Python/Examples/Browser Streaming Robot $ sudo python robot_web_server.py
sockjs.tornado will use json module
/www
Starting web server…
Uncaught exception GET / (192.168.1.16)
HTTPServerRequest(protocol=‘http’, host=‘raspberrypi.local’, method=‘GET’, uri=’/’, version=‘HTTP/1.1’, remote_ip=‘192.168.1.16’, headers={‘Connection’: ‘Keep-Alive’, ‘Accept-Language’: ‘en-gb;q=0.750’, ‘Accept-Encoding’: ‘gzip, deflate’, ‘Host’: ‘raspberrypi.local’, ‘Accept’: ‘text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8’, ‘User-Agent’: ‘Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-gb) AppleWebKit/535+ (KHTML, like Gecko) Version/5.0 Safari/535.22+ Midori/0.4’})
Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 1332, in _execute
result = method(self.path_args, **self.path_kwargs)
File “robot_web_server.py”, line 163, in get
self.render( webPath + “/index.html” )
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 665, in render
html = self.render_string(template_name, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 769, in render_string
t = loader.load(template_name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 343, in load
self.templates[name] = self._create_template(name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 370, in _create_template
with open(path, “rb”) as f:
IOError: [Errno 2] No such file or directory: ‘/www/index.html’
500 GET / (192.168.1.16) 21.70ms
404 GET /favicon.ico (192.168.1.16) 9.08ms
404 GET /favicon.ico (192.168.1.16) 3.39ms
404 GET /favicon.ico (192.168.1.16) 4.03ms
Uncaught exception GET / (192.168.1.16)
HTTPServerRequest(protocol=‘http’, host=‘raspberrypi.local’, method=‘GET’, uri=’/’, version=‘HTTP/1.1’, remote_ip=‘192.168.1.16’, headers={‘Connection’: ‘Keep-Alive’, ‘Accept-Language’: ‘en-gb;q=0.750’, ‘Accept-Encoding’: ‘gzip, deflate’, ‘Host’: ‘raspberrypi.local’, ‘Accept’: 'text/html,application/xhtml+xml,application/xml;q=0.9,
/;q=0.8’, ‘User-Agent’: ‘Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-gb) AppleWebKit/535+ (KHTML, like Gecko) Version/5.0 Safari/535.22+ Midori/0.4’})
Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 1332, in _execute
result = method(self.path_args, **self.path_kwargs)
File “robot_web_server.py”, line 163, in get
self.render( webPath + “/index.html” )
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 665, in render
html = self.render_string(template_name, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 769, in render_string
t = loader.load(template_name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 343, in load
self.templates[name] = self._create_template(name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 370, in _create_template
with open(path, “rb”) as f:
IOError: [Errno 2] No such file or directory: ‘/www/index.html’
500 GET / (192.168.1.16) 5.46ms
404 GET /favicon.ico (192.168.1.16) 3.97ms
404 GET /favicon.ico (192.168.1.16) 3.61ms
Uncaught exception GET / (192.168.1.16)
HTTPServerRequest(protocol=‘http’, host=‘192.168.1.16’, method=‘GET’, uri=’/’, version=‘HTTP/1.1’, remote_ip=‘192.168.1.16’, headers={‘Connection’: ‘Keep-Alive’, ‘Accept-Language’: ‘en-gb;q=0.750’, ‘Accept-Encoding’: ‘gzip, deflate’, ‘Host’: ‘192.168.1.16’, ‘Accept’: 'text/html,application/xhtml+xml,application/xml;q=0.9,
/
;q=0.8’, ‘User-Agent’: ‘Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-gb) AppleWebKit/535+ (KHTML, like Gecko) Version/5.0 Safari/535.22+ Midori/0.4’})
Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 1332, in _execute
result = method(*self.path_args, **self.path_kwargs)
File “robot_web_server.py”, line 163, in get
self.render( webPath + “/index.html” )
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 665, in render
html = self.render_string(template_name, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/tornado/web.py”, line 769, in render_string
t = loader.load(template_name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 343, in load
self.templates[name] = self._create_template(name)
File “/usr/local/lib/python2.7/dist-packages/tornado/template.py”, line 370, in _create_template
with open(path, “rb”) as f:
IOError: [Errno 2] No such file or directory: '/www/index.html’
500 GET / (192.168.1.16) 8.77ms
404 GET /favicon.ico (192.168.1.16) 9.09ms
404 GET /favicon.ico (192.168.1.16) 3.21ms
404 GET /favicon.ico (192.168.1.16) 3.03ms

I can’t see I’m doing anything wrong. I’ve had the same behavior on 2 differnet networks both home and work. I even tried to get into the server from running midori on the pi itself and I get a 500 internal server error.

Any help?

Thanks Karen…looking forward to what you might have to say.

Mark

Additional steps:

Logged into root shell
ran web streaming setup .sh script as root
rebooted
tried to run again
same problems
no red light on cam after starting server

Please help

Mark

PS…I read some stuff that the latest update of Rasperian may break some functionality and suggested to go into raspi-config advanced settings and enable SPI, I2C, and some other stuff which I also did.

Mark

Mark, to answer a few of your questions above, before they get lost here:

1) Should there be any other dialog in the launch window other than text stopping at “starting web server”, or should there be some status messages as in other peoples posts?

I have to check on this one. I too am going to get involved now and try this out. I’ll work with a Pi2 just to make sure your theory about the Pi2 is right.

2) What is the root password for your image? I see I have a special option to run a root shell, but I simply just don’t like not having the root password for my machine…wondering if you keep that locked away for some reason or if you would let us know what it is. I don’t need it for anything in particular right now thought.

Root password is “raspberry”.

3) With the Dexter image, do we have to run any of the setup.py files, or setup.sh scripts or are those only if you cloned the library without the Dexter image?

No, you should not have to do any setup. I personally made a mistake in the BrickPi area on this build, but that shouldn’t be causing any problems for you with the GoPiGo.

So, I think I cracked the problem. I too started with a new image, connected internet and ran into the same problem. I think it was the exact same error.

The problem lay in the file “robot_web_server.py” that was referencing a folder that didn’t exist “/www” which was referring to the folder www in root. I added an extra line that redirected to the proper location of /wwww (which is under ~/Desktop/GoPiGo/Software/Python/Examples/Browser Streaming Robot/www".

I think this should work. The best way to try it out is, connected to the internet, run the following commands:

`
cd ~/Desktop/GoPiGo/
sudo git reset – hard origin/master
git pull origin

Then change directories and run the program “sudo python robot_web_server.py”.

Can you try this and let us know how it goes?

Karen,

I absolutely will try this and get back to you asap.
Thanks for the hard work!

PS…I “kind” of got it to work. I did see that www directory but there was one the script created there with an index.html in it owned by root but I think you were right that a different part might have been pointing somewhere else.

What I did that seemed to make a difference was do a sudo rpi-update to update the PI2’s firmware and then I was able to get into it from chrome. from IE I got the joystick but no video stream.

I will try out your fixes and get back to you.

Mark

Quick update…I tried everything from scratch with a totally clean build but this time I added the sudo rpi-update and that did fix the camera streaming issue as I don’t want to try your fix yet unless something breaks for me…

But…The Left and Right operations of the joystick in the program are reversed. I can work around this by swapping right and left motor sides and reversing polarity of both motors but then obviously the other programs will not work correct.

I just started looking into your code to see how this was coded but I am not yet familiar with the GoPiGo library or how to use it.

Please help direct me how to fix the virtual joystick issue.

Also, very important…I figured I would discover this along the way but I don’t know how to write to a motor to give it a direct speed or pwm value. Speed if you are running PWM on the motor which I heard you are or can.

I need direct control of the motors so I can have the robot turn smoothly and at different arc angles.

Any pointers would be helpful before I plow though what you have.

Is there a general how to write your own programs with the GoPiGo library tutorials? Your code structure is quite dispersed so it makes it difficult to follow.

I’ll get it…

My end goal is to have openCV running to do image tracking.

I have done this before on other robots, just not the pi.

Mark

Hey,
The code to control the GoPiGo from the joystick on the screens is here: https://github.com/DexterInd/GoPiGo/blob/master/Software/Python/Examples/Browser%20Streaming%20Robot/robot_controller.py#L99-L130 . You can easily modify this to suit your GoPiGo.

To increase or decrease the speed you can use the set_left_speed() and set_right_speed() http://www.dexterindustries.com/GoPiGo/learning/python-programming-for-the-raspberry-pi-gopigo/ and make the GoPiGo move according to that value. It would be better to first get this to work with just keyboard commands and then integrate with the main joystick code.

-Karan

Hi,
I tried this and ran the updates that John posted here to get it to read from the correct place. However, now I have a browser that shows me this (see attached). Does this mean my camera isn’t working? I am using an old one, so maybe the ribbon is broken? Also, the joystick isn’t working. But, maybe the camera needs to be working in order to have the joystick working too…?

Just FYI in the screenshot you see pi10.local because I changed my username. :slight_smile:

I’m also getting the Terminal screen showing me that the “connection closed”. See screen shot attached. Maybe this has something to do with it?

Thanks,
KK

Hey KKNS, it looks like a web connection is being made: you wouldn’t see that joystick. Are you controlling with a phone or a web browser?

It looks like the problem is with the camera. To double check that: do you see a red light coming on with the camera when you start the program? If not, would check that the ribbon is oriented correctly in both the Pi and the Camera first.

Please let us know if this works!

Hi John,

Thanks! You are right that the light on the camera wasn’t turning on! I got a brand new camera and plugged it in, and now I’m getting a different error.

This is what I did.

Connect via VNC
opened up Terminal
went to: cd Desktop/GoPiGo/Software/Python/Examples/Browser Streaming Robot/
did this: sudo chmod +x robot_web_server.py
then this: sudo ./robot_web_server.py

still said “500 Internal server error” and Terminal said “I0Error: No such file or director: …” (this is what happened before too)

So, then I did what you said above to try and fix it:

control + c to quit
then…
cd ~/Desktop/GoPiGo/
sudo git reset
sudo git pull origin

On this last git pull origin command, it said "error: your local changes to the following files would be overwritten by merge: … Please commit your changes or stash them before you can merge. Aborting."
See the screen shot attached.

Does that mean it won’t work? I tried and it wouldn’t work… assuming it it because this part above isn’t working like it did last time. Any tips?

Sorry about the confusion here. You should run the following commands:

cd ~/Desktop/GoPiGo/
sudo git fetch origin
sudo git reset --hard
sudo git merge origin/master

That should update the GoPiGo folder with the latest code.

Hi,

I’m experiencing the same problem here. After the first time, I did a hard git reset and I’m now at
11a6049 Merge pull request #93 from karan259/master – but, the problem persists.

I initially followed the instructions here:
http://blog.initialstate.com/pi-browser-robot-camera-car/

When I open the browser and go to the RasPi IP, I get “500 internal server error”.

This is what the python script on the RPi (via PuTTy, or VNC) says:

pi@raspberrypi ~/Desktop/GoPiGo/Software/Python/Examples/Browser_Streaming_Robot $ sudo ./robot_web_server.py
sockjs.tornado will use json module
/home/pi/Desktop/GoPiGo/Software/Python/Examples/Browser Streaming Robot/www
Starting web server...
Uncaught exception GET / (192.168.0.206)
HTTPServerRequest(protocol='http', host='192.168.0.154', method='GET', uri='/', version='HTTP/1.1', remote_ip='192.168.0.206', headers={'Accept-Language': 'de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4', 'Accept-Encoding': 'gzip, deflate, sdch', 'Host': '192.168.0.154', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.16 Safari/537.36', 'Connection': 'keep-alive', 'Cache-Control': 'max-age=0', 'Upgrade-Insecure-Requests': '1'})
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1332, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "./robot_web_server.py", line 180, in get
    self.render( webPath + "/index.html" )
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 665, in render
    html = self.render_string(template_name, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 769, in render_string
    t = loader.load(template_name)
  File "/usr/local/lib/python2.7/dist-packages/tornado/template.py", line 343, in load
    self.templates[name] = self._create_template(name)
  File "/usr/local/lib/python2.7/dist-packages/tornado/template.py", line 370, in _create_template
    with open(path, "rb") as f:
IOError: [Errno 2] No such file or directory: '/home/pi/Desktop/GoPiGo/Software/Python/Examples/Browser Streaming Robot/www/index.html'
500 GET / (192.168.0.206) 34.21ms

Thanks a lot in advance for all your help.

Cheers,

Monika

Hey,
Looks like there is a problem with the filepath. Can you change the path in :https://github.com/DexterInd/GoPiGo/blob/master/Software/Python/Examples/Browser_Streaming_Robot/robot_web_server.py#L63 from "/home/pi/Desktop/GoPiGo/Software/Python/Examples/Browser Streaming Robot/www/" to "/home/pi/Desktop/GoPiGo/Software/Python/Examples/Browser_Streaming_Robot/www/".

Do let us know if this helps.

-Karan

Hi Karan,

yes, adding the underscores in the filepath did the trick! Thanks a lot!

Cheers,

Monika