ROS2 No executable found (ros2 run pack nodo)
Hello. I am new programming in ROS2 and I need help. I have carried out the following steps, without errors (but in the end it does not execute):
Create the workspace folder: **mkdir workspace**
Enter the workspace folder: **cd workspace**
Create a package: **ros2 pkg create --build-type ament_cmake lidar_publisher**
Enter the lidar_publisher package folder: **cd lidar_publisher**
Create the "src" folder: **mkdir src**
Enter the "src" folder: **cd src**
Install dependencies: **rosdep install -i --from-path src --rosdistro foxy -y**
Inside the "src" folder, create the following files: lidar_publisher.py, CMakeLists.txt, package.xml, setup.cfg, setup.py
Build the project from the *workspace* folder: **colcon build**
Set up the environment variables: **source install/setup.bash**
Try to execute the created script: **ros2 run lidar_publisher lidar_publisher** or **ros2 run lidar_publisher lidar_publisher.py**
This is the code for cMakelist.txt:
`cmakeminimumrequired(VERSION 3.5) project(lidar_publisher)
Find required packages
findpackage(amentcmake REQUIRED) findpackage(rclpy REQUIRED) findpackage(sensor_msgs REQUIRED)
Add the Python publisher script to the package
amentpythoninstallpackage(lidarpublisher)
Install the Python publisher script
install(PROGRAMS lidarpublisher.py DESTINATION lib/lidarpublisher )
Add package dependencies
amentdepends(rclpy sensormsgs)
Generate the package build file
ament_package() ` package.xml
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
setup.cfg
[develop] script-dir=$base/lib/lidarpublisher [install] install-scripts=$base/lib/lidarpublisher
setup.py
from setuptools import setup packagename = 'lidarpublisher' setup( name=packagename, version='0.1.0', packages=[], pymodules=[ 'lidarpublisher', ], installrequires=[ 'setuptools', 'ros2pkg', 'amentindexpython', 'rclpy', 'sensormsgs', ], datafiles=[ ('share/amentindex/resourceindex/packages', ['resource/' + packagename]), ('share/' + packagename, ['package.xml']), ], zipsafe=True, author='User', authoremail='User', maintainer='User', maintaineremail='User@mail.com', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache License 2.0', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Package for lidar publisher', license='Apache License 2.0', testsrequire=['pytest'], entrypoints={ 'consolescripts': [ 'lidarpublisher = lidarpublisher:main', ], }, )
lidar_publisher.py
import rclpy from rclpy.node import Node from sensormsgs.msg import LaserScan class LidarPublisher(Node): def _init(self): super().init('lidarpublisher') self.publisher = self.createpublisher(LaserScan, 'lidarscan', 10) def publishlidardata(self): scanmsg = LaserScan() # Configurar los datos del escaneo aquĆ self.publisher.publish(scanmsg) def main(args=None): rclpy.init(args=args) lidarpublisher = LidarPublisher() rclpy.spin(lidarpublisher) lidarpublisher.destroynode() rclpy.shutdown() if _name == 'main': main()
All this to receive at the end a message "No executable found" Something is missing, and this may also help other people who may have the same error, that's why I wrote it in full. Thank you very much to anyone who can help me. I have used a translator. Greetings from Chile.
Asked by Antonio Avezon on 2023-06-25 19:45:02 UTC
Comments
Unfortunately the code got piled up! I didn't write it like that
Asked by Antonio Avezon on 2023-06-25 19:47:21 UTC