PiBot-B

PiBot-B is a small mobile robot based on Raspberry Pi that moves on caterpillar tracks. A video live stream taken by a webcam is transmitted to an iPhone via WiFi. The vehicle can be controlled remotely with a simple iPhone web app. An 8x8 LED matrix built into the enclosure is used to display various operating conditions.

Planned next stage: If the robot is set into autonomous mode it moves on without external control. It then uses infrared and micro switch sensors to detect obstacles and it will avoid them independently by appropriate maneuvers.

Website of this project with lots of implementation details: www.retas.de/thomas/raspberrypi/pibot-b/. The website is in German for now, but provides a google translation. A video is coming soon.

Update 2013-11-21: Some things can be made better or easier. In the writeup I added some ideas for improvements: www.retas.de/thomas/raspberrypi/pibot-b/#improvements

Update 2015-06-05:

EN: PiBot-B will be present at German Raspberry Jam Pi and More on June 20 in Trier.
DE: Ich werde PiBot-B auf der Pi and More am 20. Juni in Trier vorstellen:

 

Raspberry Pi based, controlled remotely, exploring the environment, transmitting a webcam live stream

  • Actuators / output devices: 2x 1:100 gear motors (Pololu), Pololu Zumo chassis kit
  • Control method: non-autonomous until a soon update, iPhone Web App
  • CPU: Raspberry Pi Version B
  • Operating system: Raspbian Wheezy
  • Power source: 4 x AA battery (motors), 5V Power Pack (Raspberry Pi)
  • Programming language: Python
  • Target environment: indoors mainly

This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/pibot-b

Sweet base, very cute! And

Sweet base, very cute! And awesome that you have that much computing power in such a small cute little fella!

I’d love to see some video :slight_smile: How fast is it driving, and is it steady, it looks as if it has a high balancing point?

Cost to build: $120 ???

Video, speed, costs

A Video is coming soon.

The robot moves rather slowly - about 0.25m/s.

The barycenter of the vehicle is pretty low (because of the 4 AA batteries in the bottom of the Pololu chassis), but off-center to the rear where the 5V power pack is mounted. Without any delay/acceleration when changing from backwards to forwards it would make a little hop with its nose. Hence I implemented a short phase of automatic delay/acceleration for any change of the direction.

The costs are even higher than the $120 I posted. When I add up the current prizes for all parts from www.retas.de/thomas/raspberrypi/pibot-b/#components I get 180 Euro, which is about $250. Main cost factors are the webcam, the 5V power pack, the chassis with motors - and the Pi.

Information on "simple iPhone web app"

I love what you have been building here and I have been gathering parts for the past week or so.

I have a raspberry pi that I have installed Lightttpd on and I’m using a wifi connection. I have a limited knowledge of webhosting and am trying to figure out how you created the iphone control screen you show in your writeup. Is that something you created using html, and if not, where can I get the code for it.

Or, did you actually create an iphone app for your self. My preference is android, but my wife has the iphone if necessary. If it’s a web browser app, it shouldn’t make much difference.

I’m loving the Raspberry Pi and am anxious to teach my grandson Linux and programming. I think the robotics will get his juices flowing.

iPhone web app

Thanks for your kind words.

The “web app” is just ordinary html, displayed by the safari browser on the iPhone. There are few safari-specific meta elements (viewport, apple-mobile-web-app-capable) that makes it look like a genuine app. For example the safari window is displayed in fullscrreen mode without interactive elements, and a start icon is created on the iPhone home screen. But it also runs in the firefox browser on my pc, and I assume it will run under android too.

The web page has 2 frames. The above one primarily contains the video streaming (http://robot:8080?action=stream). The below one is a simple php form with 10 buttons, a little cgi script writes the button number into a file, which is read by the python script (running under root) that performs the motor control in an infinite loop.

That’s all. Hope this will help you. Enjoy your grandson! (Mine is only 2 1/2 :wink:

Web app controller

Thanks for your quick reply Mosmas.

I may have given you the impression that I have more programming skills than I really do. In my career as an Analyst at HP, I had to learn to read and understand programming, but I had never done any real programming. Just some scripting in Unix/Linux.

That said, I’m starting to learn to program in python and I have just been looking into php and cgi. Would I be asking too much to see the code for your video and motor control? That way, I could take it and ‘deconstruct’ it.

If you’re not comfortable with that, I understand.

Kem @ [email protected]

you have mail

:wink:

html file

Hi,

Thank you for this awesome robot! Can you please share your html file? I am not very good with php so right now my file just looks like this. Please help?

code:


<html>
  <head>
  <title>MJPG-Streamer - Stream Example</title>
  </head>
  <body>
  <center>
  <img src=“http://rasppi:8080/?action=stream” />
  </center>
  </body>
</html>
 

:endcode

 

Correct!

Yep - that’s it. This works fine with my browser (safari on iPhone). Other browsers may require some java script, as shown in the examples here: https://github.com/engine12/mjpg-streamer/tree/master/www

I only added some css to control the layout, and I made the image clickable to implement a restart of the mjpg-streamer, since my webcam sometimes fails. (You probably don’t need this, seems to be a problem of my webcam only.)

Do you mind posting your
Do you mind posting your HTML and PHP code?

Voilà

This is the code of the frame (“frame_cam.php”) that displays the video stream:

<html>
<? exec (“sudo …/mjpg-streamer.sh stop >/dev/null 2>/dev/null; sudo …/mjpg-streamer.sh start >/dev/null 2>/dev/null”); ?>
<body style=“margin:0px;padding:0px;background-color:black”>
<center>
<div style=“width:320px; height:240px; margin:0px; padding:0px; background-color:#444”>
<form action=“frame_cam.php” method=“post”>
<input type=“image” src=“http://pibot-b:8080/?action=stream” name=“restart” value=“restart” />
</form>
</div>
</center>
</body>
</html>

Replace the “…” above with the path of your mjpg-streamer. Note that the www user must have sudo permission to start/restart the mjpg-streamer script.

ok, I understand that part.

ok, I understand that part. But I dont understand how to make the buttons 1,2,3…9 to write to a text file. Do you have a example of that?

button to file

This is the relevant part of the code (file “frame_buttons.php”). Above part: writing button to file, below part: displaying buttons in a form.

<html>
<?
    if (isset ($_POST[‘1’])) {
        $button = “1”;
    } else if (isset ($_POST[‘2’])) {
        $button = “2”;
    …
    }

    if (isset ($button)) {
        $button_file = fopen (“button.txt”, “w”);
        fwrite ($button_file, $button . “\n”);
        fclose ($button_file);
    }
?>
<body>
<form action=“frame_buttons.php” method=“post”>
<input type=“submit” name=“1” value=“1”>
<input type=“submit” name=“2” value=“2”>

</form>
</body>
</html>

Please note: I’m not a php expert, the above code is at the level that I can do such things. Presumably this can be done much better/easier/shorter/safer/…

Great Work!

This is a very elegant design! Minimalist and expandible and very fuctional! I like that you drive the motors directly instead of delegating it to a microcontroller. Very good work. I’ve recently posted something similar, except I’m using a parallax boebot chassis and a basic stamp as an intermediate between hardware and software…any advice would be greatly appreciated!!

You got it!

Thanks. Indeed, minimalism was one of my goals. I tried to let the Pi do as much as possible by itself. That’s the reason for using that archaic or-gate-technique instead of some of these tiny and cheap microcontrollers. How could I give you any advice? Please note, I’m no expert. This is my first robot project and my first raspberry pi project as well.

ok, I have the php code to

ok, I have the php code to write the text file now. Now I need to figure out how to read the text file and enable/disable a GPIO pin. I followed your blog here http://www.retas.de/thomas/raspberrypi/pibot-b/#software but it doesnt have any code for reading the text file. Am I missing something? Can you share that code please?

No, sorry.

Please bear with me - for now, I’m not willing to share all the code here, since it’s still heavily under construction. It does work as a proof of concept, but it is not in a final state that I want to release into the public domain. Once it is finished, I’ll put it on my webpage and post an announcement here.

ok, i understand. Thank you

ok, i understand. Thank you for all your help! 

sample program using your suggested motor driver

Amazing job… Nice design! I’m planning to build one but will follow your future improvement to use the pololu DRV8835 motor driver. But the problem is im quite new to robotics and programming and i’m a little bit clueless. Can you help me achieve and start it? I need help creating a program using the pololu driver. A sample program to start will be a great help.

thanks again.

Cute

Nice bot!