Ask Your Question
0

ROSRUN couldn't find executable

asked 2020-05-27 03:27:04 -0500

sivabalakrishnan gravatar image

updated 2020-05-27 04:30:10 -0500

gvdhoorn gravatar image

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 ...
(more)
edit retag flag offensive close merge delete

Comments

You don't appear to source devel/setup.bash anywhere.

You cannot use rosrun (or roslaunch) directly after building your workspace. You have to source devel/setup.bash first.

gvdhoorn gravatar image gvdhoorn  ( 2020-05-27 04:31:27 -0500 )edit

$ 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.

sivabalakrishnan gravatar image sivabalakrishnan  ( 2020-05-27 04:40:10 -0500 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2020-06-24 23:41:14 -0500

Michelle gravatar image

Did you use the catkin_make command after the chmod+ command?

Also I don't need to modify your CMakeList for a python node so I would firstly get rid of that. I would then use the chmod + command again just to make sure that your node is executable. After that go to your catkin_ws directory and type the catkin_make. After this in your home directory and use the following command : source ~/type your path to/catkin_ws/devel/setup.bash. Did this solve your problem?

edit flag offensive delete link more
0

answered 2020-05-27 05:19:44 -0500

pmuthu2s gravatar image

Did you make your file executable?

Possible answer

edit flag offensive delete link more

Comments

Yes. I used command chmod +x for making my file executable.

I have also modified my CMakeLists.txt with following command.

catkin_install_python(PROGRAMS scripts/iot_sensor_publisher.py scripts/iot_sensor_subscriber.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} )

Anyone please help me in this to solve this issue. I can run this code in C++. But in python, I couldn't able to run using ros run.

But when i moved to path ......ros_tutorials_topic/scripts, then in my terminal I use these command to check output. $ cd .....ros_tutorials_topic/scripts scripts $ python talker.py

sivabalakrishnan gravatar image sivabalakrishnan  ( 2020-05-27 06:18:36 -0500 )edit

rosrun ros_tutorials_topic iot_sensor_publisher.py

If this works, I would update the answer!

pmuthu2s gravatar image pmuthu2s  ( 2020-05-27 09:37:06 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-05-27 03:27:04 -0500

Seen: 57 times

Last updated: Jun 24