ROSRUN couldn't find executable
my publisher node
#!/usr/bin/env python
# license removed for brevity
import rospy
from ros_tutorials_topic.msg import IoTSensor
import random
#create a new publisher. we specify the topic name, then type of message then the queue size
pub = rospy.Publisher('iot_sensor_topic', IoTSensor, queue_size=10)
#we need to initialize the node
rospy.init_node('iot_sensor_publisher_node', anonymous=True)
#set the loop rate
rate = rospy.Rate(1) # 1hz
#keep publishing until a Ctrl-C is pressed
i = 0
while not rospy.is_shutdown():
iot_sensor = IoTSensor()
iot_sensor.id = 1
iot_sensor.name="iot_parking_01"
iot_sensor.temperature = 24.33 + (random.random()*2)
iot_sensor.humidity = 33.41+ (random.random()*2)
rospy.loginfo("I publish:")
rospy.loginfo(iot_sensor)
pub.publish(iot_sensor)
rate.sleep()
i=i+1
subscriber nopde
#!/usr/bin/env python
import rospy
from ros_tutorials_topic.msg import IoTSensor
def iot_sensor_callback(iot_sensor_message):
rospy.loginfo("new IoT data received: (%d, %s, %.2f ,%.2f)",
iot_sensor_message.id,iot_sensor_message.name,
iot_sensor_message.temperature,iot_sensor_message.humidity)
rospy.init_node('iot_sensor_subscriber_node', anonymous=True)
rospy.Subscriber("iot_sensor_topic", IoTSensor, iot_sensor_callback)
# spin() simply keeps python from exiting until this node is stopped
rospy.spin()
cmakelist file
cmake_minimum_required(VERSION 2.8.3)
project(ros_tutorials_topic)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
message_generation
roscpp
rospy
std_msgs
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
add_message_files(
FILES
IoTSensor.msg
)
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs
)
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt ...
You don't appear to
source devel/setup.bash
anywhere.You cannot use
rosrun
(orroslaunch
) directly after building your workspace. You have tosource devel/setup.bash
first.$ source devel/setup.bash ros-industrial@ros-i-kinetic-vm:~/catkin_ws$ rosrun ros_tutorials_topic iot_sensor_publisher [rosrun] Couldn't find executable named iot_sensor_publisher below /home/ros-industrial/catkin_ws/src/ros_tutorials_topic ros-industrial@ros-i-kinetic-vm:~/catkin_ws$
I did that but didnot solve my issues. Kindly help in this as soon as possible.
But the problem is if i use simple talker and listener.py without custom message. My rosrun will work. If i create custom message and made changes in CMakeLists.txt. It will show the Couldn't find executable error.