Hello
I am currently on the Actions Quiz.
So I submitted my quiz and it does not finish the autocorrection (see screenshot).
It stays there for like forever.
When I run the code by myself everything was working fine.
After my second upload I received 8 points saying that the takeoff was not working appropriately.
Even tho it worked ok when I simulated it by my own.
So therefore I changed the takeoff loop. Before I had no argument which would end the takeoff while-loop, then I changed it to a loop which runs for 3 seconds. The Drone does then stay in the takeoff position.
This is the code:
#! /usr/bin/env python
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):
rate = 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()
ActionGoal = goal.goal
i = 0
while ActionGoal.upper() == "TAKEOFF" and i != 3:
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('Drone is taking off')
self._feedback.feedback = "TAKEOFF"
self._as.publish_feedback(self._feedback)
i += 1
rate.sleep()
i = 0
while ActionGoal.upper() == "LAND" and i != 3:
if self._as.is_preempt_requested():
rospy.loginfo('The goal has been cancelled/preempted')
self._as.set_preempted()
success = False
break
self._pub_land.publish(self._land_msg)
rospy.loginfo('Drone is landing')
self._feedback.feedback = "LANDING"
self._as.publish_feedback(self._feedback)
i += 1
rate.sleep()
if success:
self._result = 'success'
self._as.set_succeeded(self._result)
if name == ‘main’:
rospy.init_node(‘action_custom_msg’)
MoveDrone()
rospy.spin()
But with this code the autocorrection freezes. Since I was not sure if it had to do something with my internet connection I reloaded the page. I was checking if it took me a trial away. It showed me first that I had still 3 trials left. So it looked like no trial was taken away. But then I tried to resubmit it came a message than I received 0 Points.
Then I resubmitted again and run into the same freeze issue (I was waiting for like 30min if something else happens) and had to reload again.
So now I am not even sure how many trials I have left (it shows me 1, but I fear that when I try to resubmit it will again give me 0 points and therefor taken away my last trial).
So therefore I would like to ask for help.
Why does the autocorrection freezes?
I was assuming if it had something to to with the rate.sleep() function.
I tried also with time.sleep(1), but ran into the same issue.
I mean I think it stays in the take-off loop and can’t go out of it, but I don’t know why since in my own simulation it ends the loop after 3 seconds.
Also could you maybe give me more trials?
Thanks in advance for your help
Cheers