HOG2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
RoboticArm Class Reference

#include <RoboticArm.h>

Inheritance diagram for RoboticArm:
Inheritance graph
[legend]
Collaboration diagram for RoboticArm:
Collaboration graph
[legend]

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 &currents, 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< line2dobstacles
 
std::vector< line2darmSegments
 
std::vector< recVecstates
 
std::vector< RoboticArmHeuristic * > heuristics
 
ConfigEnvironmentce
 

Additional Inherited Members

- Public Attributes inherited from Heuristic< armAngles >
std::vector< HeuristicTreeNodelookups
 
std::vector< Heuristic * > heuristics
 
uint64_t histogram [256]
 
- Protected Attributes inherited from SearchEnvironment< armAngles, armRotations >
bool bValidSearchGoal
 
armAngles searchGoal
 
rgbColor color
 
GLfloat transparency
 

Detailed Description

Definition at line 88 of file RoboticArm.h.

Constructor & Destructor Documentation

◆ RoboticArm()

RoboticArm::RoboticArm ( int  DOF,
double  armLength,
double  tolerance = 0.01 
)

Definition at line 96 of file RoboticArm.cpp.

References BuildSinCosTables(), and ce.

◆ ~RoboticArm()

RoboticArm::~RoboticArm ( )
virtual

Definition at line 103 of file RoboticArm.cpp.

References ce.

Member Function Documentation

◆ AddHeuristic()

void RoboticArm::AddHeuristic ( RoboticArmHeuristic h)
inline

Definition at line 110 of file RoboticArm.h.

References heuristics.

◆ AddObstacle()

void RoboticArm::AddObstacle ( line2d  obs)

Definition at line 247 of file RoboticArm.cpp.

References ConfigEnvironment::AddObstacle(), ce, and obstacles.

◆ ApplyAction()

void RoboticArm::ApplyAction ( armAngles s,
armRotations  dir 
) const
virtual

◆ BuildSinCosTables()

void RoboticArm::BuildSinCosTables ( )
private

Definition at line 589 of file RoboticArm.cpp.

References cosTable, sinTable, and TWOPI.

Referenced by RoboticArm().

◆ ClearGoal()

void RoboticArm::ClearGoal ( )
inlinevirtual

Clears the goal from memory.

Reimplemented from SearchEnvironment< armAngles, armRotations >.

Definition at line 138 of file RoboticArm.h.

◆ DrawLine()

void RoboticArm::DrawLine ( line2d  l) const
private

Definition at line 479 of file RoboticArm.cpp.

References line2d::end, line2d::start, recVec::x, and recVec::y.

Referenced by OpenGLDraw().

◆ GCost() [1/2]

virtual double RoboticArm::GCost ( const armAngles ,
const armAngles  
) const
inlinevirtual

Implements SearchEnvironment< armAngles, armRotations >.

Definition at line 118 of file RoboticArm.h.

◆ GCost() [2/2]

virtual double RoboticArm::GCost ( const armAngles ,
const armRotations  
) const
inlinevirtual

Implements SearchEnvironment< armAngles, armRotations >.

Definition at line 119 of file RoboticArm.h.

◆ GenerateLineSegments()

void RoboticArm::GenerateLineSegments ( const armAngles a,
std::vector< line2d > &  armSegments 
) const
private

◆ GetAction()

armRotations RoboticArm::GetAction ( const armAngles s1,
const armAngles s2 
) const
virtual

◆ GetActionHash()

uint64_t RoboticArm::GetActionHash ( armRotations  act) const
virtual

Implements SearchEnvironment< armAngles, armRotations >.

Definition at line 399 of file RoboticArm.cpp.

References armRotations::rotations.

◆ GetActions()

void RoboticArm::GetActions ( const armAngles nodeID,
std::vector< armRotations > &  actions 
) const
virtual

◆ GetCos()

double RoboticArm::GetCos ( int  angle) const
private

Definition at line 584 of file RoboticArm.cpp.

References cosTable.

Referenced by GenerateLineSegments().

◆ GetNextState()

void RoboticArm::GetNextState ( const armAngles currents,
armRotations  dir,
armAngles news 
) const
virtual

Reimplemented from SearchEnvironment< armAngles, armRotations >.

Definition at line 489 of file RoboticArm.cpp.

References ApplyAction().

◆ GetRandomState()

armAngles RoboticArm::GetRandomState ( )

Definition at line 264 of file RoboticArm.cpp.

References DOF, armAngles::SetAngle(), and armAngles::SetNumArms().

Referenced by ArmToArmHeuristic::SelectStartNode().

◆ GetSin()

double RoboticArm::GetSin ( int  angle) const
private

Definition at line 579 of file RoboticArm.cpp.

References sinTable.

Referenced by GenerateLineSegments().

◆ GetStateFromHash()

void RoboticArm::GetStateFromHash ( uint64_t  hash,
armAngles a 
) const
virtual

◆ GetStateHash()

uint64_t RoboticArm::GetStateHash ( const armAngles node) const
virtual

◆ GetSuccessors()

void RoboticArm::GetSuccessors ( const armAngles nodeID,
std::vector< armAngles > &  neighbors 
) const
virtual

◆ GetTipPosition()

void RoboticArm::GetTipPosition ( armAngles s,
double &  x,
double &  y 
)

◆ GetTolerance()

double RoboticArm::GetTolerance ( ) const
inline

◆ GoalTest() [1/2]

virtual bool RoboticArm::GoalTest ( const armAngles node) const
inlinevirtual

Goal Test if the goal is stored.

Reimplemented from SearchEnvironment< armAngles, armRotations >.

Definition at line 140 of file RoboticArm.h.

◆ GoalTest() [2/2]

bool RoboticArm::GoalTest ( const armAngles node,
const armAngles goal 
) const
virtual

◆ HCost() [1/2]

virtual double RoboticArm::HCost ( const armAngles node) const
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().

◆ HCost() [2/2]

double RoboticArm::HCost ( const armAngles node1,
const armAngles node2 
) const
virtual

◆ InvertAction()

bool RoboticArm::InvertAction ( armRotations a) const
virtual

◆ IsGoalStored()

bool RoboticArm::IsGoalStored ( ) const
inline

Definition at line 139 of file RoboticArm.h.

◆ LegalArmConfig()

bool RoboticArm::LegalArmConfig ( armAngles a) const

◆ LegalState()

bool RoboticArm::LegalState ( armAngles a) const

◆ OpenGLDraw() [1/4]

void RoboticArm::OpenGLDraw ( ) const
virtual

Definition at line 404 of file RoboticArm.cpp.

References DrawLine(), and obstacles.

◆ OpenGLDraw() [2/4]

virtual void RoboticArm::OpenGLDraw ( const armAngles ,
const armAngles ,
float   
) const
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.

◆ OpenGLDraw() [3/4]

void RoboticArm::OpenGLDraw ( const armAngles ,
const armRotations  
) const
virtual

Reimplemented from SearchEnvironment< armAngles, armRotations >.

Definition at line 467 of file RoboticArm.cpp.

◆ OpenGLDraw() [4/4]

void RoboticArm::OpenGLDraw ( const armAngles l) const
virtual

◆ PopObstacle()

void RoboticArm::PopObstacle ( )

Definition at line 255 of file RoboticArm.cpp.

References ce, obstacles, and ConfigEnvironment::PopObstacle().

◆ StoreGoal()

void RoboticArm::StoreGoal ( armAngles s)
inlinevirtual

Stores the goal for use by single-state HCost.

Reimplemented from SearchEnvironment< armAngles, armRotations >.

Definition at line 137 of file RoboticArm.h.

◆ TipPositionIndex()

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.

Member Data Documentation

◆ armLength

double RoboticArm::armLength
private

Definition at line 149 of file RoboticArm.h.

Referenced by GenerateLineSegments(), and HCost().

◆ armSegments

std::vector<line2d> RoboticArm::armSegments
mutableprivate

Definition at line 158 of file RoboticArm.h.

Referenced by GoalTest(), HCost(), LegalArmConfig(), LegalState(), and OpenGLDraw().

◆ ce

ConfigEnvironment* RoboticArm::ce
private

Definition at line 163 of file RoboticArm.h.

Referenced by AddObstacle(), HCost(), PopObstacle(), RoboticArm(), and ~RoboticArm().

◆ cosTable

std::vector<double> RoboticArm::cosTable
private

Definition at line 156 of file RoboticArm.h.

Referenced by BuildSinCosTables(), and GetCos().

◆ DOF

int RoboticArm::DOF
private

Definition at line 148 of file RoboticArm.h.

Referenced by GetRandomState().

◆ heuristics

std::vector<RoboticArmHeuristic *> RoboticArm::heuristics
private

Definition at line 162 of file RoboticArm.h.

Referenced by AddHeuristic(), and HCost().

◆ legals

std::vector<std::vector<bool> > RoboticArm::legals
private

Definition at line 150 of file RoboticArm.h.

◆ obstacles

std::vector<line2d> RoboticArm::obstacles
private

Definition at line 157 of file RoboticArm.h.

Referenced by AddObstacle(), LegalState(), OpenGLDraw(), and PopObstacle().

◆ sinTable

std::vector<double> RoboticArm::sinTable
private

Definition at line 155 of file RoboticArm.h.

Referenced by BuildSinCosTables(), and GetSin().

◆ states

std::vector<recVec> RoboticArm::states
mutableprivate

Definition at line 160 of file RoboticArm.h.

Referenced by HCost().

◆ tolerance

double RoboticArm::tolerance
private

Definition at line 149 of file RoboticArm.h.

Referenced by GetTolerance(), GoalTest(), and OpenGLDraw().


The documentation for this class was generated from the following files: