Hi
first here are my code:
#! /usr/bin/env python
import rospy
import actionlib
from actions_quiz.msg import CustomActionMsgAction, CustomActionMsgResult, CustomActionMsgFeedback
from std_msgs.msg import Empty
class ActionServer(object):
feedback = CustomActionMsgFeedback()
result = CustomActionMsgResult()
drone_cmd = ''
clientContact = False
def __init__(self):
self.a_server = actionlib.SimpleActionServer(
"/action_custom_msg_as", CustomActionMsgAction, self.goal_callback, False)
self.a_server.start()
self.ctrl_c = False
self.rate = rospy.Rate(10)
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()
self.timer = rospy.Timer(rospy.Duration(1), self.sendFeedback)
def sendFeedback(self, timer):
if self.clientContact is True:
self.feedback.feedback = self.drone_cmd
self.a_server.publish_feedback(self.feedback)
def goal_callback(self, goal):
self.drone_cmd = goal.goal
self.clientContact = True
success = True
for x in range(3):
if self.a_server.is_preempt_requested():
self.a_server.set_preempted()
success = False
break
if self.drone_cmd == 'TAKEOFF':
self._pub_takeoff.publish(self._takeoff_msg)
elif self.drone_cmd == 'LAND':
self._pub_land.publish(self._land_msg)
rospy.sleep(1)
if success is True:
self.a_server.set_succeeded()
if self.drone_cmd == 'LAND':
self.clientContact = False
if name == ‘main’:
rospy.init_node(‘action_server’)
ActionServer()
rospy.spin()
So GradeBot can build the code and he can launch the launch file
everything went fine until he sends the Goal TAKEOFF
I can’t run the Quiz anymore because i reached the Limit and got only 6 Points
But can please anybody show me where in my code is the misstake ?
Because if i don’t know it i can’t learn from it and that is very frustrating .
In my Simulation everything is working fine.
thx, Kevin