3 import clearpath_localization_msgs.msg
4 from sensor_msgs.msg
import NavSatFix
9 SURVEY_ACTION_NAME =
'localization/survey'
10 SURVEY_PROPERTIES_TOPIC_NAME = SURVEY_ACTION_NAME +
'/properties'
14 """Performs surveying, prior to running missions.
16 This is typically used to initialize the position of the Base Station.
19 def __init__(self, progress_callback=None, done_callback=None):
20 """Builds up the data structure containing the details of the surveying.
24 progress_callback : fn(float32), optional
25 A callback function that is called at regular intervals while the surveying
26 is being executed to provide progress updates. The function should take
27 float32 parameter that is the percent complete. If set to None, no feedback
28 will be provided and the surveying will execute to completion.
30 done_callback : fn(enum, bool), optional
31 A callback function that is called when the surveying is complete. The function
32 should take two parameters: the terminal state (as an integer from
33 actionlib_msgs/GoalStatus) and the result.
42 SURVEY_ACTION_NAME, clearpath_localization_msgs.msg.SurveyBaseStationAction)
45 """Executes when 'feedback' is received from the surveying.
47 Forwards the callback to the survey feedback callback (if provided).
50 rospy.loginfo(
"Surveying is %0.3f percent complete" % (feedback.percent_complete))
55 """Executes when 'done' is received from the surveying.
57 Forwards the callback to the survey feedback callback (if provided).
60 if goal_state == actionlib.GoalStatus.SUCCEEDED
and result.success:
65 rospy.loginfo(
"Surveying is complete. Success: %s" % (self.
_survey_success))
67 base_properties_msg = rospy.wait_for_message(SURVEY_PROPERTIES_TOPIC_NAME, clearpath_localization_msgs.msg.SurveyProperties, 2.0)
69 except rospy.ROSException
as e:
70 rospy.logerr(
"Failed to get survey properties message.")
77 Using the default value, this process will take approximately 5 minutes.
81 num_of_desired_fixes : int, optional
82 The number of sample to take during the surveying process (default is 2000)
90 if not self.
_client.wait_for_server(timeout=rospy.Duration(2.0)):
91 rospy.logerr(
"Failed to connect to server")
93 goal = clearpath_localization_msgs.msg.SurveyBaseStationActionGoal
94 goal.number_of_desired_fixes = num_of_desired_fixes
97 except rospy.ROSInterruptException:
98 rospy.logerr(
"localization/survey server is not available; exception detected")
103 """Cancels the active survey."""
108 """Determines if the survey was successful.
110 If the survey is still in progress, reports False.
112 See also isSurveyComplete().
117 True if the survey completed successfully, else False
123 """Determines if the survey is complete.
125 See also getSurveySuccess().
130 True if the survey is complete, else False if survey is still running