Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

PilotTypes.cc

Go to the documentation of this file.
00001 #include "Motion/WalkMC.h"
00002 #ifdef TGT_HAS_WALK
00003 
00004 #include <ostream>
00005 
00006 #include "Crew/Pilot.h"
00007 
00008 namespace DualCoding {
00009 
00010   namespace PilotTypes {
00011 
00012 const char* RequestTypeNames[] = {
00013   "localize",
00014   "walk",
00015   "waypointWalk",
00016   "setVelocity",
00017   "goToShape",
00018   "pushObject",
00019   "visualSearch",
00020   "setOdometry",
00021   "noRequest"
00022 };
00023 
00024 const char* ErrorTypeNames[] = {
00025   "noError",
00026   "someError",
00027   "invalidRequest",
00028   "abort",
00029   "cantLocalize",
00030   "startCollides",
00031   "endCollides",
00032   "noPath",
00033   "noSpace",
00034   "collisionDetected",
00035   "searchFailed"
00036 };
00037 
00038 //================ Navigation plans and steps ================
00039 
00040 std::string NavigationPlan::toString() const {
00041   std::ostringstream os;
00042   os << "Navigation plan (" << steps.size() << " steps):" << std::endl;
00043   std::vector<NavigationStep>::const_iterator stepper = steps.begin();
00044   for ( size_t i=0; i<steps.size(); i++ ) 
00045     os << ( (stepper++ == currentStep ) ? "-> " : "   " )
00046        << steps[i].toString() << std::endl;
00047   return os.str();
00048 }
00049 
00050 void NavigationPlan::addNavigationStep(NavigationStepType_t type, 
00051                const DualCoding::Point &waypoint,
00052                AngTwoPi orientation,
00053                AngSignTwoPi turn,
00054                const std::vector<ShapeRoot> &landmarks) {
00055   NavigationStep step(type, waypoint, orientation, turn);
00056   if ( type == localizeStep )
00057     step.visibleLandmarks = Pilot::calculateVisibleLandmarks(waypoint, orientation, M_PI/2, landmarks);
00058   if ( type != localizeStep || !step.visibleLandmarks.empty() )
00059     steps.push_back(step);
00060 }
00061 
00062 void NavigationPlan::addNavigationStep(NavigationStepType_t type, const NodeValue_t &waypoint,
00063                const std::vector<ShapeRoot> &landmarks) {
00064   addNavigationStep(type,
00065         Point(waypoint.x, waypoint.y, 0, allocentric),
00066         waypoint.theta,
00067         waypoint.turn,
00068         landmarks);
00069 }
00070         
00071 
00072 std::string NavigationStep::toString() const {
00073   std::ostringstream os;
00074   os << "NavigationStep[";
00075   switch (type) {
00076   case localizeStep: os << "localizeStep"; break;
00077   case turnStep: os << "turnStep"; break;
00078   case travelStep: os << "travelStep"; break;
00079   case headingStep: os << "headingStep"; break;
00080   case turnObjStep: os << "turnObjStep"; break;
00081   case acquireObjStep: os << "acquireObjStep"; break;
00082   default:
00083     os << "unknown step type";
00084   }
00085   if ( type == localizeStep ) {
00086     os << ", visible=(";
00087     for (size_t i = 0; i < visibleLandmarks.size(); i++)
00088       os << ( (i>0) ? "," : "")  << visibleLandmarks[i]->getName();
00089     os << ")";
00090   } else if ( type == headingStep || type == turnStep )
00091     os << ", hdg " << float(orientation)*(180/M_PI) << " deg."
00092        << ", turn " << float(turn)*(180/M_PI) << " deg.";
00093   else
00094     os << ", waypoint=" << waypoint;
00095   os << "]";
00096   return os.str();
00097 }
00098 
00099 std::ostream& operator<<(std::ostream& os, const NavigationStep &step) { return os << step.toString(); }
00100 std::ostream& operator<<(std::ostream& os, const NavigationPlan &plan) { return os << plan.toString(); }
00101 
00102 } } // namespaces
00103 
00104 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:46 2016 by Doxygen 1.6.3