HOG2
|
#include <RoboticArm.h>
Public Member Functions | |
RoboticArm (int DOF, double armLength, double tolerance=0.01) | |
virtual | ~RoboticArm () |
double | GetTolerance () const |
void | GetTipPosition (armAngles &s, double &x, double &y) |
int | TipPositionIndex (armAngles &s, const double minX=-1, const double minY=-1, const double width=2) |
void | AddObstacle (line2d obs) |
void | PopObstacle () |
void | GetSuccessors (const armAngles &nodeID, std::vector< armAngles > &neighbors) const |
void | GetActions (const armAngles &nodeID, std::vector< armRotations > &actions) const |
armRotations | GetAction (const armAngles &s1, const armAngles &s2) const |
virtual void | ApplyAction (armAngles &s, armRotations dir) const |
armAngles | GetRandomState () |
virtual bool | InvertAction (armRotations &a) const |
void | AddHeuristic (RoboticArmHeuristic *h) |
virtual double | HCost (const armAngles &) const |
Heuristic value between node and the stored goal. More... | |
virtual double | HCost (const armAngles &node1, const armAngles &node2) const |
Heuristic value between two arbitrary nodes. More... | |
virtual double | GCost (const armAngles &, const armAngles &) const |
virtual double | GCost (const armAngles &, const armRotations &) const |
bool | GoalTest (const armAngles &node, const armAngles &goal) const |
void | GetStateFromHash (uint64_t hash, armAngles &) const |
uint64_t | GetStateHash (const armAngles &node) const |
uint64_t | GetActionHash (armRotations act) const |
virtual void | OpenGLDraw () const |
virtual void | OpenGLDraw (const armAngles &l) const |
virtual void | OpenGLDraw (const armAngles &, const armRotations &) const |
virtual void | OpenGLDraw (const armAngles &, const armAngles &, float) const |
Draw the transition at some percentage 0...1 between two states. More... | |
virtual void | GetNextState (const armAngles ¤ts, armRotations dir, armAngles &news) const |
bool | LegalState (armAngles &a) const |
bool | LegalArmConfig (armAngles &a) const |
void | StoreGoal (armAngles &) |
Stores the goal for use by single-state HCost. More... | |
void | ClearGoal () |
Clears the goal from memory. More... | |
bool | IsGoalStored () const |
virtual bool | GoalTest (const armAngles &) const |
Goal Test if the goal is stored. More... | |
Public Member Functions inherited from SearchEnvironment< armAngles, armRotations > | |
virtual | ~SearchEnvironment () |
virtual int | GetNumSuccessors (const armAngles &stateID) const |
virtual void | UndoAction (armAngles &s, armRotations a) const |
virtual bool | IsGoalStored () const |
Returns true if the goal is stored and false otherwise. More... | |
virtual double | HCost (const armAngles &node1, const armAngles &node2, double parentHCost) const |
virtual uint64_t | GetMaxHash () const |
virtual double | GetPathLength (std::vector< armAngles > &neighbors) |
virtual double | GetPathLength (const armAngles &start, std::vector< armRotations > &neighbors) |
virtual OccupancyInterface< armAngles, armRotations > * | GetOccupancyInfo () |
virtual void | SetOccupancyInfo (OccupancyInterface< armAngles, armRotations > *) |
virtual void | OpenGLDraw () const |
virtual void | GLLabelState (const armAngles &, const char *) const |
virtual void | GLDrawLine (const armAngles &x, const armAngles &y) const |
virtual void | GLDrawPath (const std::vector< armAngles > &x) const |
virtual void | SetColor (const rgbColor &r) const |
virtual void | SetColor (GLfloat rr, GLfloat g, GLfloat b, GLfloat t=1.0) const |
virtual void | GetColor (GLfloat &rr, GLfloat &g, GLfloat &b, GLfloat &t) const |
virtual rgbColor | GetColor () const |
virtual void | Draw (Graphics::Display &display) const |
virtual void | Draw (Graphics::Display &display, const armAngles &) const |
virtual void | DrawLine (Graphics::Display &display, const armAngles &x, const armAngles &y, float width=1.0) const |
Public Member Functions inherited from Heuristic< armAngles > | |
Heuristic () | |
virtual | ~Heuristic () |
Private Member Functions | |
void | DrawLine (line2d l) const |
void | GenerateLineSegments (const armAngles &a, std::vector< line2d > &armSegments) const |
double | GetSin (int angle) const |
double | GetCos (int angle) const |
void | BuildSinCosTables () |
Private Attributes | |
int | DOF |
double | armLength |
double | tolerance |
std::vector< std::vector< bool > > | legals |
std::vector< double > | sinTable |
std::vector< double > | cosTable |
std::vector< line2d > | obstacles |
std::vector< line2d > | armSegments |
std::vector< recVec > | states |
std::vector< RoboticArmHeuristic * > | heuristics |
ConfigEnvironment * | ce |
Additional Inherited Members | |
Public Attributes inherited from Heuristic< armAngles > | |
std::vector< HeuristicTreeNode > | lookups |
std::vector< Heuristic * > | heuristics |
uint64_t | histogram [256] |
Protected Attributes inherited from SearchEnvironment< armAngles, armRotations > | |
bool | bValidSearchGoal |
armAngles | searchGoal |
rgbColor | color |
GLfloat | transparency |
Definition at line 88 of file RoboticArm.h.
RoboticArm::RoboticArm | ( | int | DOF, |
double | armLength, | ||
double | tolerance = 0.01 |
||
) |
Definition at line 96 of file RoboticArm.cpp.
References BuildSinCosTables(), and ce.
|
virtual |
Definition at line 103 of file RoboticArm.cpp.
References ce.
|
inline |
Definition at line 110 of file RoboticArm.h.
References heuristics.
void RoboticArm::AddObstacle | ( | line2d | obs | ) |
Definition at line 247 of file RoboticArm.cpp.
References ConfigEnvironment::AddObstacle(), ce, and obstacles.
|
virtual |
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 229 of file RoboticArm.cpp.
References armAngles::GetAngle(), armAngles::GetNumArms(), armRotations::GetRotation(), and armAngles::SetAngle().
Referenced by ArmToTipHeuristic::GenerateHeuristicSub(), ArmToTipHeuristic::GenerateNextDepth(), ArmToTipHeuristic::GenerateTipPositionTables(), GetActions(), GetNextState(), and GetSuccessors().
|
private |
Definition at line 589 of file RoboticArm.cpp.
References cosTable, sinTable, and TWOPI.
Referenced by RoboticArm().
|
inlinevirtual |
Clears the goal from memory.
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 138 of file RoboticArm.h.
|
private |
Definition at line 479 of file RoboticArm.cpp.
References line2d::end, line2d::start, recVec::x, and recVec::y.
Referenced by OpenGLDraw().
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 118 of file RoboticArm.h.
|
inlinevirtual |
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 119 of file RoboticArm.h.
|
private |
Definition at line 542 of file RoboticArm.cpp.
References armLength, armAngles::GetAngle(), GetCos(), armAngles::GetNumArms(), GetSin(), recVec::x, recVec::y, and recVec::z.
Referenced by GetTipPosition(), GoalTest(), HCost(), LegalArmConfig(), LegalState(), and OpenGLDraw().
|
virtual |
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 219 of file RoboticArm.cpp.
References armAngles::GetAngle(), armAngles::GetNumArms(), and armRotations::SetRotation().
|
virtual |
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 399 of file RoboticArm.cpp.
References armRotations::rotations.
|
virtual |
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 177 of file RoboticArm.cpp.
References ApplyAction(), armAngles::GetNumArms(), kRotateCCW, kRotateCW, LegalState(), and armRotations::SetRotation().
Referenced by ArmToTipHeuristic::GenerateNextDepth().
|
private |
Definition at line 584 of file RoboticArm.cpp.
References cosTable.
Referenced by GenerateLineSegments().
|
virtual |
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 489 of file RoboticArm.cpp.
References ApplyAction().
armAngles RoboticArm::GetRandomState | ( | ) |
Definition at line 264 of file RoboticArm.cpp.
References DOF, armAngles::SetAngle(), and armAngles::SetNumArms().
Referenced by ArmToArmHeuristic::SelectStartNode().
|
private |
Definition at line 579 of file RoboticArm.cpp.
References sinTable.
Referenced by GenerateLineSegments().
|
virtual |
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 390 of file RoboticArm.cpp.
References armAngles::GetNumArms(), and armAngles::SetAngle().
Referenced by ArmToArmCompressedHeuristic::BuildHeuristic(), and ArmToArmCompressedHeuristic::SetupGoal().
|
virtual |
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 379 of file RoboticArm.cpp.
Referenced by ArmToArmHeuristic::AddDiffTable(), ArmToArmHeuristic::GenerateLegalStates(), ArmToArmHeuristic::HCost(), ArmToArmHeuristic::IsLegalState(), and ArmToArmHeuristic::SelectStartNode().
|
virtual |
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 133 of file RoboticArm.cpp.
References ApplyAction(), armAngles::GetNumArms(), kNoRotation, kRotateCCW, kRotateCW, LegalState(), and armRotations::SetRotation().
Referenced by ArmToArmHeuristic::AddDiffTable(), ArmToArmHeuristic::GenerateLegalStates(), and ArmToArmHeuristic::SelectStartNode().
void RoboticArm::GetTipPosition | ( | armAngles & | s, |
double & | x, | ||
double & | y | ||
) |
Definition at line 108 of file RoboticArm.cpp.
References GenerateLineSegments(), recVec::x, and recVec::y.
Referenced by ArmToArmHeuristic::GenerateLegalStates(), ArmToTipHeuristic::GenerateMaxDistHeuristics(), ArmToTipHeuristic::GenerateTipPositionTables(), TipPositionIndex(), and ArmToTipHeuristic::UpdateTipDistances().
|
inline |
Definition at line 94 of file RoboticArm.h.
References tolerance.
Referenced by ArmToTipHeuristic::NumTipPositionIndices(), TipPositionIndex(), ArmToArmHeuristic::TipPositionIndex(), ArmToTipHeuristic::TipPositionIndex(), ArmToTipHeuristic::UseHeuristic(), and ArmToTipHeuristic::ValidGoalPosition().
|
inlinevirtual |
Goal Test if the goal is stored.
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 140 of file RoboticArm.h.
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 362 of file RoboticArm.cpp.
References armSegments, GenerateLineSegments(), armAngles::GetGoal(), armAngles::IsGoalState(), tolerance, recVec::x, and recVec::y.
Referenced by ArmToTipHeuristic::GenerateHeuristicSub().
|
inlinevirtual |
Heuristic value between node and the stored goal.
Asserts that the goal is stored
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 112 of file RoboticArm.h.
Referenced by HCost().
Heuristic value between two arbitrary nodes.
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 273 of file RoboticArm.cpp.
References armLength, armSegments, ce, GenerateLineSegments(), armAngles::GetAngle(), armAngles::GetGoal(), armAngles::GetNumArms(), TemplateAStar< state, action, environment, openList >::GetPath(), SearchEnvironment< state, action >::GetPathLength(), HCost(), heuristics, armAngles::IsGoalState(), max, states, ConfigEnvironment::StoreGoal(), TWOPI, recVec::x, and recVec::y.
|
virtual |
Implements SearchEnvironment< armAngles, armRotations >.
Definition at line 239 of file RoboticArm.cpp.
References armRotations::GetRotation(), and armRotations::SetRotation().
|
inline |
Definition at line 139 of file RoboticArm.h.
bool RoboticArm::LegalArmConfig | ( | armAngles & | a | ) | const |
Definition at line 525 of file RoboticArm.cpp.
References armSegments, GenerateLineSegments(), and armAngles::GetAngle().
Referenced by ArmToTipHeuristic::GenerateCPDB().
bool RoboticArm::LegalState | ( | armAngles & | a | ) | const |
Definition at line 495 of file RoboticArm.cpp.
References armSegments, GenerateLineSegments(), armAngles::GetAngle(), and obstacles.
Referenced by ArmToTipHeuristic::GenerateHeuristicSub(), ArmToTipHeuristic::GenerateTipPositionTables(), GetActions(), and GetSuccessors().
|
virtual |
Definition at line 404 of file RoboticArm.cpp.
References DrawLine(), and obstacles.
|
inlinevirtual |
Draw the transition at some percentage 0...1 between two states.
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 128 of file RoboticArm.h.
|
virtual |
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 467 of file RoboticArm.cpp.
|
virtual |
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 426 of file RoboticArm.cpp.
References armSegments, DrawLine(), GenerateLineSegments(), armAngles::GetGoal(), armAngles::IsGoalState(), tolerance, recVec::x, recVec::y, and recVec::z.
void RoboticArm::PopObstacle | ( | ) |
Definition at line 255 of file RoboticArm.cpp.
References ce, obstacles, and ConfigEnvironment::PopObstacle().
|
inlinevirtual |
Stores the goal for use by single-state HCost.
Reimplemented from SearchEnvironment< armAngles, armRotations >.
Definition at line 137 of file RoboticArm.h.
int RoboticArm::TipPositionIndex | ( | armAngles & | s, |
const double | minX = -1 , |
||
const double | minY = -1 , |
||
const double | width = 2 |
||
) |
Definition at line 117 of file RoboticArm.cpp.
References GetTipPosition(), GetTolerance(), and width.
|
private |
Definition at line 149 of file RoboticArm.h.
Referenced by GenerateLineSegments(), and HCost().
|
mutableprivate |
Definition at line 158 of file RoboticArm.h.
Referenced by GoalTest(), HCost(), LegalArmConfig(), LegalState(), and OpenGLDraw().
|
private |
Definition at line 163 of file RoboticArm.h.
Referenced by AddObstacle(), HCost(), PopObstacle(), RoboticArm(), and ~RoboticArm().
|
private |
Definition at line 156 of file RoboticArm.h.
Referenced by BuildSinCosTables(), and GetCos().
|
private |
Definition at line 148 of file RoboticArm.h.
Referenced by GetRandomState().
|
private |
Definition at line 162 of file RoboticArm.h.
Referenced by AddHeuristic(), and HCost().
|
private |
Definition at line 150 of file RoboticArm.h.
|
private |
Definition at line 157 of file RoboticArm.h.
Referenced by AddObstacle(), LegalState(), OpenGLDraw(), and PopObstacle().
|
private |
Definition at line 155 of file RoboticArm.h.
Referenced by BuildSinCosTables(), and GetSin().
|
mutableprivate |
Definition at line 160 of file RoboticArm.h.
Referenced by HCost().
|
private |
Definition at line 149 of file RoboticArm.h.
Referenced by GetTolerance(), GoalTest(), and OpenGLDraw().