15-494 Cognitive Robotics
Part I: MotionCommand tutorial
Read through the Motion Commands section of the Tekkotsu tutorial at http://www.cs.cmu.edu/~dst/Tekkotsu/Tutorial/. If you want to try out some of the example code on the robot, you can cut and paste it into a file in your project directory.
Part II: Exercises
We only expect you to complete and demonstrate one of the following five tasks for lab today. Three more of them will form your first homework assignment, so if you finish the lab with time remaining, feel free to press on. You only have to do a total of four of these five tasks; you can pick which one to skip. Email your completed assignment to Dave by Friday, Feb. 1. Please use the subject '15-494: Handin 1', as per handin instructions.
Use TailWagMC to wag the tail slowly, and bark each time the tail passes through the neutral position (straight up). Also, flash the LEDs each time the tail changes direction. TailWagMC posts a status event whenever a direction change occurs.
To detect when the tail goes past neutral, you will need to look for a change in sign of the value returned by TailWagMC::getPan(). By subscribing to sensorEGID events, you can be "woken up" each time a joint value changes. (Specify a source ID of SensorSrcID::UpdatedSID and omit the event type. A sensorEGID event is posted every 32 msec when the sensor values are updated. Where is SensorSrcID defined?) Compare the current pan value with the previous one, which you should cache in a member variable.
In order to play a sound,
There are more options available, such as using
Listen for presses of the back buttons and use them to control the period of the cycle. (The details of how to interpret the button presses are up to you -- a tap on one button might increment the speed by a constant or a percentage, or you might have to hold the button down, etc.)
Looming Ball Indicator
Use LedMC to display the size of the pink ball in the camera image.
Note that most of the LED functionality is provided by LedMC's superclass, LedEngine, so that is the reference page you'll want to see. (The LED management is abstracted away from the MotionCommand to make it easier to recombine LED effects in other MotionCommands)
Refer to the Behaviors lecture for help with subscribing to vision events. Once you have received a vision event, you will want to use the VisionObjectEvent::getObjectArea() function to determine how large the ball is. This function returns a value in the range 0-1 reporting what percentage of the camera frame is filled by the object. (There are more accurate ways to judge distance if you are willing to make assumptions regarding the size or placement of the object, but we aren't concerned with accuracy for this task.)
Once you have determined the size of the ball, use LedEngine::displayPercentage() to display this information. Experiment with the different styles this function allows.
Wag the Dog
If the tail was smarter, the tail would wag the dog.
Control the head with the tail, joystick-style. To allow the tail to be moved freely, use the following code:
Once you are able to move the tail freely, (only when the emergency stop is turned off however!) read the tail's position from
Pick a random button-associated LED, turn it on, and wait until the user pushes the corresponding button to turn it off again, then pick another. Get creative! Add sounds, LED effects, time-outs, memory testing (e.g. "Simon"), etc.
For quick reference here is a list of "button-associated" LEDs:
In order to choose a random number between 0 and n, it's enough to simply write
Using the Nod and Tilt joints together (when looking forward) can provide a sort of "zoom" feature, where the AIBO can stretch its neck to get a closer look, or pull back to get an overview.
Write a behavior to subscribe to the sensor information (
You may find the Sensor Observer control (available under Root Control > Status Reports) useful for experimenting with the IR sensor. First select the sensors you want to see from the lower section, and then you can view the values in the Controller itself by selecting "Real-time View".
Dave Touretzky and Ethan Tira-Thompson