RosJect did work but now shows error

Hi,

currently I do the extra tour in “ROS2 Basics Python Real Robot Project”
I kind of solved section one and worked on section two.
Now it looks like there is some error left when starting

ros2 launch wall_follower wall_follower.launch.py

it shows

[INFO] [launch]: All log files can be found below /home/user/.ros/log/2022-11-27-14-03-25-912356-4_xterm-7002
[INFO] [launch]: Default logging verbosity is set to INFO[INFO] [wall_follower-1]: process started with pid [7063]
[wall_follower-1] Traceback (most recent call last):
[wall_follower-1]   File "/home/user/ros2_ws/install/wall_follower/lib/wall_follower/wall_follower", line 33, in <
module>
[wall_follower-1]     sys.exit(load_entry_point('wall-follower==0.0.0', 'console_scripts', 'wall_follower')())
[wall_follower-1]   File "/home/user/ros2_ws/install/wall_follower/lib/wall_follower/wall_follower", line 25, in importlib_load_entry_point
[wall_follower-1]     return next(matches).load()
[wall_follower-1]   File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
[wall_follower-1]     module = import_module(match.group('module'))
[wall_follower-1] AttributeError: 'NoneType' object has no attribute 'group'
[ERROR] [wall_follower-1]: process has died [pid 7063, exit code 1, cmd '/home/user/ros2_ws/install/wall_follower/
lib/wall_follower/wall_follower --ros-args'].

not sure why it should not work again. Any hint how to isolate the problem ?

Hi @vkuehn ,

I think you need to check your setup.py file again. The error says that your entry points is a ‘NoneType’, basically indicating that your entry points list is empty.

I hope this tip helps you fix your issue.

In case, this does not fix your issue, then:

  1. Post your package folder structure with filenames visible - a screenshot from your IDE left panel.
  2. Post the contents of your package’s setup.py file as a code-block.

Regards,
Girish

1 Like

Hi @girishkumar.kannan ,

I have checked that and it looked ok. But than to make sure I have removed build and install folder and restarted the whole build again.
It looks actually that the wall_follower_srv which just contains the message for the wall_finder service contains the break. it was created with ros2 pkg create --build-type ament_cmake and looks like that

wall_follower_srv

FindWall.srv

​
---
bool wallfound

The package.xml

<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>wall_follower_srv</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="user@todo.todo">user</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>rclcpp</depend>
  <depend>std_msgs</depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

The CMakeLists.txt

cmake_minimum_required(VERSION 3.5)
project(wall_follower_srv)

if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

rosidl_generate_interfaces(${PROJECT_NAME}
  "srv/FindWall.srv"
)

ament_package()

Thanks for any hint here.

Hi @vkuehn ,

Just by looking at your folder structure and the file contents that you included in your post, I understood the following:

  1. Your FindWall.srv service message file is correct.
  2. You do not have to create a package specifically for srv message - because you will be creating a custom action message in Part 3 and you can keep both the custom messages (service and action) as one single ament_cmake package. If you make separate packages you must make sure that you include these packages in your main package’s dependencies.
  3. You have not added rosidl_default_generators as a dependency of your wall_follower_srv package.
  4. You must rebuild your wall_follower_srv package after adding rosidl dependencies to your package.xml file and CMakeLists.txt file.
  5. In your CMakeLists.txt file you must also add the rosidl_generate_interfaces() block to identify tour custom message during colcon build.
  6. Since you have not posted the setup.py file that I wanted to see, I am assuming that you have it correct.

So, do these modifications and try running your program. If anything still fails, let me know!

Regards,
Girish

Hi @girishkumar.kannan,

have added the rosidl and redone

colcon build --packages-select wall_follower_srv

which simply stated

Starting >>> wall_follower_srv
Failed   <<< wall_follower_srv [4.16s, exited with code 1]

Summary: 0 packages finished [4.52s]
  1 package failed: wall_follower_srv

here the structure for both packages

|-- wall_follower
|   |-- launch
|   |   |-- wall_finder.launch.py
|   |   `-- wall_follower.launch.py
|   |-- package.xml
|   |-- resource
|   |   `-- wall_follower
|   |-- setup.cfg
|   |-- setup.py
|   |-- test
|   `-- wall_follower
|       |-- __init__.py
|       |-- wall_finder.py
|       `-- wall_following.py
`-- wall_follower_srv
    |-- CMakeLists.txt
    |-- include
    |   `-- wall_follower_srv
    |-- package.xml
    |-- src
    `-- srv
        `-- FindWall.srv

here …/wall_follower/setup.py

from setuptools import setup
import os
from glob import glob

package_name = 'wall_follower'

setup(
    name=package_name,
    version='0.0.0',
    packages=[package_name],
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
        (os.path.join('share', package_name), glob('launch/*.launch.py'))
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='user',
    maintainer_email='user@todo.todo',
    description='TODO: Package description',
    license='TODO: License declaration',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
            'wall_follower = wall_follower.wall_following:main'
            'wall_finder = wall_follower.wall_finder:main'
        ],
    },
)

Does this clarify it ?

Hi @vkuehn ,

Okay… so your service message package itself is failing.

So, going through your attached file contents, everything seems fine, so that is good.
Your setup.py file is correct.

I faced a similar issue when I did my project, so I am guessing that might be happening in your case too.
[As discussed here: ROSDS - colcon build fails - environment dependency requirement]
So do this:

colcon build --packages-select wall_follower_srv --event-handlers console_cohesion+
  1. Delete build, install and log folders from ros2_ws.
  2. Compile your wall_follower_srv with the above command line.
  3. Post the complete output of the above command as a code block.
  4. Post the file contents of /home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeError.log as a code block.
  5. Post the contents of your CMakeLists.txt of your wall_follower_srv package as code block.
  6. Post the contents of your package.xml of your wall_follower_srv package as code block.

So, if I can verify that the problem you are facing was same as mine, I can give you some tips.

Regards,
Girish

Hi @girishkumar.kannan,

followed the steps and here is the compile output

Starting >>> wall_follower_srv
--- output: wall_follower_srv
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ament_cmake: 0.9.9 (/opt/ros/foxy/share/ament_cmake/cmake)
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Found rclcpp: 2.4.0 (/opt/ros/foxy/share/rclcpp/cmake)
-- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c
-- Found rosidl_adapter: 1.2.1 (/opt/ros/foxy/share/rosidl_adapter/cmake)
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1f")
-- Found FastRTPS: /opt/ros/foxy/include
-- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp
-- Found rmw_implementation_cmake: 1.0.3 (/opt/ros/foxy/share/rmw_implementation_cmake/cmake)
-- Using RMW implementation 'rmw_fastrtps_cpp' as default
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found rosidl_default_generators: 1.0.1 (/opt/ros/foxy/share/rosidl_default_generators/cmake)
-- Found ament_lint_auto: 0.9.6 (/opt/ros/foxy/share/ament_lint_auto/cmake)
-- Found PythonInterp: /usr/bin/python3 (found version "3.8.10")
-- Configuring incomplete, errors occurred!
See also "/home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeOutput.log".
See also "/home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeError.log".
---
Failed   <<< wall_follower_srv [3.71s, exited with code 1]

Summary: 0 packages finished [3.96s]
  1 package failed: wall_follower_srv

here the content of /home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeError.log

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_e6f68/fast && /usr/bin/make -f CMakeFiles/cmTC_e6f68.dir/build.makeCMakeFiles/cmTC_e6f68.dir/build
make[1]: Entering directory '/home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_e6f68.dir/src.c.o
/usr/bin/cc   -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_e6f68.dir/src.c.o   -c /home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_e6f68
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e6f68.dir/link.txt --verbose=1
/usr/bin/cc  -DCMAKE_HAVE_LIBC_PTHREAD    CMakeFiles/cmTC_e6f68.dir/src.c.o  -o cmTC_e6f68
/usr/bin/ld: CMakeFiles/cmTC_e6f68.dir/src.c.o: in function `main':
src.c:(.text+0x46): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x52): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x63): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_e6f68.dir/build.make:87: cmTC_e6f68] Error 1
make[1]: Leaving directory '/home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_e6f68/fast] Error 2


Source file was:
#include <pthread.h>

void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_c9b8b/fast && /usr/bin/make -f CMakeFiles/cmTC_c9b8b.dir/build.makeCMakeFiles/cmTC_c9b8b.dir/build
make[1]: Entering directory '/home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_c9b8b.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_c9b8b.dir/CheckFunctionExists.c.o  -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_c9b8b
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c9b8b.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_c9b8b.dir/CheckFunctionExists.c.o  -o cmTC_c9b8b  -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_c9b8b.dir/build.make:87: cmTC_c9b8b] Error 1
make[1]: Leaving directory '/home/user/ros2_ws/build/wall_follower_srv/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_c9b8b/fast] Error 2

CMakeLists.txt

cmake_minimum_required(VERSION 3.5)
project(wall_follower_srv)

if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

rosidl_generate_interfaces(${PROJECT_NAME}
  "srv/FindWall.srv"
)

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"?>
<package format="3">
  <name>wall_follower_srv</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="user@todo.todo">user</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>rclcpp</depend>
  <depend>std_msgs</depend>

  <build_depend>rosidl_default_generators</build_depend>
  <exec_depend>rosidl_default_runtime</exec_depend>
  <member_of_group>rosidl_interface_packages</member_of_group>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

thanks in advance for your insights

Regards,
Volker

Hi @vkuehn ,

You seem to have the exact same problem as I did.
The solution for me was that I had to wait a couple of days to get this fixed. I have no idea why but that was my solution as indicated here: ROSDS - colcon build fails - environment dependency requirement - #8 by girishkumar.kannan

What I would suggest for you is to do:

sudo apt update
sudo apt install build-essential

This is what I did but the output said that all packages are up-to-date. Perhaps something will work for you.
Otherwise, you just have to wait for two days and it will be fine.

I would like The Construct team to check on this issue please! (In case you have been reading this post!)

Cheers,
Girish

EDIT:
You could also try this: (you may need sudo)
python3 -m pip install -U setuptools wheel cmake distutils

1 Like

Hi @girishkumar.kannan ,

no as you say it I remember it hapend before like that to me and it was difficult to get a support solution.
I did as you suggested.

sudo apt install build-essential

did fail as it was already installed.
your pip update should probably look like

sudo python3 -m pip install -U testresources setuptools wheel cmake distutils-pytest

but still the issue therefor I tried

sudo apt update; sudo apt dist-upgrade

which asked for

sudo apt install --fix-broken

which failed with

Unpacking ros-noetic-gazebo-ros (2.9.2-1focal.20221014.230203) over (2.9.2-1focal.20210727.073131) ...
dpkg: error processing archive /var/cache/apt/archives/ros-noetic-gazebo-ros_2.9.2-1focal.20221014.230203_amd64.deb (--unpack):
 unable to make backup link of './opt/ros/noetic/lib/gazebo_ros/gzserver' before installing new version: Invalid cross-device link
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/ros-noetic-gazebo-ros_2.9.2-1focal.20221014.230203_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I’ll ask for help from the construct also

Hi @vkuehn ,

I am glad you attempted to fix it!

I have one suggestion though, try this:

  1. Save your entire project package files by downloading them to your computer.
  2. Delete the rosject and get a copy of the same rosject again.
  3. Upload the project files back into your new rosject workspace.

I have to say this would be again a 50/50 probability of getting things to work. But you can still try it.

Regards,
Girish

Hi @girishkumar.kannan ,

yes that would be a solution thought.
However I will give the friends from theconstruct a chance to analyse the problem.
I do another course in parallel and will see in a few day’s where I am with this.

Regards,
Volker

1 Like

I’ve been investigating and I found it really difficult to have this problem solved.

Let us see if any of the @staff members can help.

Hello @vkuehn ,

Cold you share your rosject with us, so that we can have a look and test it directly? Also, please indicate the steps in order to reproduce the error.

Hello @albertoezquerro,

It’s now public as Copy ROS2 Basics Python Real Robot Project

Thanks in advance

Hi @vkuehn ,

Good News ! I have finally SOLVED your problem !

@ralves and @albertoezquerro : Please scroll down to see the actual cause of this problem!

All along the problem was the non-ASCII character that I mentioned in the solution of my actual post about this problem. Here: ROSDS - colcon build fails - environment dependency requirement - #8 by girishkumar.kannan

I am going to share you some pictures to understand the problem easily!

The actual cause of this problem:

So, when someone copy-pastes the message file contents from the jupyter notebook into their package’s FindWall.srv file, this problem happens!
The bad thing here is that the online IDE does not show any hidden non-ASCII characters present in the file.
This causes the problem during compilation / building.

THE FIX:
Simply remove / delete the unwanted character from the service message.
@ralves and @albertoezquerro : Also, please delete this on the jupyter notebook, so new students will not have the same issue!

Sorry for the long post (picture is worth a thousand words!)

Cheers and Regards,
Girish

Hi @girishkumar.kannan ,

Thanks a lot for the research !
Unfortunatetly this is not the root cause in my case thought.
I have checked with cat -T to make sure the FindWall.srv does not contain any hidden characters.
However with your python iteration it shows

b'\xe2\x80\x8b\n'
b'---\n'
b'bool wallfound'

I’ll clean and check again

Regards,
Volker

Hi @girishkumar.kannan, @albertoezquerro

checked and Gris is right the hidden character was one issue !
However still the launch is having an issue. I’ll investigate later. But maybe Alberto has more insights ?

Regards,
Volker

Hi @vkuehn ,

If you have the service message package successfully compiled and you still have issues with your package launch, maybe I can still help you out.

Just post the new error (as text) that your are facing.

– Girish

EDIT: I checked the outputs of cat .... Only cat -A works correctly. cat -T only shows tab characters.
The outputs look very weird, that is why I chose to use python.

1 Like

Hi @girishkumar.kannan,

thanks for the offer and the research again !!
Actually

ros2 launch wall_follower wall_following.launch.py

results in

launch.substitutions.substitution_failure.SubstitutionFailure: executable 'wall_following' not found on the libexec directory '/home/user/ros2_ws/install/wall_follower/lib/wall_follower'

even so that the launch file ./launch/wall_following.launch.py has

            package='wall_follower',
            executable='wall_following',

and ~/ros2_ws/src/wall_follower/wall_follower/wall_following.py exists

so it should launch even if it would have a failure, no ?

Regrards,
V

Hi @vkuehn ,

I just referred to your directory tree structure from your above posts.

It seems that your command line is wrong. Your launch file is correct though.

In your wall_follower package, your python file is wall_following.py which is correctly mentioned in launch file’s executable field.

This command line is wrong.

The correct command line would be:
ros2 launch wall_follower wall_follower.launch.py

Try this and let me know if that works!

Regards,
Girish