5 #ifndef BEH_SEARCH_FOR_BALL_H
6 #define BEH_SEARCH_FOR_BALL_H
9 #include <walk_and_kick/wak_beh_state.h>
10 #include <walk_and_kick/beh_states/gaze_beh_look_for_ball.h>
11 #include <rc_utils/ros_time.h>
14 namespace walk_and_kick
38 static bool sfbWalkStateValid(
int state) {
return (state > SFB_WS_UNKNOWN && state < SFB_WS_COUNT); }
39 static bool sfbWalkStateValid(SFBWalkState state) {
return sfbWalkStateValid((
int) state); }
40 static const std::string& sfbWalkStateName(SFBWalkState state) {
if(sfbWalkStateValid(state))
return SFBWalkStateName[state];
else return SFBWalkStateName[SFB_WS_UNKNOWN]; }
42 static const std::string SFBWalkStateName[SFB_WS_COUNT];
52 static bool ballHypTypeValid(
int type) {
return (type >= BHT_NONE && type < BHT_COUNT); }
53 static bool ballHypTypeValid(BallHypType type) {
return ballHypTypeValid((
int) type); }
54 static const std::string& ballHypTypeName(BallHypType type) {
if(ballHypTypeValid(type))
return BallHypTypeName[type];
else return BallHypTypeName[BHT_NONE]; }
56 static const std::string BallHypTypeName[BHT_COUNT];
69 void clearSfbStateRequest() { m_reqState = SFB_WS_UNKNOWN; m_reqData = 0; rc_utils::zeroRosTime(m_reqTime); }
70 void requestSfbState(SFBWalkState state,
int data = 0) {
if(sfbWalkStateValid(state)) { m_reqState = state; m_reqData = data; m_reqTime = SV.now; }
else clearSfbStateRequest(); }
71 void refreshSfbStateRequest() {
if(haveSfbStateRequest()) m_reqTime = SV.now; }
72 float timeSinceSfbStateRequest()
const {
return (m_reqTime.isZero() ? INFINITY : (SV.now - m_reqTime).toSec()); }
73 bool haveSfbStateRequest()
const {
return (sfbWalkStateValid(m_reqState) && timeSinceSfbStateRequest() < config.sfbStateRequestTimeout()); }
77 virtual void handleActivation(
bool nowActive);
83 PersistentVars() { reset(); }
85 SFBWalkState nextState;
86 BallHypType ballHypType;
93 void changeSfbState(SFBWalkState newSfbState, SFBWalkState nextState = SFB_WS_UNKNOWN);
98 void clearSuspendedState();
99 bool haveSuspendedState()
const;
102 float calcBallHypValue(
const Vec2f& ballHypPose);
103 float calcTimeout(
const Vec2f& target);
104 int calcSpinDirnToTarget(
const Vec2f& target);
105 bool spinningToTargetIsBetter(
const Vec2f& target);
106 float backupFactorFromLine(
float margin,
float distToLine,
float cosAlpha);
107 float backupFactorFromPoint(
float margin,
float vecToPointX,
float vecToPointY,
float theta);
110 SFBWalkState m_reqState;
115 SFBWalkState m_lastActState;
116 ros::Time m_lastActTime;
117 ros::Time m_lastActSpinTime;
118 float m_lastActElapsed;
121 SFBWalkState m_walkState;
122 ros::Time m_walkStateTime;
123 bool m_walkStateIsRequest;
124 bool m_walkStateIsResumed;
125 bool m_walkStateIsNew;
135 SFBWalkState m_resumeWalkState;
136 float m_resumeElapsed;
137 PersistentVars m_resumePV;
140 Vec2f m_lastBallHypPose;
141 bool m_lastBallHypPoseValid;
144 BallHypType m_visBallHypType;
Configuration struct for the walk and kick node.
Definition: wak_config.h:20
An interface class for encapsulating all of the ROS input data to the walk and kick node...
Definition: wak_sensor_vars.h:29
A class that shares the required walk and kick variables amongst the game state classes.
Definition: wak_game_shared.h:31
A simple counter class for counting events.
Definition: wak_utils.h:63
A walk and kick gaze behaviour state that looks for the ball.
Definition: gaze_beh_look_for_ball.h:20
A class that shares the required walk and kick variables amongst the behaviour state classes...
Definition: wak_beh_shared.h:48
A walk and kick behaviour state that searches for the ball.
Definition: beh_search_for_ball.h:21
An interface class for encapsulating all of the data that the walk and kick behaviour states should c...
Definition: wak_actuator_vars.h:22