eric-wieser / ros_numpy

Tools for converting ROS messages to and from numpy arrays
MIT License
305 stars 159 forks source link

Instructions on how to run it? #29

Open Petros626 opened 2 years ago

Petros626 commented 2 years ago

Hey,

i want to convert a sensor_msgs/PointCloud2 to a numpy array. So I play a bag file or a stream which is publishing the message and then run the python script to convert it? Would be more user-friendly if better instructions were given.

Thank you

alvaropascuaI commented 2 years ago

Hi, have you been able to start the repository?

Petros626 commented 2 years ago

Hi, have you been able to start the repository?

No 😂

alvaropascuaI commented 2 years ago

I have managed to launch data = ros2_numpy.numpify(msg), what I have done has been to first clone the repository and the content of the file is the following and it shows me this in the print of the data image image

alvaropascuaI commented 2 years ago

What you have to do to get it up and running is to clone the repository and then do the colcon build --packages-select ros2_numpy

an99990 commented 2 years ago

That is what i did and i got the following

--- stderr: ros2_numpy                         
CMake Error at CMakeLists.txt:14 (find_package):
  By not providing "Findament_cmake_nose.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "ament_cmake_nose", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake_nose"
  with any of the following names:

    ament_cmake_noseConfig.cmake
    ament_cmake_nose-config.cmake

  Add the installation prefix of "ament_cmake_nose" to CMAKE_PREFIX_PATH or
  set "ament_cmake_nose_DIR" to a directory containing one of the above
  files.  If "ament_cmake_nose" provides a separate development package or
  SDK, be sure it has been installed.
alvaropascuaI commented 2 years ago

You have to run this command sudo apt install ros-foxy-ament-cmake-nose, when you get more errors like this I recommend that you use apt search ros-foxy- ... + the missing library to be able to install it later, in my case the version of ros was foxy you put the one have

Genozen commented 1 year ago

@alvaropascuaI I have cloned the ros2_numpy form this fork: https://github.com/Box-Robotics/ros2_numpy

After colcon build, I wrote a code to import ros2_numpy.ros2_numpy as rnp but it says no module named 'ros2_numpy` is found...

alvaropascuaI commented 1 year ago

You have to run this command sudo apt install ros-foxy-ament-cmake-nose, when you get more errors like this I recommend that you use apt search ros-foxy- ... + the missing library to be able to install it later, in my case the version of ros was foxy you put the one have

Getting additional error:

CMake Error at CMakeLists.txt:7 (find_package):
  By not providing "Findcatkin.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "catkin", but
  CMake did not find one.

  Could not find a package configuration file provided by "catkin" with any
  of the following names:

    catkinConfig.cmake
    catkin-config.cmake

  Add the installation prefix of "catkin" to CMAKE_PREFIX_PATH or set
  "catkin_DIR" to a directory containing one of the above files.  If "catkin"
  provides a separate development package or SDK, be sure it has been
  installed.

Any suggestions? I've Googled this issue and try qtcreator but no success.

If you have this problem, is because you aren't in the same branch that your ros version

Genozen commented 1 year ago

@alvaropascuaI Thank you for the quick reply.

I'm trying to run your code via python3 test.py with importing ros2_numpy.ros2_numpy' but no module of ros2_numpy is found.

Did you have to create a launch file instead and run something like ros2 launch ros2_numpy test.launch.py?

alvaropascuaI commented 1 year ago

No, now i just got my file up and i just needed to run source /opt/ros/foxy/setup.bash and then run the file with python3 name_file.py, give me more details to know how you get your error

Genozen commented 1 year ago

No, now i just got my file up and i just needed to run source /opt/ros/foxy/setup.bash and then run the file with python3 name_file.py, give me more details to know how you get your error

@alvaropascuaI

That's very strange...

Here are the steps to reproduce my error:

Setup: Ubuntu 22.04, ROS2 Humble

In my ros2_ws/src I cloned the repository from https://github.com/Box-Robotics/ros2_numpy then

cd ~/ros2_ws
colcon build --symlink-install --packages-select ros2_numpy
source /opt/ros/humble/setup.bash

then inside the package /ros2_ws/src/ros2_numpy I created a script test.py with the following code inside:

import ros2_numpy.ros2_numpy as rnp

print('test complete')

and ran python3 test.py in the terminal which results in the error: ModuleNotFoundError: No module named 'ros2_numpy.ros2_numpy

What's also interesting is when I type rnp. my VSCode was able to suggest the methods like rnp.numpify() image

Below is what my ~/ros2_ws/src/ros2_numpy directory look like: image

Genozen commented 1 year ago

Not sure if this is correct, but I found a work-around by simply calling individual scripts: image

image

Hope there's a better way to do it as I'm not sure if I'm missing anything else that's needed (for example the tf_transformation was missing)

alvaropascuaI commented 1 year ago

You do that but you need to launch source before the colcon like this

cd ~/ros2_ws
source /opt/ros/humble/setup.bash
colcon build --symlink-install --packages-select ros2_numpy
alvaropascuaI commented 1 year ago

@Genozen Did you resolve with I told you?