[Bug] Issue with Custom ROS Message and Publisher

This is an error report.


Screenshot of the error


Error details

Hi all,

I’m working with ROS and have created a custom message, Age.msg, to publish data about age (years, months, days) via a publisher to a topic. However, I am encountering an error when launching the node. Below is the setup and error details:

ROS Launch File (publish_age.launch):

<launch>
<node pkg="exercise_33" type="publish_age.py" name="publish_age_node" output="screen" />
</launch>

Custom Message (Age.msg):

float32 years
float32 months
float32 days

Python Script (publish_age.py):

#! /usr/bin/env python

import rospy
from exercise_33.msg import Age # Import Age message from the exercise_33 package

rospy.init_node('publish_age_node')
pub = rospy.Publisher('/age_info', Age, queue_size=1) # Create a Publisher that will publish in the /age_info topic
rate = rospy.Rate(2)

age = Age() # Create an Age message object
age.years = 5 # Fill the values of the message
age.months = 10
age.days = 21

while not rospy.is_shutdown():
pub.publish(age) # Publish the message into the defined topic /age_info
rate.sleep()

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(exercise_33)

find_package(catkin REQUIRED COMPONENTS
std_msgs
message_generation
)

add_message_files(
FILES
Age.msg
)

generate_messages(
DEPENDENCIES
std_msgs
)

catkin_package(
CATKIN_DEPENDS rospy message_runtime
)

include_directories(
${catkin_INCLUDE_DIRS}
)

package.xml:

<package format="2">
<name>exercise_33</name>
<version>0.0.0</version>
<description>The exercise_33 package</description>
<maintainer email="user@todo.todo">user</maintainer>
<license>TODO</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>

<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>message_runtime</build_export_depend>

<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>

<export>
</export>
</package>

Error Message:

roslaunch exercise_33 publish_age.launch

RLException: [publish_age.launch] is neither a launch file in package [exercise_33] nor is [exercise_33] a launch file name
The traceback for the exception was written to the log file

Questions:
Is there something I’m missing in the package structure or configuration files?
Why is ROS not finding the publish_age.launch file?
Any help would be greatly appreciated!

Thanks in advance!

Hi @jayaklish ,

Welcome to this Community!

  1. Did you provide your launch file executable permissions by doing
    chmod +x ./publish_age.launch ?

  2. Did you compile your package again after creating the launch file and giving it execution permissions?

If you have not, then try doing the above two steps in order - give executable permissions and then re-compile your catkin workspace.

Your issue should be resolved after you do the above two steps.

Regards,
Girish

Where did you put the launch file? It should be inside a launch directory inside your package.

Can you show us your directory structure for the package?

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.