File tree Expand file tree Collapse file tree
include/WalkingControllers/WalkingModule Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ namespace WalkingControllers
6363
6464 double m_dT; /* *< RFModule period. */
6565 double m_time; /* *< Current time. */
66+ double m_lastSetGoalTime; /* *< Time of the last set goal. */
67+ double m_maxTimeToWaitForGoal; /* *< Maximum time to wait for a goal. */
6668 std::string m_robot; /* *< Robot name. */
6769
6870 bool m_useMPC; /* *< True if the MPC controller is used. */
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ bool WalkingModule::configure(yarp::os::ResourceFinder &rf)
138138 std::string goalSuffix = rf.check (" goal_port_suffix" , yarp::os::Value (" /goal:i" )).asString ();
139139 m_skipDCMController = rf.check (" skip_dcm_controller" , yarp::os::Value (false )).asBool ();
140140 m_removeZMPOffset = rf.check (" remove_zmp_offset" , yarp::os::Value (false )).asBool ();
141+ m_maxTimeToWaitForGoal = rf.check (" max_time_to_wait_for_goal" , yarp::os::Value (1.0 )).asFloat64 ();
141142
142143 m_goalScaling.resize (3 );
143144 if (!YarpUtilities::getVectorFromSearchable (rf, " goal_port_scaling" , m_goalScaling))
@@ -683,6 +684,17 @@ bool WalkingModule::updateModule()
683684 yError () << " [WalkingModule::updateModule] Unable to set the planner input" ;
684685 return false ;
685686 }
687+ m_lastSetGoalTime = m_time;
688+ }
689+ else if (!m_firstRun && ((m_time - m_lastSetGoalTime) > m_maxTimeToWaitForGoal))
690+ {
691+ yWarning () << " [WalkingModule::updateModule] The goal has not been set for more than " << m_maxTimeToWaitForGoal << " seconds." ;
692+ yarp::sig::Vector dummy (3 , 0.0 );
693+ if (!setPlannerInput (dummy))
694+ {
695+ yError () << " [WalkingModule::updateModule] Unable to set the planner input" ;
696+ return false ;
697+ }
686698 }
687699
688700 // if a new trajectory is required check if its the time to evaluate the new trajectory or
You can’t perform that action at this time.
0 commit comments