WARNING WARNING WARNING WARNING
Moving machines can cause damage to personal property, personal injury or death. It is the responsibility of the reader of this document to take adequate safety precautions when operating, designing, or building any machinery, or when offering machinery to others for use.
None of the software, documents, firmware, schematics, drawings or other materials accompanying this document have been checked for errors, omissions or mistakes of any kind. Use it at your own risk.
Your use of the software, documents, firmware, schematics, drawings or other materials accompanying this document is governed by the License Agreement. Read it before proceeding.
All trademarks are the property of their respective owners.
In this tutorial you will learn to use the Chrome Web Lab's Sketchbot open source Sketchbot library in order to build your very own web-controlled drawing machine!
Since building robots can be an expensive endeavor we will try to minimize cost (and complexity) by making a drawing robot using Lego Mindstorms NXT.
Like its bigger brother, the Mindstorms Sketchbot will use a 3-axis arm to manipulate a physical 'stylus' in order to tranposes a vector-based image onto a two-dimensional surface like paper.
After assembling Lego Mindstorms NXT drawing robot, getting the dependencies installed on your machine and running the Sketchbot code, the library will handle everything from the image capture, to the conversion to vector-based machine code (i.e. gcode) that the drawing robot can understand.
For a full description of the history and concept of the project see this page.
It looks something like this after setup:

(click for video)
NOTE:
The Lego Mindstorms NXT sketchbot is NOT a high-precision drawing robot--far from it. This is primarily due to its physical motor limitations and loose tolerances. However, it does demonstrate how a complete drawing system works, by going from web interface to physical sketch and providing a great jumping off point for anyone interested in building more advanced drawing machines using the Chrome Web Lab's Sketchbot library.
###References
###PART 1: Gather Materials
The first step is to acquire all of the parts we will need to build this project.
- LEGO® MINDSTORMS® NXT Kit (such as LEGO kit number 8527)
- Pen, Pencil or Brush to attach to the stylus
- Paper or other drawing surface--try sand if you like
- A good metric ruler or, better still, a good metric dial caliper. Yes, you should use metric units.
--
###PART 2: Assemble the Lego Sketchbot

####Build the Base We will start with the base from a robot arm designed by Dave Parker, then add a new arm section on top. Special thanks to Dave for making such a great collection of Mindstorms projects available.
To build the base, follow Dave's instructions through step 9 for Dave Parker's robot arm (cached copy here) then return here. Don't do steps 10 or later.
####Build the Middle Arm Segment - Part 1
#####Parts














####Build the Middle Arm Segment - Part 2
#####Parts







####Build the Middle Arm Segment - Part 3
#####Parts










####Build the Middle Arm Segment - Part 4
#####Parts








####Build the Middle Arm Segment - Part 5
#####Parts


####Connect the Middle Arm to the Base
#####Parts
####Test the Middle Arm Connection
#####Procedure

####Build the Limit Switch
#####Parts








####Connect the Limit Switch to the Base
#####Assembly
IMPORTANT: Rotate the base so that the limit switch will not be stuck between the NXT brick and the corner of the base. Looking from above with the "NXT" text reading left-to-right, rotate the base clockwise so that the limit switch is past the corner. This may be difficult to see in the video.
When complete, the switch should be attached as shown below:

####Build the Stylus
#####Parts















####Connect the Stylus to the Middle Arm
#####Assembly

####Connect the Cables
#####Parts
Cable 0.2M:
Cable 0.35M:
Cable 0.35M:
Cable 0.5M:
###PART 3: Software Configuration
Now we will set up the software needed for this project. This will be done on a computer, as well as on the "NXT brick" from the LEGO kit.
The NXT brick is the motion controller for LEGO's robotics system and handles taking higher level motion commands and moving the motors appropriately. The NXT Brick comes from LEGO with a stock firmware installed. Happily, LEGO freely allows builders to install their own new firmware. We will use the community-developed pbLua firmware rather than the stock LEGO firmware.
- Follow the instructions in the Getting Started Guide, Basic Setup section for the main Sketchbot Library and follow the procedures there. Once you can verify the system works without any LEGOs attached head back.
- If you haven't done so already, make sure that the basic LEGO Mindstorms NXT software is installed and running properly on your computer. Instructions are included in the Mindstorms NXT box and on LEGO's web site.
- Update: we are now using the pbLua 2.0 RC2 firmware. Download that here. Follow these instructions to install the pbLua firmware on the NXT brick.
- Open the ConfigParams.js file from the robotcontrol/src folder.
- Locate the
DRAW_MACHINE_TYPEsetting. Make sure it is set as follows:DRAW_MACHINE_TYPE: "MindstormsNXT", - If you built your drawing machine according to the instructions referenced in step 1, above, then the robot geometry settings included in ConfigParams.js can be used as-is. If you modified the machine or want to understand these settings in more detail, please see the DrawMachine Geometry Configuration section.
- Connect the NXT brick to the computer via USB or Bluetooth and make sure the NXT Brick is on (press the orange button). See your computer operating system's documentation for details on how to create a Bluetooth connection.
- Determine the name of the serial port by looking in the /dev directory in a shell or Mac OS X terminal. For Bluetooth devices on Mac OS X, the port is usually called /dev/cu.NXT-DevB.
- Back in ConfigParams.js, set the
MINDSTORMS_NXT__SERIAL_PORTto the name of the serial port from step 9. - Save changes to ConfigParams.js.
Now we should re-test the entire system to make sure that it still works.
- In the shell, change to the robotcontrol/ folder (one level up from the src folder).
- Run
./start_robot_control- You should see the following message in the console:
********************** Connected to MindstormsNXT drawing machine **********************- You should also see "Sketchbot OK" on the Mindstorms NXT brick LCD display. Troubleshooting: If you do not see both the message in the console on the computer and on the LCD, then you may have the wrong serial port configured in ConfigParams.js. Review Step 9 above and try again.
- Switch to the UI running in your browser. If the UI is not running, switch to App Engine Launcher, select labqueue and press the Run button. Click the Browse button to display the UI in your browser.
- Click the New from File button
- Select the testpattern.png file which is part of this repository. You can find it in the sw/test folder.
- Click the Save button
- A few seconds later robotcontrol should pick up the new drawing task and begin commanding the drawing machine.
Troubleshooting:
- If robotcontrol does not detect the new drawing task then there may be a fundamental misconfiguration in robotcontrol itself. Review the Getting Started: Basic Setup instructions.
- If robotcontrol detects the new task but the robot does not start drawing then review step 3 in this test procedure to make sure that the computer is actually connecting to the robot.
- The Mindstorms system is battery hungry. If things are acting strangely, try using fresh batteries.
- If you are having communication problems between the computer and the NXT brick, try using USB instead of Bluetooth.
- If the drawing machine starts drawing but does not draw correctly, you may need to check the physical build of the machine. Review the steps in Part 2 this file (above).















