Skip to content

Commit

Permalink
[yarprobotinterface] Add a "run" phase that does not accept actions
Browse files Browse the repository at this point in the history
yarprobotinterface will be in this phase while the robot finishes
startup actions and no interrupt has been received.
  • Loading branch information
drdanz committed Feb 17, 2016
1 parent 238df36 commit a35dbc7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/yarprobotinterface/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ bool RobotInterface::Module::configure(yarp::os::ResourceFinder &rf)
setName(mPriv->robot.portprefix().c_str());

// Enter startup phase
if (!mPriv->robot.enterPhase(RobotInterface::ActionPhaseStartup)) {
yError() << "Error in" << ActionPhaseToString(RobotInterface::ActionPhaseStartup) << "phase... see previous messages for more info";
if (!mPriv->robot.enterPhase(RobotInterface::ActionPhaseStartup) ||
!mPriv->robot.enterPhase(RobotInterface::ActionPhaseRun)) {
yError() << "Error in" << ActionPhaseToString(mPriv->robot.currentPhase()) << "phase... see previous messages for more info";
// stopModule() calls interruptModule() and then close()
// internally. This ensure that interrupt1 phase actions
// (i.e. detach) are performed before destroying the devices.
Expand Down
5 changes: 5 additions & 0 deletions src/yarprobotinterface/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ bool RobotInterface::Robot::enterPhase(RobotInterface::ActionPhase phase)
}
}

// run phase does not accept actions
if (phase == ActionPhaseRun) {
return true;
}

// Before starting any action we ensure that there are no other
// threads running from prevoius phases.
// In interrupt 2 and 3 and this is called by the interrupt callback,
Expand Down
4 changes: 4 additions & 0 deletions src/yarprobotinterface/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ RobotInterface::ActionPhase RobotInterface::StringToActionPhase(const std::strin
{
if (!phase.compare("startup")) {
return RobotInterface::ActionPhaseStartup;
} else if (!phase.compare("run")) {
return RobotInterface::ActionPhaseRun;
} else if (!phase.compare("interrupt1")) {
return RobotInterface::ActionPhaseInterrupt1;
} else if (!phase.compare("interrupt2")) {
Expand All @@ -105,6 +107,8 @@ std::string RobotInterface::ActionPhaseToString(RobotInterface::ActionPhase acti
switch (actionphase) {
case RobotInterface::ActionPhaseStartup:
return std::string("startup");
case RobotInterface::ActionPhaseRun:
return std::string("run");
case RobotInterface::ActionPhaseInterrupt1:
return std::string("interrupt1");
case RobotInterface::ActionPhaseInterrupt2:
Expand Down
1 change: 1 addition & 0 deletions src/yarprobotinterface/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum ActionPhase
{
ActionPhaseUnknown = 0,
ActionPhaseStartup,
ActionPhaseRun,
ActionPhaseInterrupt1,
ActionPhaseInterrupt2,
ActionPhaseInterrupt3,
Expand Down

0 comments on commit a35dbc7

Please sign in to comment.