Throwing warning

Hello all,
In the image below, I’m trying to send message to the action_server to make the drone TAKEOFF

I’m getting the warning shown below

Following is the code I’ve written:
if goal == 'TAKEOFF':

      # make the drone takeoff
      self._pub_takeoff.publish(self._takeoff_msg)
    
      # check that preempt (cancelation) has not been requested by the action client
      if self._as.is_preempt_requested():
        rospy.loginfo('The goal has been cancelled/preempted')
        # the following line, sets the client in preempted state (goal cancelled)
        self._as.set_preempted()
      
      # build and publish the feedback message
      self._feedback.feedback = i
      self._as.publish_feedback(self._feedback)
      # the sequence is computed at 1 Hz frequency
      r.sleep()
      
    # make the drone stop and land
    elif goal == 'LAND':
      self.stop_drone()
      self._pub_land.publish(self._land_msg)

I tried to understand why, but couldn’t figure out. I didn’t get any satisfactory answer from Google either.
I searched in the construct forum. I found a solution shown in pic below…But, I don’t understand what the person is trying to say. Why do we even need to import CustomActionMsgResult when we didn’t give any result string in the .action file


I still gave it a shot. I imported CustomActionMsgResult and then wrote something like shown below, in goal_callback function:
_result = CustomActionMsgResult()
self._result = Empty()

Even then, the warning was thrown.
I wonder what’s causing the error and why is drone not taking off when I enter the message TAKEOFF ?

Hello @abdulbasitisdost,

Even though the result is an Empty message, this is still a message in ROS. Think about, for instance, the examples where you send an Empty message in order to call a ROS service. The message is Empty, yes, but you still need to send it in order to trigger the service. Therefore, even if it’s an Empty message, you have to bear in mind that this is still a type of message in ROS.

Try to add the following to your Action code (at the end of the callback function):

self._result = Empty()
self._as.set_succeeded(self._result)

This should solve your issue.

Best,

2 Likes