Hello, I am currently doing the actions quiz. I have done the .py code and have the .launch file created. However, I cannot launch my file because of this error: ImportError: cannot import name CustomActionMsg.
I have checked the Cmakelists file and the xml file and both are ok.
I have also run catkin make and source devel/setup.bash several times
I have tried the rm -rf solution as well.
But nothing I try works I still get that error.
I tried checking if I would get more indication as to what was wrong by submitting the quiz but it only gave me a mark of 3.5 without telling me anything else (usually it tells you what you were wrong and such).
Below is my .py file, the Cmakelists.txt, and the xml file. I would appreciate any help.
pythonfile
#! /usr/bin/env python
import rospy
import actionlib
from actions_quiz.msg import CustomActionMsg, CustomActionMsgFeedback, CustomActionMsgAction
from std_msgs.msg import Empty
class QuizClass(object):
# create messages that are used to publish feedback/result
_feedback = CustomActionMsgFeedback()
def __init__(self):
# creates the action server
self.quizobject = actionlib.SimpleActionServer("action_custom_msg_as", CustomActionMsgAction, self.goal_callback, False)
self.quizobject.start()
def goal_callback(self, goal):
r = rospy.Rate(1)
success = True
if goal.goal == 'TAKEOFF':
self._feedback = "TAKEOFF"
self.quizobject.publish_feedback(self._feedback)
self.take_off()
if self.quizobject.is_preempt_requested():
rospy.loginfo('The goal has been cancelled/preempted')
self.quizobject.set_preempted()
success = False
elif goal.goal == 'LAND':
self._feedback = "LAND"
self.quizobject.publish_feedback(self._feedback)
self.land()
if self.quizobject.is_preempt_requested():
rospy.loginfo('The goal has been cancelled/preempted')
self.quizobject.set_preempted()
success = False
else:
rospy.loginfo('Bad input')
r.sleep()
if success:
rospy.loginfo('Succeeded')
def take_off(self):
pubis = rospy.Publisher('/drone/takeoff', Empty, queue_size = 1)
mover = Empty()
i=0
while not i == 3:
pubis.publish(mover)
rospy.loginfo('Taking off...')
time.sleep(1)
i += 1
def land(self):
pubises = rospy.Publisher('/drone/land', Empty, queue_size = 1)
moverer = Empty()
i=0
while not i == 3:
pubises.publish(moverer)
rospy.loginfo('Landing...')
time.sleep(1)
i += 1
if __name__ == '__main__':
rospy.init_node('action_custom_msg_as')
QuizClass()
rospy.spin()
cmakelists file (i have deleted all the commented lines for brevity)
cmake_minimum_required(VERSION 3.0.2)
project(actions_quiz)
find_package(catkin REQUIRED COMPONENTS
std_msgs
actionlib_msgs
)
add_action_files(
FILES
CustomActionMsg.action
)
generate_messages(
DEPENDENCIES
std_msgs actionlib_msgs
)
catkin_package(
CATKIN_DEPENDS rospy
)
include_directories(
${catkin_INCLUDE_DIRS}
)
xml file (commented lines deleted for brevity)
<?xml version="1.0"?>
<package format="2">
<name>actions_quiz</name>
<version>0.0.0</version>
<description>The actions_quiz package</description>
<maintainer email="user@todo.todo">user</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>actionlib</build_depend>
<build_depend>actionlib_msgs</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>actionlib</build_export_depend>
<build_export_depend>actionlib_msgs</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<exec_depend>actionlib</exec_depend>
<exec_depend>actionlib_msgs</exec_depend>
<exec_depend>rospy</exec_depend>
<export>
</export>
</package>