<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Mad Physics (Robotics)</title>
    <link rel="alternate" type="text/html" href="http://www.madphysics.com/robotics/" />
    <link rel="self" type="application/atom+xml" href="http://www.madphysics.com/robotics/atom.xml" />
   <id>tag:www.madphysics.com,2007:/robotics//3</id>
    <link rel="service.post" type="application/atom+xml" href="http://www.madphysics.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=3" title="Mad Physics :: Robotics" />
    <updated>2007-06-12T23:30:56Z</updated>
    
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 3.2</generator>
 
<entry>
    <title>Designing and Rendering Computer Graphics</title>
    <link rel="alternate" type="text/html" href="http://www.madphysics.com/robotics/designing_and_rendering_computer_graphics.htm" />
    <link rel="service.edit" type="application/atom+xml" href="http://www.madphysics.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=3/entry_id=24" title="Designing and Rendering Computer Graphics" />
    <id>tag:www.madphysics.com,2006:/robotics//3.24</id>
    
    <published>2006-02-28T21:00:57Z</published>
    <updated>2007-06-12T23:30:56Z</updated>
    
    <summary>Computer graphics are based on mathematical concepts such as geometry and vectors. Animators use basic shapes to create complex objects and use many different techniques to achieve realism. This growing field is constantly adapting with new technology and it’s a fun challenge for artists and programmers alike. This article outlines the fundamentals of computer graphic design....</summary>
    <author>
        <name>Afrooz Family</name>
        <uri>http://www.madphysics.com</uri>
    </author>
    
    <content type="html" xml:lang="en" xml:base="http://www.madphysics.com/robotics/">
        <![CDATA[<p>Computer graphics are based on mathematical concepts such as geometry and vectors. Animators use basic shapes to create complex objects and use many different techniques to achieve realism. This growing field is constantly adapting with new technology and it’s a fun challenge for artists and programmers alike. This article outlines the fundamentals of computer graphic design.</p>]]>
        <![CDATA[<div align=center><a href=#intro>Introduction</a> | <a href=#model>Modeling Objects</a> | <a href=#real>Achieving Realism</a> | <a href=#render>Rendering</a></div>

<p><a name=intro id=intro></a><p class=style14>Introduction</p></p>

<p>Animation and graphic design is vital in many trades. From making advertisements to special effects in blockbuster movies, computer effects artists are in high demand. This article provides a very quick introduction to the various steps of animation, including modeling, setting up materials, and rendering. These skills are pertinent in all fields of design. While this article does not cover technical details, it includes plenty of pictures to show the gradual evolution of a scene. This article was written in conjunction with iHOT team 1414 (the team has an animation group which creates animations to represent the team). iHOT won the national prize last year for their work in animation. This article was written by iHOT chief animator, Matthew Keeter. </p>

<p><a name=model id=model></a><p class=style14>Modeling Objects</p></p>

<p>The first stage of making a scene is modeling an object. You can start with basic objects like boxes (1), and edit them until they look like a car, or a horse, or a person. All objects are made of faces, or “polygons.” You can move individual faces around, and “extrude” them to make an object look different (2). By adding more faces, you can end up with complex models, which look like things in real life (3). You can have more than one object in a scene, so I’ll give my teapot a lid (4).</p>

<div align=center><img alt="model.jpg" src="http://www.madphysics.com/robotics/images/model.jpg" width="310" height="236" /></div>

<p><a name=real id=real></a><p class=style14>Achieving Realism</p></p>

<p>This teapot looks nice, but it still doesn’t look real. The next step in animation is creating materials that look real. This new material is white, and not as shiny (5). Most objects aren’t just one color.  Animators use “textures” to make materials look more real. These textures are usually image files, or created by small programs that generate patterns like clouds or checkerboards. The teapot now has a cloudy material assigned to it (6).</p>

<div align=center><img alt="real.jpg" src="http://www.madphysics.com/robotics/images/real.jpg" width="310" height="113" />
</div>

<p><a name=render id=render></a><p class=style14>Rendering</p></p>

<p>The final stage of animating is setting up a scene to “render.” When you render a scene, your computer calculates how the objects you’ve made should actually look. Rendering a scene can take seconds or hours, depending on the complexity of your scene. To prepare to render this scene, I’ll set up a surface on which the teapot can cast a shadow (7). Finally, you can place your completed model in a scene with other objects and effects (8).</p>

<div align=center><img alt="render.jpg" src="http://www.madphysics.com/robotics/images/render.jpg" width="350" height="300" />
</div>

<p>Here’s a close-up of the tea liquid, which has been set as transparent and reflective:</p>

<div align=center><img alt="final.jpg" src="http://www.madphysics.com/robotics/images/final.jpg" width="300" height="225" />
</div>
]]>
    </content>
</entry>
<entry>
    <title>An Introduction to Robot Programming</title>
    <link rel="alternate" type="text/html" href="http://www.madphysics.com/robotics/an_introduction_to_robot_programming.htm" />
    <link rel="service.edit" type="application/atom+xml" href="http://www.madphysics.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=3/entry_id=23" title="An Introduction to Robot Programming" />
    <id>tag:www.madphysics.com,2006:/robotics//3.23</id>
    
    <published>2006-02-23T18:15:53Z</published>
    <updated>2007-06-12T23:31:36Z</updated>
    
    <summary>Programming is an essential part of robotics. A robot&apos;s programming acts as a guide for the machine and makes it &quot;autonomous.&quot; The robot’s Central Processing Unit (CPU) holds the information and processes it, acting as the robot&apos;s brain. This tutorial outlines the basics of programming....</summary>
    <author>
        <name>Afrooz Family</name>
        <uri>http://www.madphysics.com</uri>
    </author>
    
    <content type="html" xml:lang="en" xml:base="http://www.madphysics.com/robotics/">
        <![CDATA[<p>Programming is an essential part of robotics. A robot's programming acts as a guide for the machine and makes it "autonomous." The robot’s Central Processing Unit (CPU) holds the information and processes it, acting as the robot's brain. This tutorial outlines the basics of programming.</p>]]>
        <![CDATA[<div align=center><a href=#intro>Introduction</a> | <a href=#controller>Controller</a> | <a href=#code>Code</a> | <a href=#modify>Modifying the Code</a></div>

<p><a name=intro id=intro></a><p class=style14>Introduction</p></p>

<p>Robots, from the Mars Rover to the Roomba, have one thing in common, a CPU. These machines can perform a wide range of automated tasks, but they all are dependent on programmers—robots are especially configured to work the way they do. This is a result of a complex system of inputs and outputs. A robot’s onboard computer constantly gets input from sources such as sensors and motors, and the computer analyzes this information to determine what the robot needs to do. This input can be information such as position, time, and a host of other possibilities. These variables can in turn trigger motors, lights, or other onboard components.</p>

<p>Many robots are programmed from scratch, and others have a preexisting framework. To give you a basic example of robot programming, we will the latter, and show you how one can rearrange preexisting code to make a robot perform customized tasks. This tutorial is based on the <a href=http://www.usfirst.org/robotics target=”_blank”>FIRST Robotics Competition’s</a> default code. This code used and altered by thousands of high school teams across the world. Each team receives the same framework (which is described in this article) and their programmers edit the code to achieve their team’s goals. IHOT team 1414’s lead programmer, Adrien Pellerin, wrote this article.</p>

<p><a name=controller id=controller></a><p class=style14>The Controller</p></p>

<p><br />
This introduction to programming is an overview of the necessities of programming the FRC (FIRST Robotics Competition) Robot Controller. <img alt="http://www.madphysics.com/robotics/images/controller.jpg" src="http://www.madphysics.com/robotics/images/controller.jpg" width="190" height="160" align="right"/>By the end of this article you should have a better understanding of what programming the robot takes and how it is done. The Robot Controller, manufactured by Innovation First <a href="http://www.innovationfirst.com" target="_blank">(www.innovationfirst.com)</a>, is the heart of the robot. It is the machine that executes your code. It gets information from the rest of the robot through its many analog and digital inputs, and it sends information back through its many outputs. Basically there are 16 each of Analog Inputs, Digital In/Outputs, and Motor (PWM) Outputs. Digital inputs can be used for various sensors like limit switches and light sensors. Being digital they send a ‘1’ (true, or high) or a ‘0’ (false, or low) back to the controller depending on how they’re being used. Analog Inputs can be used for sensors like potentiometers where the return value can’t just be true or false. Finally, motor outputs are where the motors are plugged in to so they can be told how fast to turn.</p>

<p><a name=code id=code></a><p class=style14>The Code</p></p>

<p>Since 2004, FRC robots have been programmed in the C language, or if teams wish, Assembly language. <img alt="struct.jpg" src="http://www.madphysics.com/robotics/images/struct.jpg" width="105" height="175" align="left"/><br />
Before 2004 PBASIC was used. The code is compiled with Microchip’s C18 compiler. FIRST provides this along with Microchip’s MPLAB IDE to FRC teams.</p>

<p>The structure of the Default Code (provided to FRC teams) can be seen in MPLAB IDE. The various files in the project are categorized under “Source Files”, “Header Files”, “Library Files”, or “Linker Scripts”. Source files are those with actual code which will be executed. Header files contain variable declarations and definitions that are used throughout the program. Library files cannot be read because they have already been compiled. They contain more information like the header files. Linker Scripts tell the compiler how to link all of these files together to make one seamless program. The most important file to the programmer is ‘user_routines.c’. It contains a function called ‘Default_Routine()’. This function runs every 26.2 ms on the robot controller. This means that it will run approximately 38 times per second. The reason for this time is the controller can only get new inputs and put new outputs every 26.2 ms.</p>

<div align=center><img alt="images/code.jpg" src="http://www.madphysics.com/robotics/images/code.jpg" width="508" height="313"/></div>

<p><a name=modify id=modify></a><p class=style14>Modifying the Default Code<br />
</p><br />
Motors: pwmx (x = 01 – 16)<br />
Digital inputs: rc_dig_inx (x = 01 – 16)<br />
Analog inputs: rc_ana_inx (x = 01 – 16)<br />
Joysticks: <br />
<blockquote><br />
•	p1_x (X axis of joystick 1) <br />
•	p3_y (Y axis of joystick 3)<br />
•	p2_sw_trig (Trigger of joystick 2 [0 = up, 1 = pressed])<br />
•	p4_sw_top (Top button of joystick 4)<br />
</blockquote><br />
Using these variables, you can edit ‘Default_Routine()’ to suit your robot. All variables are stored as “unsigned char”, so they are one byte each. This means that they can have values of 0-255 (digital variables only use 1 and 0). In pwm’s, 0 is full reverse, 255 is full forward, and 127 is neutral, or no movement. On joystick axes, 0 is full back, 255 is full forward, and 127 is middle. This means that you can easily map a pwm to a joystick with this line:</p>

<p>pwm01 = p1_y; //Motor 1 gets the speed of Y axis of Joystick 1</p>

<p>Here are some more code samples:<br />
<blockquote><br />
if(rc_dig_in05 == 0) //If Digital input 5  is giving '0'<br />
{<br />
	pwm01 = pwm02 = ((p1_y + p2_y) / 2); //motors 1 & 2 get the average of p1_y and p2_y<br />
}</p>

<p></p>

<hr width="400" size="4">

<p></p>

<p>int timer = 0; //Times processor cycles</p>

<p>/*<br />
timer will count how many times the code has run.<br />
The code runs every 26.2 ms. 38 times per second.<br />
This can be used to time certain events<br />
*/</p>

<p>void Default_Routine(void)<br />
{<br />
	if(timer < 38) //For the first second...<br />
	{<br />
		pwm01 = pwm02 = 255; //Both motors at full speed<br />
	}<br />
	else if(timer < 114) //For the next 2 seconds...<br />
	{<br />
		pwm01 = 0; //motor one full reverse<br />
		pwm02 = 255; //motor two full forward<br />
	}<br />
	else if(timer < 133) //For the next 1/2 secoond...<br />
	{<br />
		pwm01 = pwm02 = 0; //Both motors full reverse<br />
	}<br />
	else<br />
	{<br />
		pwm01 = pwm02 = 127; //When finished, stop both motors<br />
	}<br />
}</p>

<p></p>

<hr width="400" size="4">

<p></p>

<p><br />
if(p1_y >= 127) //If p1_y is pushed forward or at rest...<br />
{<br />
	pwm01 = ((((p1_y - 127) * (p1_y - 127)) / 127) + 127); //Curve the speed<br />
}<br />
else //If p1_y is pulled back<br />
{<br />
	pwm01 = (127 - (((127 - p1_y) * (127 - p1_y)) / 127)); //Curve the speed<br />
}<br />
</blockquote></p>]]>
    </content>
</entry>

</feed> 

