0
$\begingroup$

I have successfully trained and tested a pointpillars network on my own point cloud dataset using https://github.com/shangjie-li/pointpillars/tree/master. I modified demo_in_ros.py from that repository to apply the trained model for 3D object detection using ROS2 (Humble). I modified setup.py and deom_in_ros.py based on suggestions from this link https://answers.ros.org/question/367793/including-a-python-module-in-a-ros2-package/. I used colcon build and successfully installed all python codes (located in different folders) as modules in ROS2 workspace (ros2_pointpillars) /ros2_pointpillars/install/lidar_object_detection/lib/python3.10/site-packages/lidar_object_detection. I need to use iou3d_nms_cuda.cpython-37m-x86_64-linux-gnu.so which is located in /ops/iou3d_nms folder. How can I install it as a module in ROS2?

I appreciate any help in advance.

#setup.py

from setuptools import setup
package_name = 'lidar_object_detection'
submodules = ['lidar_object_detection.utils',
               'lidar_object_detection.layers.vfe','lidar_object_detection.layers.map_to_bev','lidar_object_detection.layers.backbones_2d','lidar_object_detection.layers.dense_heads',
               'lidar_object_detection.ops.iou3d_nms', 'lidar_object_detection.ops.roiaware_pool3d', 'lidar_object_detection.ops.iou3d_nms.src',
               #'lidar_object_detection.ops.iou3d_nms_cuda',              
               'lidar_object_detection.data', 'lidar_object_detection.data.processor', 'lidar_object_detection.data.kitti_object_eval_python',
               'lidar_object_detection.data.kitti', 'lidar_object_detection.data.augmentor'
               ]


setup(
    name=package_name,
    version='0.0.0',
    packages=[package_name] + submodules,
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='usr',
    maintainer_email='[email protected]',
    description='Object detection',
    license='Apache License 2.0',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
               'subscriber = lidar_object_detection.demo_in_ros:main',
        ],
    },
)

#demo_in_ros.py

import argparse
import glob
from pathlib import Path
import time
import os
import sys
import math
import threading
import rclpy
from std_msgs.msg import Header
from sensor_msgs.msg import PointCloud2
from visualization_msgs.msg import Marker, MarkerArray
import matplotlib.pyplot as plt
import cv2
import numpy as np
import torch

from .ops.iou3d_nms import iou3d_nms_cuda
from .ops.iou3d_nms import iou3d_nms_utils
from .data import cfg, cfg_from_yaml_file
from .data import KittiDataset
from .pointpillar import build_network, load_data_to_gpu
from .utils import common_utils, calibration_kitti
from .utils import opencv_vis_utils
from .utils import numpy_pc2

#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>lidar_object_detection</name>
  <version>0.0.0</version>
  <description>Object detection</description>
  <maintainer email="[email protected]">usr</maintainer>
  <license>Apache License 2.0</license>
  
  <exec_depend>rclpy</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>sensor_msgs</exec_depend>
  <exec_depend>visualization_msgs</exec_depend>

  <test_depend>ament_copyright</test_depend>
  <test_depend>ament_flake8</test_depend>
  <test_depend>ament_pep257</test_depend>
  <test_depend>python3-pytest</test_depend>

  <export>
    <build_type>ament_python</build_type>
  </export>
</package>
$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.