Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ __pycache__
.vscode/

watod-config.local.sh
utils/voxel/spconv
13 changes: 13 additions & 0 deletions autonomy/behaviour/octo_map/launch/octo_map.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from launch import LaunchDescription
import launch_ros.actions


def generate_launch_description():
return LaunchDescription([
launch_ros.actions.Node(
name='octo_map_node',
package='octo_map',
executable='octo_map_node',
output='screen',
emulate_tty=True),
])
75 changes: 75 additions & 0 deletions autonomy/behaviour/octo_map/octo_map/octo_map_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import rclpy
from rclpy.node import Node
import numpy as np
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'np' is not used.

Suggested change
import numpy as np

Copilot uses AI. Check for mistakes.
import torch
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'torch' is not used.

Suggested change
import torch

Copilot uses AI. Check for mistakes.
from spconv.pytorch.utils import PointToVoxel
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'PointToVoxel' is not used.

Suggested change
from spconv.pytorch.utils import PointToVoxel

Copilot uses AI. Check for mistakes.
import cv2
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'cv2' is not used.

Suggested change
import cv2

Copilot uses AI. Check for mistakes.
from cv_bridge import CvBridge

from sensor_msgs.msg import Image, PointCloud2, PointField, CameraInfo
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'PointField' is not used.

Suggested change
from sensor_msgs.msg import Image, PointCloud2, PointField, CameraInfo
from sensor_msgs.msg import Image, PointCloud2, CameraInfo

Copilot uses AI. Check for mistakes.
from std_msgs.msg import Header
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'Header' is not used.

Suggested change
from std_msgs.msg import Header

Copilot uses AI. Check for mistakes.
import sensor_msgs_py.point_cloud2 as pc2
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'pc2' is not used.

Suggested change
import sensor_msgs_py.point_cloud2 as pc2

Copilot uses AI. Check for mistakes.

class OctoMapNode(Node):
def __init__(self):
super().__init__('octo_map_node')

# Subscribe to processed perception data
self.rgb_sub = self.create_subscription(
Image, '/perception/rgb_processed', self.rgb_callback, 10)
self.depth_sub = self.create_subscription(
Image, '/perception/depth_processed', self.depth_callback, 10)
self.info_sub = self.create_subscription(
CameraInfo, '/perception/camera_info', self.info_callback, 10)

self.octo_pub = self.create_publisher(PointCloud2, '/behaviour/octo_map', 10)

self.rgb_image = None
self.depth_image = None
self.bridge = CvBridge()

# Camera intrinsics (will be updated from camera info)
self.fx, self.fy, self.cx, self.cy = 525.0, 525.0, 320.0, 240.0

self.voxel_size = 0.04
self.max_range = 3.5

self.get_logger().info('OctoMap Node started - subscribing to processed perception data')

def info_callback(self, msg):
"""Update camera intrinsics from perception node."""
self.fx = msg.k[0]
self.fy = msg.k[4]
self.cx = msg.k[2]
self.cy = msg.k[5]
self.get_logger().info(f'Updated camera intrinsics: fx={self.fx}, fy={self.fy}')

def rgb_callback(self, msg):
"""Receive processed RGB image from perception node."""
self.rgb_image = self.bridge.imgmsg_to_cv2(msg, 'bgr8')
self.process_rgbd_if_ready()
self.get_logger().info('Received processed RGB image from perception')

def depth_callback(self, msg):
"""Receive processed depth image from perception node."""
self.depth_image = self.bridge.imgmsg_to_cv2(msg, 'passthrough')
self.process_rgbd_if_ready()
self.get_logger().info('Received processed depth image from perception')

Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The process_rgbd_if_ready method is called but never defined in this file. This will cause a runtime error when the callback is triggered.

Suggested change
def process_rgbd_if_ready(self):
"""
Process RGB-D data when both images are available.
This is a placeholder implementation to prevent runtime errors when
the RGB and depth callbacks are triggered. Point cloud generation and
octomap updating logic should be implemented here.
"""
# Ensure both RGB and depth images have been received
if self.rgb_image is None or self.depth_image is None:
return
# Placeholder: actual point cloud generation and octomap updating
# should be implemented here in the future.
self.get_logger().debug(
'process_rgbd_if_ready called, but point cloud generation is not implemented yet.'
)

Copilot uses AI. Check for mistakes.
# TODO: Implement point cloud generation and octomap updating


def main(args=None):
rclpy.init(args=args)
node = OctoMapNode()

try:
rclpy.spin(node)
except KeyboardInterrupt:
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'except' clause does nothing but pass and there is no explanatory comment.

Suggested change
except KeyboardInterrupt:
except KeyboardInterrupt:
# Allow clean shutdown on Ctrl+C; cleanup is handled in the finally block.

Copilot uses AI. Check for mistakes.
pass
finally:
node.destroy_node()
rclpy.shutdown()

if __name__ == '__main__':
main()
20 changes: 20 additions & 0 deletions autonomy/behaviour/octo_map/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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>octo_map</name>
<version>0.0.0</version>
<description>OctoMap generation for 3D mapping</description>
<maintainer email="watonomous@uwaterloo.ca">watonomous</maintainer>
<license>Apache-2.0</license>

<depend>rclpy</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>
1 change: 1 addition & 0 deletions autonomy/behaviour/octo_map/resource/octo_map
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
voxel_grid
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect resource file content. The file should contain 'octo_map' but it contains 'voxel_grid' instead. This is likely a copy-paste error.

Suggested change
voxel_grid
octo_map

Copilot uses AI. Check for mistakes.
4 changes: 4 additions & 0 deletions autonomy/behaviour/octo_map/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script-dir=$base/lib/voxel_grid
[install]
install-scripts=$base/lib/voxel_grid
Comment on lines +2 to +4
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect paths in setup.cfg. The script_dir and install_scripts paths reference 'voxel_grid' but this is the octo_map package. They should reference 'octo_map' instead.

Suggested change
script-dir=$base/lib/voxel_grid
[install]
install-scripts=$base/lib/voxel_grid
script-dir=$base/lib/octo_map
[install]
install-scripts=$base/lib/octo_map

Copilot uses AI. Check for mistakes.
35 changes: 35 additions & 0 deletions autonomy/behaviour/octo_map/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
from glob import glob
from setuptools import setup

package_name = 'octo_map'

setup(
name=package_name,
version='0.0.0',
packages=[package_name],
data_files=[
# Install marker file in the package index
('share/ament_index/resource_index/packages', ['resource/' + package_name]),
# Include our package.xml file
(os.path.join('share', package_name), ['package.xml']),
# Include all launch files.
(os.path.join('share', package_name, 'launch'),
glob(os.path.join('launch', '*.launch.py'))),
# Include all config files.
(os.path.join('share', package_name, 'config'),
glob(os.path.join('config', '*.yaml'))),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='watonomous',
maintainer_email='watonomous@uwaterloo.ca',
description='OctoMap generation for 3D mapping',
license='Apache-2.0',
tests_require=['pytest'],
entry_points={
'console_scripts': [
'octo_map_node = octo_map.octo_map_node:main'
],
},
)
13 changes: 13 additions & 0 deletions autonomy/behaviour/voxel_grid/launch/voxel_grid.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from launch import LaunchDescription
import launch_ros.actions


def generate_launch_description():
return LaunchDescription([
launch_ros.actions.Node(
name='voxel_grid_node',
package='voxel_grid',
executable='voxel_grid_node',
output='screen',
emulate_tty=True),
])
20 changes: 20 additions & 0 deletions autonomy/behaviour/voxel_grid/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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>voxel_grid</name>
<version>0.0.0</version>
<description>Voxel grid generation for depth camera data</description>
<maintainer email="watonomous@uwaterloo.ca">watonomous</maintainer>
<license>Apache-2.0</license>

<depend>rclpy</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>
1 change: 1 addition & 0 deletions autonomy/behaviour/voxel_grid/resource/voxel_grid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
voxel_grid
4 changes: 4 additions & 0 deletions autonomy/behaviour/voxel_grid/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script-dir=$base/lib/voxel_grid
[install]
install-scripts=$base/lib/voxel_grid
35 changes: 35 additions & 0 deletions autonomy/behaviour/voxel_grid/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
from glob import glob
from setuptools import setup

package_name = 'voxel_grid'

setup(
name=package_name,
version='0.0.0',
packages=[package_name],
data_files=[
# Install marker file in the package index
('share/ament_index/resource_index/packages', ['resource/' + package_name]),
# Include our package.xml file
(os.path.join('share', package_name), ['package.xml']),
# Include all launch files.
(os.path.join('share', package_name, 'launch'),
glob(os.path.join('launch', '*.launch.py'))),
# Include all config files.
(os.path.join('share', package_name, 'config'),
glob(os.path.join('config', '*.yaml'))),
],
install_requires=['setuptools'],
zip_safe=True,
maintainer='watonomous',
maintainer_email='watonomous@uwaterloo.ca',
description='Voxel grid generation for depth camera data',
license='Apache-2.0',
tests_require=['pytest'],
entry_points={
'console_scripts': [
'voxel_grid_node = voxel_grid.voxel_grid_node:main'
],
},
)
Loading
Loading