mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-09-14 20:10:19 +08:00
Fix point cloud direction
This commit is contained in:
@@ -62,30 +62,44 @@ sudo make install
|
||||
sudo ldconfig
|
||||
```
|
||||
|
||||
Install `ORBBEC_SDK`
|
||||
Install `ORBBEC_SDK`,First remove old one if you have installed, **BE CAREFUL**
|
||||
|
||||
```bash
|
||||
# remove old(If you have already installed
|
||||
cd /usr/local/lib/
|
||||
sudo rm libOrbbecSDK.so* # BE CAREFUL
|
||||
sudo rm libpostfilter.so
|
||||
cd /usr/local/include/
|
||||
sudo rm -fr libobsensor
|
||||
|
||||
# install
|
||||
cd orbbec_camera/dependencies
|
||||
tar -xzvf sensor_sdk_v1.2.8_linux.tar.gz
|
||||
cd SDK/lib
|
||||
sudo cp libOrbbecSDK.so.1.2.8 libpostfilter.so /usr/local/lib
|
||||
sudo cp libOrbbecSDK.so.1.2.8 /usr/local/lib
|
||||
sudo cp libpostfilter.so /usr/local/lib
|
||||
sudo ln -s /usr/local/lib/libOrbbecSDK.so.1.2.8 /usr/local/lib/libOrbbecSDK.so.1.2
|
||||
sudo ln -s /usr/local/lib/libOrbbecSDK.so.1.2.8 /usr/local/lib/libOrbbecSDK.so
|
||||
cd ../include
|
||||
sudo cp -frd libobsensor /usr/local/include
|
||||
sudo ldconfig
|
||||
```
|
||||
Build
|
||||
---
|
||||
|
||||
## Getting start
|
||||
|
||||
---
|
||||
|
||||
```bash
|
||||
cd ~/ros2_ws/
|
||||
colcon build --event-handlers console_direct+
|
||||
# build release, Default is Debug
|
||||
colcon build --event-handlers console_direct+ -DCMAKE_BUILD_TYPE=Release
|
||||
```
|
||||
Launch camera node
|
||||
* On terminal 1
|
||||
```bash
|
||||
. ./install/setup.bash
|
||||
ros2 launch orbbec_camera orbbec.launch.py
|
||||
ros2 launch orbbec_camera ob_camera.launch.py
|
||||
```
|
||||
* On terminal 2
|
||||
|
||||
@@ -101,12 +115,6 @@ ros2 service list
|
||||
ros2 param list
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Camera control && Information service
|
||||
|
||||
---
|
||||
|
||||
* Show depth to color extrinsic
|
||||
|
||||
```bash
|
||||
@@ -115,19 +123,19 @@ ros2 topic echo --qos-durability=transient_local /camera/extrinsic/depth_to_colo
|
||||
* Get device info
|
||||
|
||||
```bash
|
||||
ros2 service call /camera/get_device_info orbbec_camera_msgs/srv/GetDeviceInfo "{}"
|
||||
ros2 service call /camera/get_device_info orbbec_camera_msgs/srv/GetDeviceInfo '{}'
|
||||
```
|
||||
* Get SDK version
|
||||
|
||||
```bash
|
||||
ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString "{}"
|
||||
ros2 service call /camera/get_sdk_version orbbec_camera_msgs/srv/GetString '{}'
|
||||
|
||||
```
|
||||
|
||||
* Get exposure
|
||||
|
||||
```bash
|
||||
ros2 service call /camera/get_color_exposure orbbec_camera_msgs/srv/GetInt32 "{}"
|
||||
ros2 service call /camera/get_color_exposure orbbec_camera_msgs/srv/GetInt32 '{}'
|
||||
```
|
||||
> If your check `ir` or `depth`, please change ` /camera/get_color_exposure`
|
||||
to `/camera/get_ir_exposure` or `/camera/get_depth_exposure`, Same below.
|
||||
@@ -135,12 +143,12 @@ to `/camera/get_ir_exposure` or `/camera/get_depth_exposure`, Same below.
|
||||
* Get gain
|
||||
|
||||
```bash
|
||||
ros2 service call /camera/get_color_gain orbbec_camera_msgs/srv/GetInt32 "{}"
|
||||
ros2 service call /camera/get_color_gain orbbec_camera_msgs/srv/GetInt32 '{}'
|
||||
```
|
||||
* Get white balance
|
||||
|
||||
```bash
|
||||
ros2 service call /camera/get_white_balance orbbec_camera_msgs/srv/GetInt32 "{}"
|
||||
ros2 service call /camera/get_white_balance orbbec_camera_msgs/srv/GetInt32 '{}'
|
||||
```
|
||||
|
||||
* Set auto exposure
|
||||
@@ -153,3 +161,7 @@ ros2 service call /camera/set_color_auto_exposure std_srvs/srv/SetBool '{data: f
|
||||
```bash
|
||||
ros2 service call /camera/set_white_balance orbbec_camera_msgs/srv/SetInt32 '{data: 4600}'
|
||||
```
|
||||
|
||||
---
|
||||
## Known issues
|
||||
* TODO:
|
||||
|
||||
@@ -8,7 +8,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-variable -Wno-unused-parameter -Werror)
|
||||
add_compile_options(-Wall -Wextra -Wpedantic -Werror)
|
||||
endif ()
|
||||
|
||||
# find dependencies
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#define OB_ROS_MAJOR_VERSION 1
|
||||
#define OB_ROS_MINOR_VERSION 0
|
||||
#define OB_ROS_PATCH_VERSION 0
|
||||
#define OB_ROS_PATCH_VERSION 1
|
||||
|
||||
#ifndef STRINGIFY
|
||||
#define STRINGIFY(arg) #arg
|
||||
|
||||
@@ -123,7 +123,9 @@ class OBCameraNode {
|
||||
|
||||
void setupPublishers();
|
||||
|
||||
void updateStreamCalibData();
|
||||
void setupDefaultStreamCalibData();
|
||||
|
||||
void updateStreamCalibData(const OBCameraParam& param);
|
||||
|
||||
void publishStaticTF(const rclcpp::Time& t, const std::vector<float>& trans,
|
||||
const tf2::Quaternion& q, const std::string& from, const std::string& to);
|
||||
@@ -160,12 +162,10 @@ class OBCameraNode {
|
||||
std::shared_ptr<SetInt32::Response>& response,
|
||||
const stream_index_pair& stream_index);
|
||||
|
||||
void getWhiteBalanceCallback(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<GetInt32::Request>& request,
|
||||
void getWhiteBalanceCallback(const std::shared_ptr<GetInt32::Request>& request,
|
||||
std::shared_ptr<GetInt32::Response>& response);
|
||||
|
||||
void setWhiteBalanceCallback(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<SetInt32 ::Request>& request,
|
||||
void setWhiteBalanceCallback(const std::shared_ptr<SetInt32 ::Request>& request,
|
||||
std::shared_ptr<SetInt32 ::Response>& response);
|
||||
|
||||
void setAutoExposureCallback(const std::shared_ptr<std_srvs::srv::SetBool::Request>& request,
|
||||
@@ -184,16 +184,13 @@ class OBCameraNode {
|
||||
const std::shared_ptr<std_srvs::srv::SetBool::Request>& request,
|
||||
std::shared_ptr<std_srvs::srv::SetBool::Response>& response);
|
||||
|
||||
void setFanModeCallback(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<SetInt32::Request>& request,
|
||||
void setFanModeCallback(const std::shared_ptr<SetInt32::Request>& request,
|
||||
std::shared_ptr<SetInt32::Response>& response);
|
||||
|
||||
void getDeviceInfoCallback(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<GetDeviceInfo::Request>& request,
|
||||
void getDeviceInfoCallback(const std::shared_ptr<GetDeviceInfo::Request>& request,
|
||||
std::shared_ptr<GetDeviceInfo::Response>& response);
|
||||
|
||||
void getSDKVersion(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<GetString::Request>& request,
|
||||
void getSDKVersion(const std::shared_ptr<GetString::Request>& request,
|
||||
std::shared_ptr<GetString::Response>& response);
|
||||
|
||||
void publishPointCloud(std::shared_ptr<ob::FrameSet> frame_set);
|
||||
@@ -218,8 +215,8 @@ class OBCameraNode {
|
||||
std::shared_ptr<Parameters> parameters_;
|
||||
rclcpp::Logger logger_;
|
||||
std::atomic_bool is_running_{false};
|
||||
std::unique_ptr<ob::Pipeline> pipeline_;
|
||||
std::shared_ptr<ob::Config> config_;
|
||||
std::unique_ptr<ob::Pipeline> pipeline_ = nullptr;
|
||||
std::shared_ptr<ob::Config> config_ = nullptr;
|
||||
std::map<stream_index_pair, std::shared_ptr<ob::Sensor>> sensors_;
|
||||
std::map<stream_index_pair, ob_camera_intrinsic> stream_intrinsics_;
|
||||
std::map<stream_index_pair, sensor_msgs::msg::CameraInfo> camera_infos_;
|
||||
@@ -230,8 +227,8 @@ class OBCameraNode {
|
||||
std::map<stream_index_pair, std::string> frame_id_;
|
||||
std::map<stream_index_pair, std::string> optical_frame_id_;
|
||||
std::map<stream_index_pair, std::string> depth_aligned_frame_id_;
|
||||
std::string base_frame_id_;
|
||||
bool align_depth_;
|
||||
std::string camera_link_frame_id_;
|
||||
bool align_depth_ = false;
|
||||
bool publish_rgb_point_cloud_;
|
||||
std::string d2c_mode_; // sw, hw, none
|
||||
std::map<stream_index_pair, std::string> qos_;
|
||||
@@ -261,7 +258,7 @@ class OBCameraNode {
|
||||
std::map<stream_index_pair, rclcpp::Service<SetInt32>::SharedPtr> set_gain_srv_;
|
||||
rclcpp::Service<GetInt32>::SharedPtr get_white_balance_srv_; // only rgb
|
||||
rclcpp::Service<SetInt32>::SharedPtr set_white_balance_srv_;
|
||||
rclcpp::Service<GetString>::SharedPtr get_api_version_srv_;
|
||||
rclcpp::Service<GetString>::SharedPtr get_sdk_version_srv_;
|
||||
std::map<stream_index_pair, rclcpp::Service<std_srvs::srv::SetBool>::SharedPtr>
|
||||
set_auto_exposure_srv_; // only rgb color
|
||||
|
||||
@@ -284,6 +281,6 @@ class OBCameraNode {
|
||||
std::vector<geometry_msgs::msg::TransformStamped> static_tf_msgs_;
|
||||
std::shared_ptr<std::thread> tf_thread_;
|
||||
std::condition_variable tf_cv_;
|
||||
double tf_publish_rate_;
|
||||
double tf_publish_rate_ = 10.0;
|
||||
};
|
||||
} // namespace orbbec_camera
|
||||
|
||||
@@ -43,6 +43,8 @@ class OBCameraNodeFactory : public rclcpp::Node {
|
||||
|
||||
void printDeviceInfo(const std::shared_ptr<ob::DeviceInfo>& device_info);
|
||||
|
||||
OBLogSeverity obLogSeverityFromString(const std::string& log_level);
|
||||
|
||||
private:
|
||||
std::unique_ptr<ob::Context> ctx_;
|
||||
rclcpp::Logger logger_;
|
||||
@@ -56,6 +58,7 @@ class OBCameraNodeFactory : public rclcpp::Node {
|
||||
double reconnect_timeout_ = 0.0;
|
||||
double wait_for_device_timeout_ = 0.0;
|
||||
std::shared_ptr<Parameters> parameters_;
|
||||
std::string ob_log_level_;
|
||||
};
|
||||
} // namespace orbbec_camera
|
||||
|
||||
|
||||
+3
-4
@@ -4,9 +4,9 @@ from ament_index_python import get_package_share_directory
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
params_config_path = (
|
||||
ob_params_file = (
|
||||
get_package_share_directory("orbbec_camera")
|
||||
+ "/params/orbbec_camera_params.yaml"
|
||||
+ "/params/ob_camera_params.yaml"
|
||||
)
|
||||
return LaunchDescription(
|
||||
[
|
||||
@@ -16,8 +16,7 @@ def generate_launch_description():
|
||||
name="camera",
|
||||
executable="orbbec_camera_node",
|
||||
output="screen",
|
||||
parameters=[params_config_path],
|
||||
prefix=["xterm -e gdb -ex run --args"]
|
||||
parameters=[ob_params_file],
|
||||
),
|
||||
]
|
||||
)
|
||||
+2
-1
@@ -6,7 +6,7 @@ from ament_index_python import get_package_share_directory
|
||||
def generate_launch_description():
|
||||
params_config_path = (
|
||||
get_package_share_directory("orbbec_camera")
|
||||
+ "/params/orbbec_camera_params.yaml"
|
||||
+ "/params/ob_camera_params.yaml"
|
||||
)
|
||||
return LaunchDescription(
|
||||
[
|
||||
@@ -17,6 +17,7 @@ def generate_launch_description():
|
||||
executable="orbbec_camera_node",
|
||||
output="screen",
|
||||
parameters=[params_config_path],
|
||||
prefix=["xterm -e gdb -ex run --args"],
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
from launch import LaunchDescription
|
||||
import launch_ros.actions
|
||||
from ament_index_python import get_package_share_directory
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
ob_params_file1 = (
|
||||
get_package_share_directory("orbbec_camera")
|
||||
+ "/params/multi_camera/ob_camera1_params.yaml"
|
||||
)
|
||||
ob_params_file2 = (
|
||||
get_package_share_directory("orbbec_camera")
|
||||
+ "/params/multi_camera/ob_camera2_params.yaml"
|
||||
)
|
||||
return LaunchDescription(
|
||||
[
|
||||
launch_ros.actions.Node(
|
||||
package="orbbec_camera",
|
||||
namespace="camera1",
|
||||
name="camera1",
|
||||
executable="orbbec_camera_node",
|
||||
output="screen",
|
||||
parameters=[ob_params_file1],
|
||||
),
|
||||
launch_ros.actions.Node(
|
||||
package="orbbec_camera",
|
||||
namespace="camera2",
|
||||
name="camera2",
|
||||
executable="orbbec_camera_node",
|
||||
output="screen",
|
||||
parameters=[ob_params_file2],
|
||||
),
|
||||
# dummy static transformation from camera1 to camera2
|
||||
launch_ros.actions.Node(
|
||||
package="tf2_ros",
|
||||
executable="static_transform_publisher",
|
||||
arguments=[
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"camera1_link",
|
||||
"camera2_link",
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -2,9 +2,9 @@
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>orbbec_camera</name>
|
||||
<version>0.0.1</version>
|
||||
<version>1.0.1</version>
|
||||
<description>Orbbec Camera package</description>
|
||||
<maintainer email="weikang@todo.todo">weikang</maintainer>
|
||||
<maintainer email="mocun@orbbec.com">Joe Dong</maintainer>
|
||||
<license>TODO: License declaration</license>
|
||||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/camera1/camera1:
|
||||
ros__parameters:
|
||||
color_width: 640
|
||||
color_height: 480
|
||||
color_fps: 30
|
||||
color_frame_id: "color_frame"
|
||||
color_optical_frame_id: "color_optical_frame"
|
||||
enable_color: true
|
||||
ir_width: 640
|
||||
ir_height: 480
|
||||
ir_fps: 30
|
||||
ir_frame_id: "ir_frame"
|
||||
ir_optical_frame_id: "ir_optical_frame"
|
||||
enable_ir: false
|
||||
depth_width: 640
|
||||
depth_height: 480
|
||||
depth_fps: 25
|
||||
depth_frame_id: "depth_frame"
|
||||
depth_optical_frame_id: "depth_optical_frame"
|
||||
enable_depth: true
|
||||
publish_tf: true
|
||||
tf_publish_rate: 10.0
|
||||
publish_rgb_point_cloud: true
|
||||
wait_for_device_timeout: 120.0
|
||||
reconnect_timeout: 6.0
|
||||
d2c_mode: "hw"
|
||||
serial_number: ""
|
||||
camera_link_frame_id: "camera1_link"
|
||||
ob_log_level: "none"
|
||||
@@ -0,0 +1,29 @@
|
||||
/camera2/camera2:
|
||||
ros__parameters:
|
||||
color_width: 640
|
||||
color_height: 480
|
||||
color_fps: 30
|
||||
color_frame_id: "color_frame"
|
||||
color_optical_frame_id: "color_optical_frame"
|
||||
enable_color: true
|
||||
ir_width: 640
|
||||
ir_height: 480
|
||||
ir_fps: 30
|
||||
ir_frame_id: "ir_frame"
|
||||
ir_optical_frame_id: "ir_optical_frame"
|
||||
enable_ir: false
|
||||
depth_width: 640
|
||||
depth_height: 480
|
||||
depth_fps: 25
|
||||
depth_frame_id: "depth_frame"
|
||||
depth_optical_frame_id: "depth_optical_frame"
|
||||
enable_depth: true
|
||||
publish_tf: true
|
||||
tf_publish_rate: 10.0
|
||||
publish_rgb_point_cloud: true
|
||||
wait_for_device_timeout: 120.0
|
||||
reconnect_timeout: 6.0
|
||||
d2c_mode: "hw"
|
||||
serial_number: ""
|
||||
camera_link_frame_id: "camera2_link"
|
||||
ob_log_level: "none"
|
||||
+7
-3
@@ -19,7 +19,11 @@
|
||||
depth_optical_frame_id: "depth_optical_frame"
|
||||
enable_depth: true
|
||||
publish_tf: true
|
||||
align_depth: true
|
||||
tf_publish_rate: 10.0
|
||||
publish_rgb_point_cloud : true
|
||||
d2c_mode : "hw"
|
||||
publish_rgb_point_cloud: true
|
||||
wait_for_device_timeout: 120.0
|
||||
reconnect_timeout: 6.0
|
||||
d2c_mode: "hw"
|
||||
serial_number: ""
|
||||
camera_link_frame_id: "camera_link"
|
||||
ob_log_level: "none"
|
||||
+221
-190
@@ -1,190 +1,221 @@
|
||||
Panels:
|
||||
- Class: rviz_common/Displays
|
||||
Help Height: 70
|
||||
Name: Displays
|
||||
Property Tree Widget:
|
||||
Expanded:
|
||||
- /Global Options1
|
||||
- /Status1
|
||||
- /Image1
|
||||
- /Image1/Topic1
|
||||
- /PointCloud21
|
||||
- /Image2
|
||||
Splitter Ratio: 0.5
|
||||
Tree Height: 486
|
||||
- Class: rviz_common/Selection
|
||||
Name: Selection
|
||||
- Class: rviz_common/Tool Properties
|
||||
Expanded:
|
||||
- /2D Goal Pose1
|
||||
- /Publish Point1
|
||||
Name: Tool Properties
|
||||
Splitter Ratio: 0.5886790156364441
|
||||
- Class: rviz_common/Views
|
||||
Expanded:
|
||||
- /Current View1
|
||||
Name: Views
|
||||
Splitter Ratio: 0.5
|
||||
Visualization Manager:
|
||||
Class: ""
|
||||
Displays:
|
||||
- Alpha: 0.5
|
||||
Cell Size: 1
|
||||
Class: rviz_default_plugins/Grid
|
||||
Color: 160; 160; 164
|
||||
Enabled: true
|
||||
Line Style:
|
||||
Line Width: 0.029999999329447746
|
||||
Value: Lines
|
||||
Name: Grid
|
||||
Normal Cell Count: 0
|
||||
Offset:
|
||||
X: 0
|
||||
Y: 0
|
||||
Z: 0
|
||||
Plane: XY
|
||||
Plane Cell Count: 10
|
||||
Reference Frame: <Fixed Frame>
|
||||
Value: true
|
||||
- Class: rviz_default_plugins/Image
|
||||
Enabled: true
|
||||
Max Value: 1
|
||||
Median window: 5
|
||||
Min Value: 0
|
||||
Name: Image
|
||||
Normalize Range: true
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Best Effort
|
||||
Value: /camera/color/image_raw
|
||||
Value: true
|
||||
- Alpha: 1
|
||||
Autocompute Intensity Bounds: true
|
||||
Autocompute Value Bounds:
|
||||
Max Value: 10
|
||||
Min Value: -10
|
||||
Value: true
|
||||
Axis: Z
|
||||
Channel Name: intensity
|
||||
Class: rviz_default_plugins/PointCloud2
|
||||
Color: 255; 255; 255
|
||||
Color Transformer: RGB8
|
||||
Decay Time: 0
|
||||
Enabled: true
|
||||
Invert Rainbow: false
|
||||
Max Color: 255; 255; 255
|
||||
Max Intensity: 3.5733110840282835e-43
|
||||
Min Color: 0; 0; 0
|
||||
Min Intensity: 2.802596928649634e-44
|
||||
Name: PointCloud2
|
||||
Position Transformer: XYZ
|
||||
Selectable: true
|
||||
Size (Pixels): 3
|
||||
Size (m): 0.01
|
||||
Style: Flat Squares
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /camera/depth/color/points
|
||||
Use Fixed Frame: true
|
||||
Use rainbow: true
|
||||
Value: true
|
||||
- Class: rviz_default_plugins/Image
|
||||
Enabled: true
|
||||
Max Value: 1
|
||||
Median window: 5
|
||||
Min Value: 0
|
||||
Name: Image
|
||||
Normalize Range: true
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /camera/color/image_raw
|
||||
Value: true
|
||||
Enabled: true
|
||||
Global Options:
|
||||
Background Color: 48; 48; 48
|
||||
Fixed Frame: camera_link
|
||||
Frame Rate: 30
|
||||
Name: root
|
||||
Tools:
|
||||
- Class: rviz_default_plugins/Interact
|
||||
Hide Inactive Objects: true
|
||||
- Class: rviz_default_plugins/MoveCamera
|
||||
- Class: rviz_default_plugins/Select
|
||||
- Class: rviz_default_plugins/FocusCamera
|
||||
- Class: rviz_default_plugins/Measure
|
||||
Line color: 128; 128; 0
|
||||
- Class: rviz_default_plugins/SetInitialPose
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /initialpose
|
||||
- Class: rviz_default_plugins/SetGoal
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /goal_pose
|
||||
- Class: rviz_default_plugins/PublishPoint
|
||||
Single click: true
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /clicked_point
|
||||
Transformation:
|
||||
Current:
|
||||
Class: rviz_default_plugins/TF
|
||||
Value: true
|
||||
Views:
|
||||
Current:
|
||||
Class: rviz_default_plugins/Orbit
|
||||
Distance: 0.6009803414344788
|
||||
Enable Stereo Rendering:
|
||||
Stereo Eye Separation: 0.05999999865889549
|
||||
Stereo Focal Distance: 1
|
||||
Swap Stereo Eyes: false
|
||||
Value: false
|
||||
Focal Point:
|
||||
X: 0
|
||||
Y: 0
|
||||
Z: 0
|
||||
Focal Shape Fixed Size: true
|
||||
Focal Shape Size: 0.05000000074505806
|
||||
Invert Z Axis: false
|
||||
Name: Current View
|
||||
Near Clip Distance: 0.009999999776482582
|
||||
Pitch: -0.009601986967027187
|
||||
Target Frame: <Fixed Frame>
|
||||
Value: Orbit (rviz)
|
||||
Yaw: 2.695401906967163
|
||||
Saved: ~
|
||||
Window Geometry:
|
||||
Displays:
|
||||
collapsed: false
|
||||
Height: 984
|
||||
Hide Left Dock: false
|
||||
Hide Right Dock: false
|
||||
Image:
|
||||
collapsed: false
|
||||
QMainWindow State: 000000ff00000000fd0000000400000000000002ba0000037efc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d00000269000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000a0049006d00610067006500000001f4000000870000002800fffffffb0000000a0049006d00610067006501000002ac0000010f0000002800ffffff000000010000011e00000317fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d00000317000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d00650100000000000004500000000000000000000004760000037e00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
|
||||
Selection:
|
||||
collapsed: false
|
||||
Tool Properties:
|
||||
collapsed: false
|
||||
Views:
|
||||
collapsed: false
|
||||
Width: 1846
|
||||
X: 72
|
||||
Y: 27
|
||||
Panels:
|
||||
- Class: rviz_common/Displays
|
||||
Help Height: 78
|
||||
Name: Displays
|
||||
Property Tree Widget:
|
||||
Expanded:
|
||||
- /Global Options1
|
||||
- /Status1
|
||||
- /TF1
|
||||
- /PointCloud21/Topic1
|
||||
- /Axes1
|
||||
Splitter Ratio: 0.5
|
||||
Tree Height: 357
|
||||
- Class: rviz_common/Selection
|
||||
Name: Selection
|
||||
- Class: rviz_common/Tool Properties
|
||||
Expanded:
|
||||
- /2D Goal Pose1
|
||||
- /Publish Point1
|
||||
Name: Tool Properties
|
||||
Splitter Ratio: 0.5886790156364441
|
||||
- Class: rviz_common/Views
|
||||
Expanded:
|
||||
- /Current View1
|
||||
Name: Views
|
||||
Splitter Ratio: 0.5
|
||||
- Class: rviz_common/Time
|
||||
Experimental: false
|
||||
Name: Time
|
||||
SyncMode: 0
|
||||
SyncSource: PointCloud2
|
||||
Visualization Manager:
|
||||
Class: ""
|
||||
Displays:
|
||||
- Alpha: 0.5
|
||||
Cell Size: 1
|
||||
Class: rviz_default_plugins/Grid
|
||||
Color: 160; 160; 164
|
||||
Enabled: true
|
||||
Line Style:
|
||||
Line Width: 0.029999999329447746
|
||||
Value: Lines
|
||||
Name: Grid
|
||||
Normal Cell Count: 0
|
||||
Offset:
|
||||
X: 0
|
||||
Y: 0
|
||||
Z: 0
|
||||
Plane: XY
|
||||
Plane Cell Count: 10
|
||||
Reference Frame: <Fixed Frame>
|
||||
Value: true
|
||||
- Class: rviz_default_plugins/TF
|
||||
Enabled: false
|
||||
Frame Timeout: 15
|
||||
Frames:
|
||||
All Enabled: true
|
||||
Marker Scale: 1
|
||||
Name: TF
|
||||
Show Arrows: true
|
||||
Show Axes: true
|
||||
Show Names: false
|
||||
Tree:
|
||||
{}
|
||||
Update Interval: 0
|
||||
Value: false
|
||||
- Class: rviz_default_plugins/Image
|
||||
Enabled: true
|
||||
Max Value: 1
|
||||
Median window: 5
|
||||
Min Value: 0
|
||||
Name: Image
|
||||
Normalize Range: true
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /camera/depth/image_raw
|
||||
Value: true
|
||||
- Class: rviz_default_plugins/Image
|
||||
Enabled: true
|
||||
Max Value: 1
|
||||
Median window: 5
|
||||
Min Value: 0
|
||||
Name: Image
|
||||
Normalize Range: true
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /camera/color/image_raw
|
||||
Value: true
|
||||
- Alpha: 1
|
||||
Autocompute Intensity Bounds: true
|
||||
Autocompute Value Bounds:
|
||||
Max Value: 2.177511215209961
|
||||
Min Value: -1.9372501373291016
|
||||
Value: true
|
||||
Axis: Z
|
||||
Channel Name: intensity
|
||||
Class: rviz_default_plugins/PointCloud2
|
||||
Color: 255; 255; 255
|
||||
Color Transformer: RGB8
|
||||
Decay Time: 0
|
||||
Enabled: true
|
||||
Invert Rainbow: false
|
||||
Max Color: 255; 255; 255
|
||||
Max Intensity: 0
|
||||
Min Color: 0; 0; 0
|
||||
Min Intensity: 0
|
||||
Name: PointCloud2
|
||||
Position Transformer: XYZ
|
||||
Selectable: true
|
||||
Size (Pixels): 3
|
||||
Size (m): 0.009999999776482582
|
||||
Style: Flat Squares
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
Filter size: 10
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Best Effort
|
||||
Value: /camera/depth/points
|
||||
Use Fixed Frame: true
|
||||
Use rainbow: true
|
||||
Value: true
|
||||
- Class: rviz_default_plugins/Axes
|
||||
Enabled: false
|
||||
Length: 1
|
||||
Name: Axes
|
||||
Radius: 0.10000000149011612
|
||||
Reference Frame: color_optical_frame
|
||||
Value: false
|
||||
Enabled: true
|
||||
Global Options:
|
||||
Background Color: 48; 48; 48
|
||||
Fixed Frame: color_optical_frame
|
||||
Frame Rate: 30
|
||||
Name: root
|
||||
Tools:
|
||||
- Class: rviz_default_plugins/Interact
|
||||
Hide Inactive Objects: true
|
||||
- Class: rviz_default_plugins/MoveCamera
|
||||
- Class: rviz_default_plugins/Select
|
||||
- Class: rviz_default_plugins/FocusCamera
|
||||
- Class: rviz_default_plugins/Measure
|
||||
Line color: 128; 128; 0
|
||||
- Class: rviz_default_plugins/SetInitialPose
|
||||
Covariance x: 0.25
|
||||
Covariance y: 0.25
|
||||
Covariance yaw: 0.06853891909122467
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /initialpose
|
||||
- Class: rviz_default_plugins/SetGoal
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /goal_pose
|
||||
- Class: rviz_default_plugins/PublishPoint
|
||||
Single click: true
|
||||
Topic:
|
||||
Depth: 5
|
||||
Durability Policy: Volatile
|
||||
History Policy: Keep Last
|
||||
Reliability Policy: Reliable
|
||||
Value: /clicked_point
|
||||
Transformation:
|
||||
Current:
|
||||
Class: rviz_default_plugins/TF
|
||||
Value: true
|
||||
Views:
|
||||
Current:
|
||||
Class: rviz_default_plugins/Orbit
|
||||
Distance: 25.43751335144043
|
||||
Enable Stereo Rendering:
|
||||
Stereo Eye Separation: 0.05999999865889549
|
||||
Stereo Focal Distance: 1
|
||||
Swap Stereo Eyes: false
|
||||
Value: false
|
||||
Focal Point:
|
||||
X: -0.04824497178196907
|
||||
Y: 0.8122125864028931
|
||||
Z: 20.006338119506836
|
||||
Focal Shape Fixed Size: true
|
||||
Focal Shape Size: 0.05000000074505806
|
||||
Invert Z Axis: false
|
||||
Name: Current View
|
||||
Near Clip Distance: 0.009999999776482582
|
||||
Pitch: -1.519796371459961
|
||||
Target Frame: <Fixed Frame>
|
||||
Value: Orbit (rviz)
|
||||
Yaw: 4.65173864364624
|
||||
Saved: ~
|
||||
Window Geometry:
|
||||
Displays:
|
||||
collapsed: false
|
||||
Height: 1016
|
||||
Hide Left Dock: false
|
||||
Hide Right Dock: false
|
||||
Image:
|
||||
collapsed: false
|
||||
QMainWindow State: 000000ff00000000fd0000000400000000000002180000035afc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000001f0000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000a0049006d0061006700650100000233000000970000002800fffffffb0000000a0049006d00610067006501000002d0000000c70000002800ffffff000000010000010f0000035afc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d0000035a000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007380000003efc0100000002fb0000000800540069006d0065010000000000000738000002eb00fffffffb0000000800540069006d00650100000000000004500000000000000000000004050000035a00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
|
||||
Selection:
|
||||
collapsed: false
|
||||
Time:
|
||||
collapsed: false
|
||||
Tool Properties:
|
||||
collapsed: false
|
||||
Views:
|
||||
collapsed: false
|
||||
Width: 1848
|
||||
X: 72
|
||||
Y: 27
|
||||
|
||||
@@ -158,10 +158,13 @@ void OBCameraNode::setupProfiles() {
|
||||
void OBCameraNode::startPipeline() {
|
||||
if (d2c_mode_ == "sw") {
|
||||
config_->setAlignMode(ALIGN_D2C_SW_MODE);
|
||||
align_depth_ = true;
|
||||
} else if (d2c_mode_ == "hw") {
|
||||
config_->setAlignMode(ALIGN_D2C_HW_MODE);
|
||||
align_depth_ = true;
|
||||
} else {
|
||||
config_->setAlignMode(ALIGN_DISABLE);
|
||||
align_depth_ = false;
|
||||
}
|
||||
pipeline_ = std::make_unique<ob::Pipeline>(device_);
|
||||
pipeline_->start(config_, [this](std::shared_ptr<ob::FrameSet> frame_set) {
|
||||
@@ -189,17 +192,17 @@ void OBCameraNode::getParameters() {
|
||||
depth_aligned_frame_id_[stream_index] = stream_name_[OB_STREAM_COLOR] + "_optical_frame";
|
||||
}
|
||||
setAndGetNodeParameter(publish_tf_, "publish_tf", true);
|
||||
setAndGetNodeParameter(align_depth_, "align_depth", true);
|
||||
setAndGetNodeParameter(tf_publish_rate_, "tf_publish_rate", 10.0);
|
||||
setAndGetNodeParameter(publish_rgb_point_cloud_, "publish_rgb_point_cloud", false);
|
||||
setAndGetNodeParameter(d2c_mode_, "d2c_mode_", DEFAULT_D2C_MODE);
|
||||
setAndGetNodeParameter(camera_link_frame_id_, "camera_link_frame_id", DEFAULT_BASE_FRAME_ID);
|
||||
}
|
||||
|
||||
void OBCameraNode::setupTopics() {
|
||||
getParameters();
|
||||
setupDevices();
|
||||
updateStreamCalibData();
|
||||
setupProfiles();
|
||||
setupDefaultStreamCalibData();
|
||||
setupCameraCtrlServices();
|
||||
setupPublishers();
|
||||
publishStaticTransforms();
|
||||
@@ -228,7 +231,7 @@ void OBCameraNode::publishPointCloud(std::shared_ptr<ob::FrameSet> frame_set) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if(publish_rgb_point_cloud_) {
|
||||
if (publish_rgb_point_cloud_) {
|
||||
if (frame_set->depthFrame() != nullptr && frame_set->colorFrame() != nullptr) {
|
||||
publishColorPointCloud(frame_set);
|
||||
}
|
||||
@@ -268,7 +271,7 @@ void OBCameraNode::publishDepthPointCloud(std::shared_ptr<ob::FrameSet> frame_se
|
||||
bool valid_pixel(points->z > 0);
|
||||
if (valid_pixel) {
|
||||
*iter_x = static_cast<float>(points->x / 1000.0);
|
||||
*iter_y = static_cast<float>(points->y / 1000.0);
|
||||
*iter_y = -static_cast<float>(points->y / 1000.0);
|
||||
*iter_z = static_cast<float>(points->z / 1000.0);
|
||||
++iter_x;
|
||||
++iter_y;
|
||||
@@ -316,7 +319,7 @@ void OBCameraNode::publishColorPointCloud(std::shared_ptr<ob::FrameSet> frame_se
|
||||
bool valid_pixel(points->z > 0);
|
||||
if (valid_pixel) {
|
||||
*iter_x = static_cast<float>(points->x / 1000.0);
|
||||
*iter_y = static_cast<float>(points->y / 1000.0);
|
||||
*iter_y = -static_cast<float>(points->y / 1000.0);
|
||||
*iter_z = static_cast<float>(points->z / 1000.0);
|
||||
*iter_r = static_cast<uint8_t>(points->r);
|
||||
*iter_g = static_cast<uint8_t>(points->g);
|
||||
@@ -336,6 +339,7 @@ void OBCameraNode::publishColorPointCloud(std::shared_ptr<ob::FrameSet> frame_se
|
||||
point_cloud_msg_.header.frame_id = optical_frame_id_[COLOR];
|
||||
point_cloud_publisher_->publish(point_cloud_msg_);
|
||||
}
|
||||
|
||||
void OBCameraNode::frameSetCallback(std::shared_ptr<ob::FrameSet> frame_set) {
|
||||
auto color_frame = frame_set->colorFrame();
|
||||
auto depth_frame = frame_set->depthFrame();
|
||||
@@ -351,6 +355,7 @@ void OBCameraNode::frameSetCallback(std::shared_ptr<ob::FrameSet> frame_set) {
|
||||
}
|
||||
publishPointCloud(frame_set);
|
||||
}
|
||||
|
||||
std::optional<OBCameraParam> OBCameraNode::findDefaultCameraParam() {
|
||||
auto camera_params = device_->getCalibrationCameraParamList();
|
||||
for (size_t i = 0; i < camera_params->count(); i++) {
|
||||
@@ -428,11 +433,18 @@ std::optional<OBCameraParam> OBCameraNode::findCameraParam(uint32_t color_width,
|
||||
return {};
|
||||
}
|
||||
|
||||
void OBCameraNode::updateStreamCalibData() {
|
||||
void OBCameraNode::setupDefaultStreamCalibData() {
|
||||
auto param = findDefaultCameraParam();
|
||||
CHECK(param.has_value());
|
||||
camera_infos_[DEPTH] = convertToCameraInfo(param->depthIntrinsic, param->depthDistortion);
|
||||
camera_infos_[COLOR] = convertToCameraInfo(param->rgbIntrinsic, param->rgbDistortion);
|
||||
if (!param.has_value()) {
|
||||
RCLCPP_WARN_STREAM(logger_, "Not Found default camera parameter");
|
||||
return;
|
||||
}
|
||||
updateStreamCalibData(*param);
|
||||
}
|
||||
|
||||
void OBCameraNode::updateStreamCalibData(const OBCameraParam& param) {
|
||||
camera_infos_[DEPTH] = convertToCameraInfo(param.depthIntrinsic, param.depthDistortion);
|
||||
camera_infos_[COLOR] = convertToCameraInfo(param.rgbIntrinsic, param.rgbDistortion);
|
||||
camera_infos_[INFRA0] = camera_infos_[DEPTH];
|
||||
}
|
||||
|
||||
@@ -468,12 +480,12 @@ void OBCameraNode::calcAndPublishStaticTransform() {
|
||||
rclcpp::Time tf_timestamp = node_->now();
|
||||
|
||||
publishStaticTF(tf_timestamp, trans, Q, frame_id_[DEPTH], frame_id_[COLOR]);
|
||||
publishStaticTF(tf_timestamp, trans, Q, "camera_link", frame_id_[COLOR]);
|
||||
publishStaticTF(tf_timestamp, trans, Q, camera_link_frame_id_, frame_id_[COLOR]);
|
||||
publishStaticTF(tf_timestamp, zero_trans, quaternion_optical, frame_id_[COLOR],
|
||||
optical_frame_id_[COLOR]);
|
||||
publishStaticTF(tf_timestamp, zero_trans, quaternion_optical, frame_id_[DEPTH],
|
||||
optical_frame_id_[DEPTH]);
|
||||
publishStaticTF(tf_timestamp, zero_trans, zero_rot, "camera_link", frame_id_[DEPTH]);
|
||||
publishStaticTF(tf_timestamp, zero_trans, zero_rot, camera_link_frame_id_, frame_id_[DEPTH]);
|
||||
extrinsics_publisher_->publish(obExtrinsicsToMsg(ex, "depth_to_color_extrinsics"));
|
||||
}
|
||||
|
||||
@@ -485,6 +497,7 @@ void OBCameraNode::publishStaticTransforms() {
|
||||
static_tf_broadcaster_->sendTransform(static_tf_msgs_);
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNode::publishDynamicTransforms() {
|
||||
RCLCPP_WARN(logger_, "Publishing dynamic camera transforms (/tf) at %g Hz", tf_publish_rate_);
|
||||
std::mutex mu;
|
||||
@@ -545,8 +558,9 @@ void OBCameraNode::publishColorFrame(std::shared_ptr<ob::ColorFrame> frame) {
|
||||
auto& camera_info_publisher = camera_info_publishers_.at(stream);
|
||||
auto& image_publisher = image_publishers_.at(stream);
|
||||
auto& cam_info = camera_infos_.at(stream);
|
||||
if (cam_info.width != width) {
|
||||
if (cam_info.width != width || cam_info.height != height) {
|
||||
RCLCPP_ERROR(logger_, "cam info error");
|
||||
updateStreamCalibData(pipeline_->getCameraParam());
|
||||
cam_info.height = height;
|
||||
cam_info.width = width;
|
||||
}
|
||||
@@ -577,8 +591,9 @@ void OBCameraNode::publishDepthFrame(std::shared_ptr<ob::DepthFrame> frame) {
|
||||
auto& camera_info_publisher = camera_info_publishers_.at(stream);
|
||||
auto& image_publisher = image_publishers_.at(stream);
|
||||
auto& cam_info = camera_infos_.at(stream);
|
||||
if (cam_info.width != width) {
|
||||
if (cam_info.width != width || cam_info.height != height) {
|
||||
RCLCPP_ERROR(logger_, "cam info error");
|
||||
updateStreamCalibData(pipeline_->getCameraParam());
|
||||
cam_info.height = height;
|
||||
cam_info.width = width;
|
||||
}
|
||||
@@ -592,7 +607,11 @@ void OBCameraNode::publishDepthFrame(std::shared_ptr<ob::DepthFrame> frame) {
|
||||
img->height = height;
|
||||
img->is_bigendian = false;
|
||||
img->step = width * unit_step_size_[stream];
|
||||
img->header.frame_id = optical_frame_id_[COLOR];
|
||||
if (align_depth_) {
|
||||
img->header.frame_id = optical_frame_id_[COLOR];
|
||||
} else {
|
||||
img->header.frame_id = optical_frame_id_[DEPTH];
|
||||
}
|
||||
img->header.stamp = timestamp;
|
||||
image_publisher.publish(img);
|
||||
}
|
||||
@@ -609,8 +628,9 @@ void OBCameraNode::publishIRFrame(std::shared_ptr<ob::IRFrame> frame) {
|
||||
auto& camera_info_publisher = camera_info_publishers_.at(stream);
|
||||
auto& image_publisher = image_publishers_.at(stream);
|
||||
auto& cam_info = camera_infos_.at(stream);
|
||||
if (cam_info.width != width) {
|
||||
if (cam_info.width != width || cam_info.height != height) {
|
||||
RCLCPP_ERROR(logger_, "cam info error");
|
||||
updateStreamCalibData(pipeline_->getCameraParam());
|
||||
cam_info.height = height;
|
||||
cam_info.width = width;
|
||||
}
|
||||
@@ -624,7 +644,11 @@ void OBCameraNode::publishIRFrame(std::shared_ptr<ob::IRFrame> frame) {
|
||||
img->height = height;
|
||||
img->is_bigendian = false;
|
||||
img->step = width * unit_step_size_[stream];
|
||||
img->header.frame_id = optical_frame_id_[COLOR];
|
||||
if (align_depth_) {
|
||||
img->header.frame_id = optical_frame_id_[COLOR];
|
||||
} else {
|
||||
img->header.frame_id = optical_frame_id_[DEPTH];
|
||||
}
|
||||
img->header.stamp = timestamp;
|
||||
image_publisher.publish(img);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ OBCameraNodeFactory::OBCameraNodeFactory(const rclcpp::NodeOptions &node_options
|
||||
logger_(this->get_logger()) {
|
||||
init();
|
||||
}
|
||||
|
||||
OBCameraNodeFactory::OBCameraNodeFactory(const std::string &node_name, const std::string &ns,
|
||||
const rclcpp::NodeOptions &node_options)
|
||||
: Node(node_name, ns, node_options),
|
||||
@@ -32,8 +33,10 @@ OBCameraNodeFactory::~OBCameraNodeFactory() {
|
||||
query_thread_.join();
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNodeFactory::init() {
|
||||
ctx_->setLoggerSeverity(OB_LOG_SEVERITY_NONE);
|
||||
ob_log_level_ = declare_parameter<std::string>("ob_log_level", "none");
|
||||
ctx_->setLoggerSeverity(obLogSeverityFromString(ob_log_level_));
|
||||
is_alive_.store(true);
|
||||
parameters_ = std::make_shared<Parameters>(this);
|
||||
serial_number_ = declare_parameter<std::string>("serial_number", "");
|
||||
@@ -123,6 +126,21 @@ void OBCameraNodeFactory::printDeviceInfo(const std::shared_ptr<ob::DeviceInfo>
|
||||
RCLCPP_INFO_STREAM(logger_, "hardware version " << device_info->hardwareVersion());
|
||||
}
|
||||
|
||||
OBLogSeverity OBCameraNodeFactory::obLogSeverityFromString(const std::string &log_level) {
|
||||
if (log_level == "debug") {
|
||||
return OB_LOG_SEVERITY_DEBUG;
|
||||
} else if (log_level == "info") {
|
||||
return OB_LOG_SEVERITY_INFO;
|
||||
} else if (log_level == "warn" || log_level == "warning") {
|
||||
return OB_LOG_SEVERITY_WARN;
|
||||
} else if (log_level == "fatal" || log_level == "error") {
|
||||
return OB_LOG_SEVERITY_FATAL;
|
||||
} else {
|
||||
// Default None
|
||||
return OB_LOG_SEVERITY_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNodeFactory::getDevice(const std::shared_ptr<ob::DeviceList> &list) {
|
||||
if (device_) {
|
||||
return;
|
||||
|
||||
@@ -25,55 +25,49 @@ void OBCameraNode::setupCameraCtrlServices() {
|
||||
if (enable_[stream_index]) {
|
||||
std::string service_name = "get_" + stream_name + "_exposure";
|
||||
get_exposure_srv_[stream_index] = node_->create_service<GetInt32>(
|
||||
service_name, [this, stream_index = stream_index](
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<GetInt32::Request> request,
|
||||
std::shared_ptr<GetInt32::Response> response) {
|
||||
service_name,
|
||||
[this, stream_index = stream_index](const std::shared_ptr<GetInt32::Request> request,
|
||||
std::shared_ptr<GetInt32::Response> response) {
|
||||
getExposureCallback(request, response, stream_index);
|
||||
});
|
||||
|
||||
service_name = "set_" + stream_name + "_exposure";
|
||||
set_exposure_srv_[stream_index] = node_->create_service<SetInt32>(
|
||||
service_name, [this, stream_index = stream_index](
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<SetInt32::Request> request,
|
||||
std::shared_ptr<SetInt32::Response> response) {
|
||||
service_name,
|
||||
[this, stream_index = stream_index](const std::shared_ptr<SetInt32::Request> request,
|
||||
std::shared_ptr<SetInt32::Response> response) {
|
||||
setExposureCallback(request, response, stream_index);
|
||||
});
|
||||
service_name = "get_" + stream_name + "_gain";
|
||||
get_gain_srv_[stream_index] = node_->create_service<GetInt32>(
|
||||
service_name, [this, stream_index = stream_index](
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<GetInt32::Request> request,
|
||||
std::shared_ptr<GetInt32::Response> response) {
|
||||
service_name,
|
||||
[this, stream_index = stream_index](const std::shared_ptr<GetInt32::Request> request,
|
||||
std::shared_ptr<GetInt32::Response> response) {
|
||||
getGainCallback(request, response, stream_index);
|
||||
});
|
||||
|
||||
service_name = "set_" + stream_name + "_gain";
|
||||
set_gain_srv_[stream_index] = node_->create_service<SetInt32>(
|
||||
service_name, [this, stream_index = stream_index](
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<SetInt32::Request> request,
|
||||
std::shared_ptr<SetInt32::Response> response) {
|
||||
service_name,
|
||||
[this, stream_index = stream_index](const std::shared_ptr<SetInt32::Request> request,
|
||||
std::shared_ptr<SetInt32::Response> response) {
|
||||
setGainCallback(request, response, stream_index);
|
||||
});
|
||||
if (stream_index.first == OB_STREAM_COLOR || stream_index.first == OB_STREAM_DEPTH) {
|
||||
service_name = "set_" + stream_name + "_auto_exposure";
|
||||
set_auto_exposure_srv_[stream_index] = node_->create_service<SetBool>(
|
||||
service_name, [this, stream_index = stream_index](
|
||||
const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<SetBool::Request> request,
|
||||
std::shared_ptr<SetBool::Response> response) {
|
||||
service_name,
|
||||
[this, stream_index = stream_index](const std::shared_ptr<SetBool::Request> request,
|
||||
std::shared_ptr<SetBool::Response> response) {
|
||||
setAutoExposureCallback(request, response, stream_index);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
set_fan_mode_srv_ = node_->create_service<SetInt32>(
|
||||
"set_fan_mode", [this](const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<SetInt32::Request> request,
|
||||
"set_fan_mode", [this](const std::shared_ptr<SetInt32::Request> request,
|
||||
std::shared_ptr<SetInt32::Response> response) {
|
||||
setFanModeCallback(request_header, request, response);
|
||||
setFanModeCallback(request, response);
|
||||
});
|
||||
set_floor_enable_srv_ = node_->create_service<SetBool>(
|
||||
"set_floor_enable", [this](const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
@@ -95,30 +89,25 @@ void OBCameraNode::setupCameraCtrlServices() {
|
||||
});
|
||||
|
||||
get_white_balance_srv_ = node_->create_service<GetInt32>(
|
||||
"get_white_balance", [this](const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<GetInt32::Request> request,
|
||||
"get_white_balance", [this](const std::shared_ptr<GetInt32::Request> request,
|
||||
std::shared_ptr<GetInt32::Response> response) {
|
||||
getWhiteBalanceCallback(request_header, request, response);
|
||||
getWhiteBalanceCallback(request, response);
|
||||
});
|
||||
|
||||
set_white_balance_srv_ = node_->create_service<SetInt32>(
|
||||
"set_white_balance", [this](const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<SetInt32::Request> request,
|
||||
"set_white_balance", [this](const std::shared_ptr<SetInt32::Request> request,
|
||||
std::shared_ptr<SetInt32::Response> response) {
|
||||
setWhiteBalanceCallback(request_header, request, response);
|
||||
setWhiteBalanceCallback(request, response);
|
||||
});
|
||||
get_device_srv_ = node_->create_service<GetDeviceInfo>(
|
||||
"get_device_info", [this](const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<GetDeviceInfo::Request> request,
|
||||
"get_device_info", [this](const std::shared_ptr<GetDeviceInfo::Request> request,
|
||||
std::shared_ptr<GetDeviceInfo::Response> response) {
|
||||
getDeviceInfoCallback(request_header, request, response);
|
||||
});
|
||||
get_api_version_srv_ = node_->create_service<GetString>(
|
||||
"get_sdk_version", [this](const std::shared_ptr<rmw_request_id_t> request_header,
|
||||
const std::shared_ptr<GetString::Request> request,
|
||||
std::shared_ptr<GetString::Response> response) {
|
||||
getSDKVersion(request_header, request, response);
|
||||
getDeviceInfoCallback(request, response);
|
||||
});
|
||||
get_sdk_version_srv_ = node_->create_service<GetString>(
|
||||
"get_sdk_version",
|
||||
[this](const std::shared_ptr<GetString::Request> request,
|
||||
std::shared_ptr<GetString::Response> response) { getSDKVersion(request, response); });
|
||||
}
|
||||
|
||||
void OBCameraNode::setExposureCallback(const std::shared_ptr<SetInt32::Request>& request,
|
||||
@@ -157,6 +146,7 @@ void OBCameraNode::setExposureCallback(const std::shared_ptr<SetInt32::Request>&
|
||||
void OBCameraNode::getGainCallback(const std::shared_ptr<GetInt32::Request>& request,
|
||||
std::shared_ptr<GetInt32::Response>& response,
|
||||
const stream_index_pair& stream_index) {
|
||||
(void)request;
|
||||
auto stream = stream_index.first;
|
||||
try {
|
||||
switch (stream) {
|
||||
@@ -218,9 +208,9 @@ void OBCameraNode::setGainCallback(const std::shared_ptr<SetInt32 ::Request>& re
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNode::getWhiteBalanceCallback(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<GetInt32::Request>& request,
|
||||
void OBCameraNode::getWhiteBalanceCallback(const std::shared_ptr<GetInt32::Request>& request,
|
||||
std::shared_ptr<GetInt32::Response>& response) {
|
||||
(void)request;
|
||||
try {
|
||||
response->data = device_->getIntProperty(OB_PROP_COLOR_WHITE_BALANCE_INT);
|
||||
response->success = true;
|
||||
@@ -236,8 +226,7 @@ void OBCameraNode::getWhiteBalanceCallback(const std::shared_ptr<rmw_request_id_
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNode::setWhiteBalanceCallback(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<SetInt32 ::Request>& request,
|
||||
void OBCameraNode::setWhiteBalanceCallback(const std::shared_ptr<SetInt32 ::Request>& request,
|
||||
std::shared_ptr<SetInt32 ::Response>& response) {
|
||||
try {
|
||||
device_->setIntProperty(OB_PROP_COLOR_WHITE_BALANCE_INT, request->data);
|
||||
@@ -289,10 +278,8 @@ void OBCameraNode::setAutoExposureCallback(
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNode::setFanModeCallback(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<SetInt32::Request>& request,
|
||||
void OBCameraNode::setFanModeCallback(const std::shared_ptr<SetInt32::Request>& request,
|
||||
std::shared_ptr<SetInt32::Response>& response) {
|
||||
(void)request_header;
|
||||
(void)response;
|
||||
bool fan_mode = request->data;
|
||||
try {
|
||||
@@ -379,6 +366,7 @@ void OBCameraNode::setLdpEnableCallback(
|
||||
void OBCameraNode::getExposureCallback(const std::shared_ptr<GetInt32::Request>& request,
|
||||
std::shared_ptr<GetInt32 ::Response>& response,
|
||||
const stream_index_pair& stream_index) {
|
||||
(void)request;
|
||||
auto stream = stream_index.first;
|
||||
try {
|
||||
switch (stream) {
|
||||
@@ -408,9 +396,9 @@ void OBCameraNode::getExposureCallback(const std::shared_ptr<GetInt32::Request>&
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNode::getDeviceInfoCallback(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<GetDeviceInfo::Request>& request,
|
||||
void OBCameraNode::getDeviceInfoCallback(const std::shared_ptr<GetDeviceInfo::Request>& request,
|
||||
std::shared_ptr<GetDeviceInfo::Response>& response) {
|
||||
(void)request;
|
||||
try {
|
||||
auto device_info = device_->getDeviceInfo();
|
||||
response->info.name = device_info->name();
|
||||
@@ -432,9 +420,9 @@ void OBCameraNode::getDeviceInfoCallback(const std::shared_ptr<rmw_request_id_t>
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNode::getSDKVersion(const std::shared_ptr<rmw_request_id_t>& request_header,
|
||||
const std::shared_ptr<GetString::Request>& request,
|
||||
void OBCameraNode::getSDKVersion(const std::shared_ptr<GetString::Request>& request,
|
||||
std::shared_ptr<GetString::Response>& response) {
|
||||
(void)request;
|
||||
try {
|
||||
auto device_info = device_->getDeviceInfo();
|
||||
nlohmann::json data;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>orbbec_camera_msgs</name>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<description>A package containing orbbec camera messages definitions.</description>
|
||||
<maintainer email="mocun@orbbec.com">Jian Dong</maintainer>
|
||||
<maintainer email="mocun@orbbec.com">Joe Dong</maintainer>
|
||||
<license>all copyrights reserved</license>
|
||||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
|
||||
Reference in New Issue
Block a user