Skip to content

Commit

Permalink
Going back to Obstacle Avoidance within behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
aligot committed Aug 31, 2018
1 parent e41d2a4 commit f905b36
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/core/AutoMoDeBehaviorTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace argos {
* However, not all conditions have been tested if the pervious RUNNING branch is not the first (left) branch
*/
if ((m_eTreeStatus == Node::SUCCESS) || (m_eTreeStatus == Node::FAILURE)) {
//LOG << "STOP" << std::endl;
LOG << "STOP" << std::endl;
m_pcRobotDAO->SetWheelsVelocity(0.0, 0.0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/bt/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace argos {
eCurrentState = Node::SUCCESS;
} else {
//LOG << "---> Running" << std::endl;
//LOG << "[" << m_pcBehaviour->LogRobotIdientifier() << "] " << m_strLabel << m_strBranchId << " (" << m_pcBehaviour->GetLabel() << ")" << std::endl;
//LOG << "[" << m_pcBehaviour->LogRobotIdientifier() << "] " << m_strLabel << m_strBranchId << " (" << m_pcBehaviour->GetLabel() << ") " << m_pcBehaviour->GetSuccessProbability() << std::endl;
m_pcBehaviour->ControlStep();
eCurrentState = Node::RUNNING;
}
Expand Down
7 changes: 7 additions & 0 deletions src/modules/AutoMoDeBehaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,11 @@ namespace argos {
return m_pcRobotDAO->GetRandomNumberGenerator()->Bernoulli(f_probability);
}

/****************************************/
/****************************************/

Real AutoMoDeBehaviour::GetSuccessProbability() const {
return m_fSuccessProbabilityParameter;
}

}
6 changes: 5 additions & 1 deletion src/modules/AutoMoDeBehaviour.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ namespace argos {
*/
EpuckDAO* m_pcRobotDAO;

Real m_fSuccessProbabilityParameter;

public:

virtual ~AutoMoDeBehaviour();
Expand Down Expand Up @@ -191,9 +193,11 @@ namespace argos {

bool EvaluateBernoulliProbability(const Real& f_probability) const;

Real GetSuccessProbability() const;

/* Debug functions */

UInt32 LogRobotIdientifier() {
UInt32 LogRobotIdientifier() {
return m_pcRobotDAO->GetRobotIdentifier();
};
};
Expand Down
17 changes: 10 additions & 7 deletions src/modules/AutoMoDeBehaviourAntiPhototaxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ namespace argos {

sLightVector = CVector2(cLightReading.Value, cLightReading.Angle);

// LOG << cLightReading.Value << " " << cLightReading.Angle << std::endl;
// LOG << sLightVector << std::endl;

if (sLightVector.Length() < 0.1) {
sLightVector = CVector2(1.0, CRadians::ZERO);
// Obstacle avoidance
CVector2 sDirectionVector(0,CRadians::ZERO);
CVector2 sProxVector(0,CRadians::ZERO);
sProxVector = CVector2(m_pcRobotDAO->GetProximityReading().Value, m_pcRobotDAO->GetProximityReading().Angle);
sDirectionVector = -sLightVector - 5*sProxVector;

if (sDirectionVector.Length() < 0.1) {
sDirectionVector = CVector2(1.0, CRadians::ZERO);
}

m_pcRobotDAO->SetWheelsVelocity(ComputeWheelsVelocityFromVector(-sLightVector));
m_pcRobotDAO->SetWheelsVelocity(ComputeWheelsVelocityFromVector(sDirectionVector));

m_bLocked = false;
}
Expand Down Expand Up @@ -108,6 +111,6 @@ namespace argos {
/****************************************/

bool AutoMoDeBehaviourAntiPhototaxis::Failed() {
return (ObstacleInFront() || !LightPerceived());
return false; //(ObstacleInFront() || !LightPerceived());
}
}
1 change: 0 additions & 1 deletion src/modules/AutoMoDeBehaviourAntiPhototaxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace argos {
virtual bool Failed();

private:
Real m_fSuccessProbabilityParameter;

};
}
Expand Down
19 changes: 10 additions & 9 deletions src/modules/AutoMoDeBehaviourAttraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,17 @@ namespace argos {
sRabVector = CVector2(cRabReading.Range, cRabReading.Bearing);
}

// LOG << "[" << m_pcRobotDAO->GetRobotIdentifier() << "] " << cRabReading.Range << " " << cRabReading.Bearing << std::endl;
// LOG << "[" << m_pcRobotDAO->GetRobotIdentifier() << "] " << sRabVector << std::endl;

if (sRabVector.Length() < 0.1) {
sRabVector = CVector2(1.0, CRadians::ZERO);
// Obstacle avoidance
CVector2 sDirectionVector(0,CRadians::ZERO);
CVector2 sProxVector(0,CRadians::ZERO);
sProxVector = CVector2(m_pcRobotDAO->GetProximityReading().Value, m_pcRobotDAO->GetProximityReading().Angle);
sDirectionVector = sRabVector - 6*sProxVector;

if (sDirectionVector.Length() < 0.1) {
sDirectionVector = CVector2(1.0, CRadians::ZERO);
}

LOG << "[" << m_pcRobotDAO->GetRobotIdentifier() << "] " << sRabVector << std::endl;

m_pcRobotDAO->SetWheelsVelocity(ComputeWheelsVelocityFromVector(sRabVector));
m_pcRobotDAO->SetWheelsVelocity(ComputeWheelsVelocityFromVector(sDirectionVector));

m_bLocked = false;
}
Expand Down Expand Up @@ -121,6 +122,6 @@ namespace argos {
/****************************************/

bool AutoMoDeBehaviourAttraction::Failed() {
return (ObstacleInFront() || (m_pcRobotDAO->GetNumberNeighbors() == 0));
return false; // (ObstacleInFront() || (m_pcRobotDAO->GetNumberNeighbors() == 0));
}
}
1 change: 0 additions & 1 deletion src/modules/AutoMoDeBehaviourAttraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace argos {

private:
UInt8 m_unAttractionParameter;
Real m_fSuccessProbabilityParameter;
};
}

Expand Down
1 change: 0 additions & 1 deletion src/modules/AutoMoDeBehaviourCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace argos {
virtual bool Failed();

private:
Real m_fSuccessProbabilityParameter;
Real m_fRadiusParameter;

enum CurveState {
Expand Down
1 change: 0 additions & 1 deletion src/modules/AutoMoDeBehaviourExploration.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ namespace argos {

Real m_fProximityThreshold;
CRange<UInt32> m_cRandomStepsRange;
Real m_fSuccessProbabilityParameter;
};
}

Expand Down
17 changes: 10 additions & 7 deletions src/modules/AutoMoDeBehaviourPhototaxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ namespace argos {

sLightVector = CVector2(cLightReading.Value, cLightReading.Angle);

// LOG << cLightReading.Value << " " << cLightReading.Angle << std::endl;
// LOG << sLightVector << std::endl;

if (sLightVector.Length() < 0.1) {
sLightVector = CVector2(1.0, CRadians::ZERO);
// Obstacle avoidance
CVector2 sDirectionVector(0,CRadians::ZERO);
CVector2 sProxVector(0,CRadians::ZERO);
sProxVector = CVector2(m_pcRobotDAO->GetProximityReading().Value, m_pcRobotDAO->GetProximityReading().Angle);
sDirectionVector = sLightVector - 5*sProxVector;;

if (sDirectionVector.Length() < 0.1) {
sDirectionVector = CVector2(1.0, CRadians::ZERO);
}

m_pcRobotDAO->SetWheelsVelocity(ComputeWheelsVelocityFromVector(sLightVector));
m_pcRobotDAO->SetWheelsVelocity(ComputeWheelsVelocityFromVector(sDirectionVector));

m_bLocked = false;
}
Expand Down Expand Up @@ -106,6 +109,6 @@ namespace argos {
/****************************************/

bool AutoMoDeBehaviourPhototaxis::Failed() {
return (ObstacleInFront() || !LightPerceived());
return false; //(ObstacleInFront() || !LightPerceived());
}
}
1 change: 0 additions & 1 deletion src/modules/AutoMoDeBehaviourPhototaxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace argos {
virtual bool Failed();

private:
Real m_fSuccessProbabilityParameter;

};
}
Expand Down
14 changes: 10 additions & 4 deletions src/modules/AutoMoDeBehaviourRepulsion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,17 @@ namespace argos {
sRabVector = CVector2(cRabReading.Range, cRabReading.Bearing);
}

if (sRabVector.Length() < 0.1) {
sRabVector = CVector2(1.0, CRadians::ZERO);
CVector2 sDirectionVector(0,CRadians::ZERO);
CVector2 sProxVector(0,CRadians::ZERO);
sProxVector = CVector2(m_pcRobotDAO->GetProximityReading().Value, m_pcRobotDAO->GetProximityReading().Angle);
sDirectionVector = -sRabVector - 5*sProxVector;;


if (sDirectionVector.Length() < 0.1) {
sDirectionVector = CVector2(1.0, CRadians::ZERO);
}

m_pcRobotDAO->SetWheelsVelocity(ComputeWheelsVelocityFromVector(-sRabVector));
m_pcRobotDAO->SetWheelsVelocity(ComputeWheelsVelocityFromVector(sDirectionVector));

m_bLocked = false;
}
Expand Down Expand Up @@ -117,6 +123,6 @@ namespace argos {
/****************************************/

bool AutoMoDeBehaviourRepulsion::Failed() {
return ObstacleInFront();
return false; //ObstacleInFront();
}
}
1 change: 0 additions & 1 deletion src/modules/AutoMoDeBehaviourRepulsion.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace argos {

private:
UInt8 m_unRepulsionParameter;
Real m_fSuccessProbabilityParameter;

};
}
Expand Down
1 change: 0 additions & 1 deletion src/modules/AutoMoDeBehaviourRotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace argos {
virtual bool Failed();

private:
Real m_fSuccessProbabilityParameter;

enum RotationState {
IDLE, LEFT, RIGHT
Expand Down
1 change: 0 additions & 1 deletion src/modules/AutoMoDeBehaviourStop.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace argos {
virtual bool Failed();

private:
Real m_fSuccessProbabilityParameter;
};
}

Expand Down
1 change: 0 additions & 1 deletion src/modules/AutoMoDeBehaviourStraight.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace argos {
virtual bool Failed();

private:
Real m_fSuccessProbabilityParameter;
};
}

Expand Down

0 comments on commit f905b36

Please sign in to comment.