3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Modifying an iRobot Create to Paint

Step 5Using Sensors to Paint

Using Sensors to Paint
«
  • IMG_0943.jpg
  • IMG_0948.jpg
As I stated in my introduction, after working on this for a while I realized that treating it as a printer really overlooked a lot of features the robot has to offer. So here are a few things you can do with the Create, Command Module, and sample programs to make paintings. Once you get a feel for how the code works and what you can change the options will be endless.

The very easiest way to paint with sensors is to the run the sample 'cover' program with objects around the perimeter of the painting area, and even some heavy objects (that are either paint resistant or wrapped in waxed paper) within the painting area. But you probably want a little more control than that, and I added the Command Module to the materials list for a reason.

If you would like to keep some of the randomness in what the robot is painting, but still have it work within parameters you set, here are some ways to do it:

Open the sample program called 'drive' in programmers notebook (an explanation of this is available in the manual you can download from the iRobot website.)

On line 156 you will find:

// Set the turn parameters and reset the angle

This is what the robot does when a sensor is triggered. This includes bumping into things or almost falling off of things. This section has some fun things to play with.

distance = 0;
You can change this to any number. The number you choose is how many millimeters the robot will back up after it hits or finds the edge of something. So, for example, changing the "0" to "200", it will back up 200 millimeters. This will give you 200 millimeter long lines at various angles coming from the edges and whatever other objects are on and around the painting surface.

angle = 0;
This means it backs up straight after it hits something. You man not want this. If you'd like it to back up at different angle set a number here. Changing "0" to "45" will cause it to back up at an arc of 45 degrees. This one takes some tweaking to get just how you want it, but it can cause some cool effects.

turn_angle = randomAngle();
This means that the amount the robot turns after hitting something will be somewhere between 53 and 180 degrees. If you'd like to change the range of "random" then head down to line 460 and change that code. If you'd like to set it to a specific angle change "randomAngle()" to "15" or whatever other angle you like. The numbers "1" and "-1" are reserved for right angles, but it seems that any other number, positive or negative is fair game. I just realized that I haven't tried anything over 360, but now I can't wait to try.

On lines 143 and 149 you find "turning" followed by a 0. Changing those to anything else makes the robot spin forever. This isn't a very effective or fun change to make, so I wouldn't bother.

drive(300, RadStraight);
This means move forward at a rate of 300 heading straight. You can change the speed of the robot by changing "300" to another number. Lower is slower, higher is faster (no tricks here). Changing "RadStraight" to a number will result in the robot driving in an arc. This will definitely increase the 'painterly' nature of what the robot does. I really like changing this setting.

Changing the speed the robot moves can change the lines it paints. Slower speeds will usually result in a smoother, heavier application of paint. Faster speeds will give you a brushier effect, or it will sometimes even make your brush skip.

Once you get involved in the code you'll be able to tweak all kinds of things. If you are having trouble understanding something check the oi file, sometimes there are clues in there. A lot of the time I've had better luck using an angle number instead of "RadCW" or similar commands. I'm assuming this is a fluke, but it's something to check if you have trouble.

I'm not an experienced programmer at all. In fact, this is the first I've ever done anything with code, with the exception of making websites. I think it's pretty hard to hurt the robot, and there's always a clean copy of the sample programs on the CD if you irreparably damage the one you're modifying. The code is well noted, and you can pretty much figure out what everything does if you take some time with it. It's worth diving in and changing things to see what you get. I've written quite a few new things to add to the 'drive' program, but they aren't ready to show to the world quite yet.




« Previous StepDownload PDFView All StepsNext Step »
1 comment
Oct 2, 2008. 12:48 PMGrey_Wolfe says:
I imagine the painting gets much more "abstract" if you get thirsty. lol

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
203
Followers
38
Author:technoplastique(Technoplastique Blog!)
I'm making something new for every week of 2012. Check my blog to see what I'm working on!