Actions Quiz: TAB-TAB autocomplete not working

When trying to use TAB-TAB to autocomplete rostopic pub /action_custom_msg_as/goal actions_quiz/CustomActionMsgActionGoal the last part where it’s “header: …” is not coming up. Did I compile my action package incorrectly or is there an error on the server side?

Entering

rostopic pub /action_custom_msg_as/goal actions_quiz/CustomActionMsgActionGoal "goal: 'TAKEOFF'"

Gives me the error:

ERROR: invalid message type: actions_quiz/CustomActionMsgActionGoal. If this is a valid message type, perhaps you need to type 'rosmake actions_quiz'

Here is my server side code:

#! /usr/bin/python

import rospy
import actionlib
from std_msgs.msg import Empty
from actions_quiz.msg import *

def publish_once(pub, msg):
    r = rospy.Rate(1)
    while True:
        connections = pub.get_num_connections()
        if connections > 0:
            pub.publish(msg)
            rospy.loginfo("Publishing msg")
            break
        else:
            r.sleep()

class CustomActionServer:
    def __init__(self):
        rospy.init_node('action_custom_msg_as', log_level=rospy.DEBUG)
        self.action_server = actionlib.SimpleActionServer('action_custom_msg_as', CustomActionMsgAction, self.callback, auto_start=False)
        self.rate = rospy.Rate(10)
    
    def takeoff(self):
        rospy.loginfo("Taking off...")
        self.pub_takeoff = rospy.Publisher('/drone/takeoff', Empty, queue_size=1)
        msg = Empty()
        publish_once(self.pub_takeoff, msg)
    
    def land(self):
        rospy.loginfo("Landing...")
        self.pub_land = rospy.Publisher('drone/land', Empty, queue_size=1)
        msg = Empty()
        publish_once(self.pub_land, msg)

    def callback(self, goal):
        if goal=='TAKEOFF':
            self.takeoff()
            feedback = 'Taking off...'
        elif goal=='LAND':
            self.land()
            feedback = 'Taking off...'
        
        for i in range(5):
            self.action_server.publish_feedback(feedback)
            rospy.sleep(1)

    def start(self):
        self.action_server.start()
        rospy.spin()

if __name__=='__main__':
    custom_action_server = CustomActionServer()
    custom_action_server.start() 

Here is a portion of the package.xml

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>rospy</build_depend>
  <build_depend>actionlib</build_depend>
  <build_depend>actionlib_msgs</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>actionlib</build_export_depend>
  <build_export_depend>actionlib_msgs</build_export_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>actionlib</exec_depend>
  <exec_depend>actionlib_msgs</exec_depend>

Here is the CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(actions_quiz)

find_package(catkin REQUIRED COMPONENTS
  rospy
  std_msgs
  actionlib_msgs
)

add_action_files(
  FILES
  CustomActionMsg.action
)

generate_messages(
  DEPENDENCIES
  std_msgs
  actionlib_msgs
)

catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES actions_quiz
 CATKIN_DEPENDS rospy
#  DEPENDS system_lib
)

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)

can you post your ActionGoal message file?

The file is actions_quiz/action/CustomActionMsg.action

string goal
---
---
string feedback

Give this a read, I think you’re not generating your custom messages.
https://answers.ros.org/question/104491/invalid-message-type/

Everything worked after following the official docs. It appeared the lesson tutorial on actions was missing a couple of lines.

Here are my updated CMakeLists.txt and package.xml. I’m not sure which line did the trick in particular.

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(actions_quiz)

find_package(catkin REQUIRED COMPONENTS
  rospy
  actionlib_msgs
)

add_action_files(
  DIRECTORY action
  FILES CustomActionMsg.action
)

generate_messages(
  DEPENDENCIES
  std_msgs
  actionlib_msgs
)

catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES actions_quiz
 CATKIN_DEPENDS rospy actionlib_msgs
#  DEPENDS system_lib
)

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)

package.xml

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>rospy</build_depend>
  <build_depend>actionlib</build_depend>
  <build_depend>actionlib_msgs</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>actionlib</build_export_depend>
  <build_export_depend>actionlib_msgs</build_export_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>actionlib</exec_depend>
  <exec_depend>actionlib_msgs</exec_depend>
  <exec_depend>message_generation</exec_depend>
1 Like

@bayodesegun Perhaps you might wanna take a look and update the lesson.

@linsu.han @simon.steinmann91,

If you follow the examples in the Notebooks carefully, you should be able to build your message successfully. It’s not clear here which line was missing nor if that line was necessary in the first place.

Hi @linsu.han, I don’t know if you have solved the issue or not, but I was facing the same problem and I managed to solve it by sourcing the workspace and then using rospack profile i.e. executing in the web shell:

roscd; cd ..
source devel/setup.bash
rospack profile

Hope this helps out.

2 Likes

Hi,
Having faced the same problem, this worked for me. Thanks !!

2 Likes

Hi,
Sorry for posting on old topic but I got the same problem. Tried all the solutions mentioned here but I still cannot make the [TAB] [TAB] work. My CMakeLists.txt and Package.xml is similar to ones posted here
If anyone can help I would appriciate it.

If you have tried the above already and it still doesn’t work you can try:

roscd; cd ..
rm -rf build/
rm -rf devel/
catkin_make
source devel/setup.bash
rospack profile

1 Like

Thanks for the reply,
I’ve already tried the
rm -rf build/
rm -rf devel/
catkin_make
source devel/setup.bash
rospack profile
with no luck. Will the
roscd; cd ..
make any difference?
I appriciate the help!

The purpose of the roscd; cd .. is to make sure you’re in the catkin_ws if you are not in their then the other commands have no effect. It is best to follow the commands in the order shown below.

roscd; cd ..
rm -rf build/
rm -rf devel/
catkin_make
source devel/setup.bash
rospack profile

1 Like

Thank you! I will try that and come back.

1 Like

Hi, that still doesn’t work with the steps you provided

I’m out of suggestions that should have worked. See if it works with another project you have done that way we can see if it’s not working in general or if it’s just this particular project this might give me a clue. Also the switch to noetic as officially started so that will require making some changes too.

Hi, are you sure your action server is running? The steps provided in

How to prepare CMakeLists.txt and package.xml files for custom action messages compilation¶

are enough to create your own custom action messages.

thank you @hskramer, removing the build and devel folder then rebuilding the workspace worked for me!

1 Like