Skip to content

Commit 6280caf

Browse files
committed
Got python version working again and cpp version building.
Still need to test cpp version
1 parent d3feb1b commit 6280caf

File tree

6 files changed

+45
-63
lines changed

6 files changed

+45
-63
lines changed

elevation_mapping_cupy/CMakeLists.txt

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ project(elevation_mapping_cupy)
55
# set(CMAKE_CXX_STANDARD 11)
66
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
77

8+
# Default to C++14
9+
if(NOT CMAKE_CXX_STANDARD)
10+
set(CMAKE_CXX_STANDARD 14)
11+
endif()
12+
813
# Compiler options
914
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1015
add_compile_options(-Wall -Wextra -Wpedantic)
1116
endif()
17+
1218
# Additional dependencies
1319
# find_package(Python COMPONENTS Interpreter Development)
1420
find_package(PythonInterp 3 REQUIRED)
@@ -17,17 +23,17 @@ find_package(Eigen3 REQUIRED)
1723
find_package(OpenCV REQUIRED)
1824

1925
# Find pybind11
20-
2126
message([MAIN] "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
2227
message([MAIN] "pybind11_INCLUDE_DIRS = ${pybind11_INCLUDE_DIRS}")
2328
message([MAIN] "pybind11_LIBRARIES = ${pybind11_LIBRARIES}")
2429

2530
# Find ROS 2 dependencies
26-
find_package(message_filters REQUIRED)
2731
find_package(ament_cmake REQUIRED)
32+
find_package(ament_cmake_python REQUIRED)
2833
find_package(rclcpp REQUIRED)
2934
find_package(rclpy REQUIRED)
3035
find_package(builtin_interfaces REQUIRED)
36+
find_package(message_filters REQUIRED)
3137
find_package(std_msgs REQUIRED)
3238
find_package(std_srvs REQUIRED)
3339
find_package(sensor_msgs REQUIRED)
@@ -38,13 +44,9 @@ find_package(grid_map_ros REQUIRED)
3844
find_package(image_transport REQUIRED)
3945
find_package(pcl_ros REQUIRED)
4046
find_package(tf2_eigen REQUIRED)
41-
find_package(ament_cmake_python REQUIRED)
4247
find_package(python_cmake_module REQUIRED)
4348
find_package(point_cloud_transport REQUIRED)
4449

45-
_ament_cmake_python_register_environment_hook()
46-
ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR script/${PROJECT_NAME})
47-
4850
# List dependencies for ament_target_dependencies
4951
set(dependencies
5052
rclcpp
@@ -92,52 +94,39 @@ target_link_libraries(elevation_mapping_node elevation_mapping_ros ${OpenCV_LIBR
9294
ament_target_dependencies(elevation_mapping_node ${dependencies})
9395

9496

97+
# Install targets Not sure if these other argrs are necessary
98+
# install(
99+
# TARGETS elevation_mapping_ros elevation_mapping_node
100+
# DESTINATION lib/${PROJECT_NAME}
101+
# ARCHIVE DESTINATION lib
102+
# LIBRARY DESTINATION lib
103+
# RUNTIME DESTINATION bin
104+
# )
95105

96-
# Install targets
97-
install(
98-
TARGETS elevation_mapping_node
99-
DESTINATION lib/${PROJECT_NAME}
100-
ARCHIVE DESTINATION lib
101-
LIBRARY DESTINATION lib
102-
RUNTIME DESTINATION bin
103-
)
104-
105-
106-
install(TARGETS
107-
elevation_mapping_node
106+
install(TARGETS elevation_mapping_ros elevation_mapping_node
108107
DESTINATION lib/${PROJECT_NAME}
109108
)
110109

110+
# install(PROGRAMS
111+
# DESTINATION lib/${PROJECT_NAME}
112+
# )
111113

114+
# Install launch, config, and rviz directories
112115
install(
113-
TARGETS elevation_mapping_ros
114-
DESTINATION lib/${PROJECT_NAME}
115-
ARCHIVE DESTINATION lib
116-
LIBRARY DESTINATION lib
117-
RUNTIME DESTINATION bin
116+
DIRECTORY launch config rviz
117+
DESTINATION share/${PROJECT_NAME}
118118
)
119119

120+
# TODO: Understand if this line is necessary
121+
# _ament_cmake_python_register_environment_hook()
122+
# For use as a Python module outside of ROS 2
123+
ament_python_install_package(${PROJECT_NAME})
120124

121-
122-
123-
install(PROGRAMS
125+
# Install the Python ROS 2 modules
126+
install(PROGRAMS
127+
scripts/elevation_mapping_node.py
124128
DESTINATION lib/${PROJECT_NAME}
125129
)
126130

127-
# Install launch and config directories
128-
install(
129-
DIRECTORY launch config
130-
DESTINATION share/${PROJECT_NAME}
131-
)
132-
133-
134-
135-
_ament_cmake_python_register_environment_hook()
136-
137-
138-
# ament_python_install_package(script/${PROJECT_NAME})
139-
# ament_python_install_package(script/${PROJECT_NAME})
140-
141-
142131
# Ament package declaration
143132
ament_package()

elevation_mapping_cupy/elevation_mapping_cupy/elevation_mapping.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import os
66
from typing import List, Any, Tuple, Union
77

8-
import rclpy # Import rclpy for ROS 2 logging
9-
from ament_index_python.packages import get_package_prefix
108
import numpy as np
119
import threading
1210
import subprocess
@@ -17,7 +15,6 @@
1715
)
1816
from elevation_mapping_cupy.parameter import Parameter
1917

20-
2118
from elevation_mapping_cupy.kernels import (
2219
add_points_kernel,
2320
add_color_kernel,
@@ -44,6 +41,7 @@
4441
)
4542

4643
import cupy as cp
44+
import rclpy # Import rclpy for ROS 2 logging
4745

4846
xp = cp
4947
pool = cp.cuda.MemoryPool(cp.cuda.malloc_managed)
@@ -61,6 +59,7 @@ def __init__(self, param: Parameter):
6159
"""
6260
# Initialize the ROS logger
6361
self.logger = rclpy.logging.get_logger('elevation_map')
62+
6463
self.param = param
6564
self.data_type = self.param.data_type
6665
self.resolution = param.resolution
@@ -101,29 +100,24 @@ def __init__(self, param: Parameter):
101100
self.additive_mean_error = 0.0
102101

103102
self.compile_kernels()
104-
self.logger.info("Finished compiling kernels.")
103+
105104
self.compile_image_kernels()
106-
self.logger.info("Finished compiling image kernels.")
105+
107106
self.semantic_map.initialize_fusion()
108-
self.logger.info("Finished compiling semantic_map kernels.")
109107

110108
weight_file = subprocess.getoutput('echo "' + param.weight_file + '"')
111-
package_prefix = get_package_prefix('elevation_mapping_cupy')
112-
self.logger.info("weight file : ." + str(package_prefix) + str(weight_file))
113-
param.load_weights(package_prefix+weight_file)
109+
param.load_weights(weight_file)
114110

115111
if param.use_chainer:
116112
self.traversability_filter = get_filter_chainer(param.w1, param.w2, param.w3, param.w_out)
117113
else:
118114
self.traversability_filter = get_filter_torch(param.w1, param.w2, param.w3, param.w_out)
119-
120115
self.untraversable_polygon = xp.zeros((1, 2))
121116

122117
# Plugins
123118
self.plugin_manager = PluginManager(cell_n=self.cell_n)
124119
plugin_config_file = subprocess.getoutput('echo "' + param.plugin_config_file + '"')
125-
self.logger.info("plugin file : ." + str(package_prefix) + str(plugin_config_file))
126-
self.plugin_manager.load_plugin_settings(package_prefix+plugin_config_file)
120+
self.plugin_manager.load_plugin_settings(plugin_config_file)
127121

128122
self.map_initializer = MapInitializer(self.initial_variance, param.initialized_variance, xp=cp, method="points")
129123

@@ -359,7 +353,7 @@ def update_map_with_kernel(self, points_all, channels, R, t, position_noise, ori
359353
error = cp.array([0.0], dtype=cp.float32)
360354
error_cnt = cp.array([0], dtype=cp.float32)
361355
points = points_all[:, :3]
362-
# additional_fusion = self.get_fusion_of_pcl(channels)
356+
363357
with self.map_lock:
364358
self.shift_translation_to_map_center(t)
365359

@@ -982,8 +976,7 @@ def initialize_map(self, points, method="cubic"):
982976
plugin_config_file="../config/plugin_config.yaml",
983977
)
984978
param.additional_layers = ["rgb", "grass", "tree", "people"]
985-
# param.fusion_algorithms = ["color", "class_bayesian", "class_bayesian", "class_bayesian"]
986-
param.fusion_algorithms = ["image_color", "pointcloud_color", "pointcloud_class_average"]
979+
param.fusion_algorithms = ["color", "class_bayesian", "class_bayesian", "class_bayesian"]
987980
param.update()
988981
elevation = ElevationMap(param)
989982
layers = [

elevation_mapping_cupy/launch/elevation_mapping_turtle.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def generate_launch_description():
4747
)
4848
elevation_mapping_node = Node(
4949
package='elevation_mapping_cupy',
50-
executable='elevation_mapping_node',
50+
executable='elevation_mapping_node.py',
5151
name='elevation_mapping_node',
5252
output='screen',
5353
parameters=[

elevation_mapping_cupy/package.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<description>Elevation mapping on GPU</description>
66
<maintainer email="[email protected]">Takahiro Miki</maintainer>
77
<license>MIT</license>
8+
89
<buildtool_depend>ament_cmake</buildtool_depend>
910
<buildtool_depend>ament_cmake_python</buildtool_depend>
1011

@@ -15,7 +16,8 @@
1516
<depend>std_srvs</depend>
1617
<depend>sensor_msgs</depend>
1718
<depend>geometry_msgs</depend>
18-
<depend>point_cloud_transport</depend>
19+
<!-- Might need to remove point_cloud_transport if not used -->
20+
<depend>point_cloud_transport</depend>
1921
<depend>message_filters</depend>
2022
<depend>elevation_map_msgs</depend>
2123
<depend>grid_map_msgs</depend>
@@ -28,7 +30,6 @@
2830
<!-- Numpy version needs to be <2.0.0 -->
2931
<depend>numpy</depend>
3032
<depend>tf2_ros</depend>
31-
<depend>message_filters</depend>
3233
<depend>cv_bridge</depend>
3334
<depend>ament_index_python</depend>
3435
<depend>tf_transformations</depend>
@@ -47,15 +48,14 @@
4748
<depend>simple-parsing</depend>
4849

4950
<!-- Export dependencies -->
50-
<!-- Might need to change to ament_cmake_python -->
51-
<build_export_depend>ament_python</build_export_depend>
52-
<exec_depend>ament_python</exec_depend>
51+
<!-- <build_export_depend>ament_cmake_python</build_export_depend> -->
52+
<!-- <exec_depend>ament_cmake_python</exec_depend> -->
5353

5454
<test_depend>ament_lint_auto</test_depend>
5555
<test_depend>ament_lint_common</test_depend>
5656

5757
<export>
58-
<build_type>ament_python</build_type>
58+
<!-- <build_type>ament_cmake_python</build_type> -->
5959
<build_type>ament_cmake</build_type>
6060
</export>
6161

elevation_mapping_cupy/resource/elevation_mapping_cupy

Whitespace-only changes.

0 commit comments

Comments
 (0)