Taking off after landing! Action_Quiz

Hello there,

for the 9.4 actions_quiz, when I launch the action_custom_msg.launch myself it works as expected. Taking off with TAKEOFF message and Landing with LAND message. However, the grader says the landing is not fine and the drone will taking off after landing (8/10) while I did not see this action when I manually used roslaunch.
Here is my code:
#! /usr/bin/env python
import time
import rospy
import actionlib
from actions_quiz.msg import CustomActionMsgAction, CustomActionMsgResult, CustomActionMsgFeedback
from std_msgs.msg import Empty

class MoveDrone(object):

def __init__(self):
    
    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)
    self._feedback = CustomActionMsgFeedback()
    self._result = CustomActionMsgResult()

def goal_callback(self, goal):
    
    r = rospy.Rate(1)
    success = True
    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()

    command = goal.goal

    while command.upper() == "TAKEOFF":

        
        if self._as.is_preempt_requested():
            rospy.loginfo('The goal has been cancelled/preempted')
            
            self._as.set_preempted()
            success = False
            
            break

        self._pub_takeoff.publish(self._takeoff_msg)
        rospy.loginfo('Taking off...')

        
        self._feedback.feedback = "taking off"
        self._as.publish_feedback(self._feedback)
        
        r.sleep()

    i = 0
    while command.upper() == "LAND" and i != 3:

        # 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()
            success = False
            
            break

        
        self._pub_land.publish(self._land_msg)
        rospy.loginfo('Landing...')

        self._feedback.feedback = "landing"
        self._as.publish_feedback(self._feedback)
        
        time.sleep(1)
        i += 1

    if success:
        self._result = 'success'
        self._as.set_succeeded(self._result)

if name == ‘main’:
rospy.init_node(‘move_square’)
MoveDrone()
rospy.spin()

I would appreciate if anyone can help me in this regard.

Make sure the drone is landed before you run the grader, and that no processes are running in any terminal

Thank you for your reply. I reload simulation and IDE and shells and check that nothing running. But, I do not know why the drone take off after landing in grade checking!(I have only one attempt to submit). The feedback is:

Feedback from the last successful autocorrection:

:heavy_check_mark: [info] Setting up ROS environment (mark: 0)

:heavy_check_mark: [info] ROS environment setup is okay (mark: 0)

:heavy_check_mark: [assess] actions_quiz package found (mark: 1.0)

:heavy_check_mark: [info] compiling package actions_quiz… (mark: 1.0)

:heavy_check_mark: [assess] actions_quiz package compiled successfully (mark: 2.0)

:heavy_check_mark: [info] Checking that the action message compiles… (mark: 2.0)

:heavy_check_mark: [assess] actions_quiz custom message compiled successfully (mark: 3.0)

:heavy_check_mark: [info] Checking that the action server can be launched… (mark: 3.0)

:heavy_check_mark: [assess] Can launch actions_quiz server successfully (mark: 4.0)

:heavy_check_mark: [info] Checking that action topics are present… (mark: 4.0)

:heavy_check_mark: [assess] Actions topics are present (mark: 6.0)

:heavy_check_mark: [info] Checking that the TAKEOFF call works… (mark: 6.0)

:heavy_check_mark: [assess] Drone took off successfully (mark: 8.0)

:heavy_check_mark: [info] Checking that the LAND call works… (mark: 8.0)

:heavy_multiplication_x: [assess] Drone was not landed. Things your can check:

  • Is your code landing the drone correctly?
  • Is your code taking the drone off after landing it? It should NOT. You should use the TAKEOFF call for that. (mark: 8.0)

I assume you have checked the two bullet points at the end. You can now submit five more times. Does the drone land at the end of your program in the simulation?

Thanks for adding more attempts. Yes I checked both bullet points.
I can show you how I examine my codes manually. Please use the links below to watch the video.

While what I can see during the gardebot checking is that after landing, it will take off again!!! I did not see it even when I waited for long time after publishing LAND msg during my manual examination.

I have made some adjustments to the gradebot that should at least make the problem clearer in the logs. There’s even a small chance that this might help fix this problem.

Please try again and let us know if the problem persists. Then I will have to examine your code more closely.

Thank you so much.
I got 10/10 after you made adjustments.

1 Like

This topic was automatically closed after 20 hours. New replies are no longer allowed.