迁移数据采集节点至vision_tools,修改点下采样参数
This commit is contained in:
@@ -25,6 +25,6 @@
|
||||
"PCA_configs": {
|
||||
"depth_scale": 1000.0,
|
||||
"depth_trunc": 3.0,
|
||||
"voxel_size": 0.010
|
||||
"voxel_size": 0.001
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ setup(
|
||||
('share/' + package_name + '/configs/flexiv_configs', glob('configs/flexiv_configs/*.json')),
|
||||
('share/' + package_name + '/configs/hand_eye_mat', glob('configs/hand_eye_mat/*.json')),
|
||||
('share/' + package_name + '/configs/launch_configs', glob('configs/launch_configs/*.json')),
|
||||
('share/' + package_name + '/configs/other_configs', glob('configs/other_configs/*.json')),
|
||||
|
||||
('share/' + package_name + '/checkpoints', glob('checkpoints/*.pt')),
|
||||
('share/' + package_name + '/checkpoints', glob('checkpoints/*.onnx')),
|
||||
@@ -43,9 +42,6 @@ setup(
|
||||
'get_camera_pose_node = vision_detect.get_camera_pose:main',
|
||||
|
||||
'detect_node = vision_detect.detect_node:main',
|
||||
|
||||
'collect_data_node = vision_detect.collect_data_node:main',
|
||||
'collect_data_client = vision_detect.collect_data_client:main',
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""计算工具"""
|
||||
import logging
|
||||
|
||||
import cv2
|
||||
# import cv2
|
||||
import numpy as np
|
||||
import open3d as o3d
|
||||
import transforms3d as tfs
|
||||
@@ -53,7 +53,7 @@ def calculate_pose_pca(
|
||||
depth_trunc=kwargs.get("depth_trunc", 3.0),
|
||||
)
|
||||
|
||||
point_cloud = point_cloud_denoising(point_cloud, kwargs.get("voxel_size", 0.005))
|
||||
point_cloud = point_cloud_denoising(point_cloud, kwargs.get("voxel_size", 0.002))
|
||||
if point_cloud is None:
|
||||
return None, [0.0, 0.0, 0.0]
|
||||
|
||||
@@ -158,11 +158,11 @@ def point_cloud_denoising(point_cloud: o3d.geometry.PointCloud, voxel_size: floa
|
||||
"""点云去噪"""
|
||||
point_cloud = point_cloud.remove_non_finite_points()
|
||||
while True:
|
||||
down_pcd = point_cloud.voxel_down_sample(voxel_size=voxel_size * 0.5)
|
||||
down_pcd = point_cloud.voxel_down_sample(voxel_size=voxel_size)
|
||||
point_num = len(down_pcd.points)
|
||||
if point_num <= 1000:
|
||||
break
|
||||
voxel_size *= 2
|
||||
voxel_size *= 4
|
||||
|
||||
# logging.fatal("point_cloud_denoising: point_num={}".format(len(point_cloud.points)))
|
||||
# logging.fatal("point_cloud_denoising: point_num={}".format(point_num))
|
||||
@@ -170,7 +170,7 @@ def point_cloud_denoising(point_cloud: o3d.geometry.PointCloud, voxel_size: floa
|
||||
# 半径滤波
|
||||
clean_pcd, _ = down_pcd.remove_radius_outlier(
|
||||
nb_points=10,
|
||||
radius=voxel_size * 5
|
||||
radius=voxel_size * 10
|
||||
)
|
||||
|
||||
# 统计滤波
|
||||
@@ -189,7 +189,7 @@ def point_cloud_denoising(point_cloud: o3d.geometry.PointCloud, voxel_size: floa
|
||||
# if largest_cluster_ratio < 0.5:
|
||||
# return None
|
||||
|
||||
labels = np.array(clean_pcd.cluster_dbscan(eps=voxel_size * 5, min_points=10))
|
||||
labels = np.array(clean_pcd.cluster_dbscan(eps=voxel_size * 10, min_points=10))
|
||||
if len(labels[labels >= 0]) == 0:
|
||||
return clean_pcd
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"save_path": "/collect_data",
|
||||
"save_path": "collect_data",
|
||||
"left": {
|
||||
"color": "/camera/camera/color/image_raw",
|
||||
"depth": "/camera/camera/aligned_depth_to_color/image_raw",
|
||||
20
vision_tools/package.xml
Normal file
20
vision_tools/package.xml
Normal file
@@ -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>vision_tools</name>
|
||||
<version>0.0.0</version>
|
||||
<description>TODO: Package description</description>
|
||||
<maintainer email="16126883+liangyuxuan123@user.noreply.gitee.com">lyx</maintainer>
|
||||
<license>TODO: License declaration</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>
|
||||
0
vision_tools/resource/vision_tools
Normal file
0
vision_tools/resource/vision_tools
Normal file
4
vision_tools/setup.cfg
Normal file
4
vision_tools/setup.cfg
Normal file
@@ -0,0 +1,4 @@
|
||||
[develop]
|
||||
script_dir=$base/lib/vision_tools
|
||||
[install]
|
||||
install_scripts=$base/lib/vision_tools
|
||||
28
vision_tools/setup.py
Normal file
28
vision_tools/setup.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from glob import glob
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
package_name = 'vision_tools'
|
||||
|
||||
setup(
|
||||
name=package_name,
|
||||
version='0.0.0',
|
||||
packages=find_packages(exclude=['test']),
|
||||
data_files=[
|
||||
('share/ament_index/resource_index/packages', ['resource/' + package_name]),
|
||||
('share/' + package_name, ['package.xml']),
|
||||
('share/' + package_name + '/configs', glob('configs/*.json')),
|
||||
],
|
||||
install_requires=['setuptools'],
|
||||
zip_safe=True,
|
||||
maintainer='lyx',
|
||||
maintainer_email='lyx@todo.todo',
|
||||
description='TODO: Package description',
|
||||
license='TODO: License declaration',
|
||||
tests_require=['pytest'],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'collect_data_node = vision_tools.collect_data_node:main',
|
||||
'collect_data_client = vision_tools.collect_data_client:main',
|
||||
],
|
||||
},
|
||||
)
|
||||
25
vision_tools/test/test_copyright.py
Normal file
25
vision_tools/test/test_copyright.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# Copyright 2015 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from ament_copyright.main import main
|
||||
import pytest
|
||||
|
||||
|
||||
# Remove the `skip` decorator once the source file(s) have a copyright header
|
||||
@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.')
|
||||
@pytest.mark.copyright
|
||||
@pytest.mark.linter
|
||||
def test_copyright():
|
||||
rc = main(argv=['.', 'test'])
|
||||
assert rc == 0, 'Found errors'
|
||||
25
vision_tools/test/test_flake8.py
Normal file
25
vision_tools/test/test_flake8.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# Copyright 2017 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from ament_flake8.main import main_with_errors
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.flake8
|
||||
@pytest.mark.linter
|
||||
def test_flake8():
|
||||
rc, errors = main_with_errors(argv=[])
|
||||
assert rc == 0, \
|
||||
'Found %d code style errors / warnings:\n' % len(errors) + \
|
||||
'\n'.join(errors)
|
||||
23
vision_tools/test/test_pep257.py
Normal file
23
vision_tools/test/test_pep257.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Copyright 2015 Open Source Robotics Foundation, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from ament_pep257.main import main
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.linter
|
||||
@pytest.mark.pep257
|
||||
def test_pep257():
|
||||
rc = main(argv=['.', 'test'])
|
||||
assert rc == 0, 'Found code style errors / warnings'
|
||||
0
vision_tools/vision_tools/__init__.py
Normal file
0
vision_tools/vision_tools/__init__.py
Normal file
@@ -13,7 +13,7 @@ from sensor_msgs.msg import Image, CameraInfo
|
||||
from std_srvs.srv import SetBool
|
||||
|
||||
|
||||
share_dir = get_package_share_directory('vision_detect')
|
||||
share_dir = get_package_share_directory('vision_tools')
|
||||
|
||||
class CollectDataNode(Node):
|
||||
def __init__(self):
|
||||
@@ -56,7 +56,7 @@ class CollectDataNode(Node):
|
||||
self.left_writer_initialized = False
|
||||
self.head_writer_initialized = False
|
||||
|
||||
with open(os.path.join(share_dir, 'configs/other_configs/collect_data_node.json'), 'r')as f:
|
||||
with open(os.path.join(share_dir, 'configs/collect_data_node.json'), 'r')as f:
|
||||
configs = json.load(f)
|
||||
|
||||
home_path = os.path.expanduser("~")
|
||||
@@ -117,6 +117,7 @@ class CollectDataNode(Node):
|
||||
|
||||
|
||||
self.service = self.create_service(SetBool, "/collect_data", self.service_callback)
|
||||
self.get_logger().info("Success start")
|
||||
|
||||
def service_callback(self, request, response):
|
||||
# Start collect data
|
||||
@@ -203,6 +204,7 @@ class CollectDataNode(Node):
|
||||
self.collect_sign = True
|
||||
response.success = True
|
||||
response.message = "start collecting data"
|
||||
self.get_logger().info("start collecting data")
|
||||
return response
|
||||
|
||||
if self.left_sign:
|
||||
@@ -269,6 +271,7 @@ class CollectDataNode(Node):
|
||||
self.save_sign = True
|
||||
response.success = False
|
||||
response.message = "stop collecting data"
|
||||
self.get_logger().info("stop collecting data")
|
||||
return response
|
||||
|
||||
def left_callback(self, color_msg, depth_msg):
|
||||
Reference in New Issue
Block a user