Just a quick question on the exam, task 3:
I’ve got the rest of the stuff running, and i can return the action result fine when i do a rostopic pub to the action server topic. However, i’m considering my next step in regards to the timed recording of the /gt_pose. The task doesnt specifically state to make use of the service server previously created, however, this seems obvious to use, since it records the required data, just not in time intervals. But i’m a little confused as to how i should make a call to the service server from within the action server?
This is what i have so far (with some added pseudo code in the middle).
Any hints would be appreciated! Thanks
#!/usr/bin/env python
import rospy
import actionlib
import time
from path_exam.msg import RecordOdomAction, RecordOdomGoal, RecordOdomResult
class CheckDistanceActionServer:
def __init__(self):
self._as = actionlib.SimpleActionServer('/rec_pose_as', RecordOdomAction, execute_cb=self.on_goal, auto_start=False)
self._as.start()
rospy.loginfo("Check Distance Action Server has been started")
def on_goal(self, goal):
rospy.loginfo("A goal has been received!")
#start some timer in ROS time
# all_positions = []
# while timer < 20 seconds:
#for each second in 20 seconds:
#variable = current /gt_pose data
# all_positions.append(variable)
#result = RecordOdomResult()
#result.position = all_positions
rospy.loginfo(result)
rospy.loginfo("send goal result to client")
self._as.set_succeeded(result)
if __name__== '__main__':
rospy.init_node('distance_action_server')
server = CheckDistanceActionServer()
rospy.spin() # keeps the node alive. with ctrl + c this allows the shutdown of the node.