230 likes | 366 Views
The P3DX, Custom Dock and ActivMedia Robot Programming Tools. Adam Milstein. ARIA/Saphira. Mid level control system for robot. Handles communication, multitasking, display, hardware. Provides architecture for quickly writing robot control programs.
E N D
The P3DX, Custom Dock and ActivMedia Robot Programming Tools Adam Milstein
ARIA/Saphira • Mid level control system for robot. • Handles communication, multitasking, display, hardware. • Provides architecture for quickly writing robot control programs. • Provides enough depth to access all functions. • Also contains systems for high level control of the robot.
ARIA • Low to mid level control systems. • Establishes and maintains connection to robot and other hardware • Stores data from sensors and provides accessor methods • Provides control methods on the order of speed and direction. • Resolver for running multiple tasks controlling the robot.
Behaviours • ArAction subclasses, once started, are called every cycle and return a desired velocity and heading for the robot. • Must be a short algorithm to determine the return values. • Each ArAction runs at a priority and on each iteration returns its desired action with a strength between 1.0 and 0. • Starting at the highest priority. • Computes average of all motion requests, weighted by strength. • Any leftover strength (is sum < 1.0) is given to the next lower priority level. • ArActions can be disabled or enabled individually at various priorities.
ArActionDesired *ActionGo::fire(ArActionDesired currentDesired) { double range; double speed; // reset the actionDesired (must be done) myDesired.reset(); // if the sonar is null we can't do anything, so deactivate if (mySonar == NULL) { deactivate(); return NULL; } // get the range off the sonar range = mySonar->currentReadingPolar(-70, 70) - myRobot->getRobotRadius(); // if the range is greater than the stop distance, find some speed to go if (range > myStopDistance) { // just an arbitrary speed based on the range speed = range * .3; // if that speed is greater than our max, cap it if (speed > myMaxSpeed) speed = myMaxSpeed; // now set the velocity myDesired.setVel(speed); // the range was less than the stop distance, so just stop } else { myDesired.setVel(0); } // return a pointer to the actionDesired, so resolver knows what to do return &myDesired; }
Task • Tasks are called every cycle, but they are only run for their share of the available time • Used for long term processing, such as localization or path planning. • Use ArASyncTask, ArRecurrentTask, or SfUTask • ArASyncTask: invoked and keeps running • ArRecurrentTask: has a method to restart once it ends, used for long running but finite computation that must be repeated • SfUTask: Saphira wrapper for task called every cycle.
void myAsyncTask::task() { // main task we are doing while (counter <= end) { // print N times, once per second sfMessage("Async task counter: %d", counter++); ArUtil::sleep(1000); lock(); // lock out the sync loop, so we can change values if (myproc) myproc->counter = 0; unlock(); // unlock and go } sfMessage("Async computation finished"); } void myProcess::process() { if (Done()) { sfMessage("Async task done, suspending uTask"); suspendTask(); } else sfMessage("uTask at %d", counter++); }
ArRobot • Get information from the robot and send direct commands • setVel, setHeading, move, comInt, … • Also findRangeDevice to get a particular sensor • Then Current/CumulativeReadingPolar/Box • Returns the closest sensor reading in a box or sector in relative position to the robot • ClearDirectMotion enables behaviours and clears direct motion commands • …
Behaviours vs. Direct Motion • 2 methods of controlling the robot. • But incompatible. • Using direct motion commands disables behaviours • Behaviours will still run, but will have no effect on the robot. • Use ClearDirectMotion() to reenable behaviours • Don’t mix them
Saphira • Graphical interface on top of Aria • Adds methods for connecting to the robot • Manual control • Structure for writing control programs and running them together and interactively. • Provides a simulator to test programs without using the robot. • The LPS display!
Convenience Variables • SfROBOT : an instance of SfRobot which subclasses ArRobot. Points to the actual robot. • Sf::sonar() : An SfRangeDevice, to get the sonar readings. Sf::sonar()->ourRangeDevice->currentReadingBox(…) • Sf::laser() : Another SfRangeDevice. • Sf::frame : More useful than you might think. Don’t forget it exists if you are using the LPS for keyboard/mouse events.
LPS • Local perceptual space • Saphira’s graphical display • Shows robot position, sensor readings, walls, and anything else. • Any class which extends SfArtifact will have its draw method called on every graphics update. • Can also read mouse and keyboard for interface. • Provides keyboard control of robot. • Text output window for the sfMessage function
C++ • Any function written in C++ can be made available to the Saphira interactive language, Colbert. • All ARIA functionality can be used in the C++ code, and exported if necessary • Code is build into a special dll. • Dlls can be loaded from saphira. • sfLoadInit performs initialization. • A dll can declare its functions, variables, and behaviours available to the Saphira command line. • In Windows, must use Studio.Net • Include Saphira.h, export.h and link Sf.lib and Aria.lib • For Linux, you’re on your own.
Colbert • Saphira’s interactive language. • Uses a C like syntax. • No dynamic allocation. • Can load libraries, other colbert .act files, world maps • Can call any exported functions, change exported variables, start and stop actions, call direct motion commands. • Colbert .act files can contain any colbert commands together with behaviours that can be used as normal.
loadlib testload; // need this for sfStalledMotor() def int MOVEVAL; MOVEVAL = 250; int BACKVAL; BACKVAL = 200; int TURNDEG; TURNDEG = 40; act getout(int dist, int turnDeg) { if (sfStalledMotor(sfLEFT)) turnDeg = -turnDeg; turn (turnDeg) timeout 10; // just in case, we timeout move(dist) timeout 10; behaviors; // resume behavioral actions succeed; } act bng() { while(1) { waitfor(sfStalledMotor(sfLEFT) || sfStalledMotor(sfRIGHT)); remove getout; // halt this activity if it's going stop(); // stop the robot move (-BACKVAL) timeout 30; // just in case, we timeout here start getout(MOVEVAL, TURNDEG) noblock; } } start bng; trace bng;
Pioneer Simulator • Provides a simulated robot and reports slightly incorrect data back to Saphira. • Can import a map so that it can report sensor readings. • The first iteration of any program will drive the robot at full speed into the wall, so it’s useful to use the simulator until the code works. • Only provides sonar, but the code is available in case you need more simulation.
Modules • Localization: Localizes the robot using any available sensors on either a scan map or a line map. • Gradient navigation: Creates a path for the robot between 2 points within the map and avoids obstacles detected by the sensors. • These modules can run on there own, controlled through the LPS, or they can be integrated into other modules
Extra Libraries • Laser Mapping and Navigation: ARIA and utility programs to record laser readings and use them to generate a map. Then navigate on that map. • ArSpeech: Speech recognition and synthesis • VisLib: a vision processing library • ACTS: a blob tracker
Documentation • C:\Program Files\Saphira\docs • Saphira-Reference.html • Aria-Reference\main.html • The best Saphira documentation is the header files.
The Dock • Connect power to correct ports. • Switches for arms. • Bypass cables • Contact plate • LEDs • Charger problems!
Details • Camera: see me for instructions, I’ve been working on it for 2 years, you don’t want to reproduce it. • Matlab can be called from C++ • The program must be a Saphira Dll. • Speech synthesis works, recognition needs a better mike. • Talk to me about what you want to do, Aria/Saphira is powerful if you can find what you’re looking for.
Example • An example docking behaviour. • Note: ArAction, laser, voltage, SfArtifact, functions