Hi,
I’m preparing the code for the Chapter 10 Actions Quiz. I did create my custom message and have the action server running (I can see the topics created with rostopic list | grep action), but I see a warning popping up saying:
[WARN] [1685251092.880672, 2637.044000]: Your executeCallback did not set the goal to a terminal status. This is a bug in your ActionServer implementation. Fix your code! For now, the ActionServer will set this goal to aborted
I’ve been reading online but I can’t find a clear solution. I added the set_succeeded method as I read it could be the problem, but had no luck with it.
Here’s the code:
#! /usr/bin/env python
import rospy
import time
import actionlib
from actions_quiz.msg import CustomActionMsgGoal, CustomActionMsgFeedback, CustomActionMsgAction
from std_msgs.msg import Empty
class MoveSquareClass(object):
# create messages that are used to publish feedback/result
_feedback = CustomActionMsgFeedback()
_result = CustomActionMsgGoal()
def __init__(self):
# creates the action server
self._as = actionlib.SimpleActionServer("/action_custom_msg_as", CustomActionMsgAction, self.goal_callback, False)
self._as.start()
self.ctrl_c = False
self.rate = rospy.Rate(10)
def goal_callback(self, goal):
# define the different publishers and messages that will be used
self._pub_takeoff = rospy.Publisher('/drone/takeoff', Empty, queue_size=1)
self._takeoff_msg = Empty()
self._pub_land = rospy.Publisher('/drone/land', Empty, queue_size=1)
self._land_msg = Empty()
if goal == 'Take-off':
self.take_off(self._takeoff_msg)
rospy.loginfo("Taking off...")
self._as.set_succeeded(self._result)
elif goal == 'Land':
self.land(self._land_msg)
rospy.loginfo("Landing...")
self._as.set_succeeded(self._result)
else:
rospy.loginfo("Incorrect Goal!")
def take_off(self):
# make the drone takeoff
i=0
while not i == 3:
self._pub_takeoff.publish(self._takeoff_msg)
rospy.loginfo('Taking off...')
time.sleep(1)
i += 1
def land(self):
while not i == 3:
self._pub_land.publish(self._land_msg)
rospy.loginfo('Landing...')
time.sleep(1)
i += 1
if __name__ == '__main__':
rospy.init_node('action_custom_msg_as')
MoveSquareClass()
rospy.spin()
I’m manually calling the service through the topic publisher:
rostopic pub /action_custom_msg_as/goal actions_quiz/CustomActionMsgActionGoal "header:
seq: 0
stamp:
secs: 0
nsecs: 0
frame_id: ''
goal_id:
stamp:
secs: 0
nsecs: 0
id: ''
goal:
goal: 'Take-off'"
Any help would be appreciated, thanks in advance!