Skip to content

Commit 5a2e586

Browse files
authored
Additional IMU modes - Jazzy (#696)
1 parent 2e3110f commit 5a2e586

File tree

17 files changed

+80
-37
lines changed

17 files changed

+80
-37
lines changed

depthai-ros/CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22
Changelog for package depthai-ros
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
2.11.2 (2025-03-17)
5+
-------------------
6+
* Add autoexposure region settings
7+
* Add additional IMU parameters
48

59
2.11.1 (2025-03-12)
610
-------------------

depthai-ros/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS
22

3-
project(depthai-ros VERSION 2.11.1 LANGUAGES CXX C)
3+
project(depthai-ros VERSION 2.11.2 LANGUAGES CXX C)
44

55
set(CMAKE_CXX_STANDARD 14)
66

depthai-ros/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package format="3">
33
<name>depthai-ros</name>
4-
<version>2.11.1</version>
4+
<version>2.11.2</version>
55
<description>The depthai-ros package</description>
66

77
<!-- One maintainer tag required, multiple allowed, one person per tag -->

depthai_bridge/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS
22
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
33

4-
project(depthai_bridge VERSION 2.11.1 LANGUAGES CXX C)
4+
project(depthai_bridge VERSION 2.11.2 LANGUAGES CXX C)
55

66
set(CMAKE_CXX_STANDARD 14)
77
set(CMAKE_CXX_STANDARD_REQUIRED ON)

depthai_bridge/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package format="3">
33
<name>depthai_bridge</name>
4-
<version>2.11.1</version>
4+
<version>2.11.2</version>
55
<description>The depthai_bridge package</description>
66

77
<maintainer email="[email protected]">Adam Serafin</maintainer>

depthai_descriptions/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.8)
2-
project(depthai_descriptions VERSION 2.11.1)
2+
project(depthai_descriptions VERSION 2.11.2)
33

44
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
55
add_compile_options(-Wall -Wextra -Wpedantic)

depthai_descriptions/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package format="3">
33
<name>depthai_descriptions</name>
4-
<version>2.11.1</version>
4+
<version>2.11.2</version>
55
<description>The depthai_descriptions package</description>
66

77
<maintainer email="[email protected]">Adam Serafin</maintainer>

depthai_examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS
2-
project(depthai_examples VERSION 2.11.1 LANGUAGES CXX C)
2+
project(depthai_examples VERSION 2.11.2 LANGUAGES CXX C)
33

44
set(CMAKE_CXX_STANDARD 14)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)

depthai_examples/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package format="3">
33
<name>depthai_examples</name>
4-
<version>2.11.1</version>
4+
<version>2.11.2</version>
55
<description>The depthai_examples package</description>
66

77
<!-- One maintainer tag required, multiple allowed, one person per tag -->

depthai_filters/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.8)
2-
project(depthai_filters VERSION 2.11.1 LANGUAGES CXX C)
2+
project(depthai_filters VERSION 2.11.2 LANGUAGES CXX C)
33

44
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
55
add_compile_options(-Wall -Wextra -Wpedantic)

depthai_filters/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>depthai_filters</name>
5-
<version>2.11.1</version>
5+
<version>2.11.2</version>
66
<description>Depthai filters package</description>
77
<maintainer email="[email protected]">Adam Serafin</maintainer>
88
<license>MIT</license>

depthai_ros_driver/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.22)
2-
project(depthai_ros_driver VERSION 2.11.1)
2+
project(depthai_ros_driver VERSION 2.11.2)
33
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
44
set(CMAKE_BUILD_SHARED_LIBS ON)
55
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

depthai_ros_driver/include/depthai_ros_driver/param_handlers/imu_param_handler.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ class ImuParamHandler : public BaseParamHandler {
3131
~ImuParamHandler();
3232
void declareParams(std::shared_ptr<dai::node::IMU> imu, const std::string& imuType);
3333
dai::CameraControl setRuntimeParams(const std::vector<rclcpp::Parameter>& params) override;
34-
std::unordered_map<std::string, dai::ros::ImuSyncMethod> imuSyncMethodMap;
35-
std::unordered_map<std::string, imu::ImuMsgType> imuMessagetTypeMap;
34+
std::unordered_map<std::string, dai::ros::ImuSyncMethod> syncMethodMap;
35+
std::unordered_map<std::string, imu::ImuMsgType> messagetTypeMap;
3636
std::unordered_map<std::string, dai::IMUSensor> rotationVectorTypeMap;
37+
std::unordered_map<std::string, dai::IMUSensor> accelerometerModeMap;
38+
std::unordered_map<std::string, dai::IMUSensor> gyroscopeModeMap;
39+
std::unordered_map<std::string, dai::IMUSensor> magnetometerModeMap;
3740
imu::ImuMsgType getMsgType();
3841
dai::ros::ImuSyncMethod getSyncMethod();
3942
};

depthai_ros_driver/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>depthai_ros_driver</name>
5-
<version>2.11.1</version>
5+
<version>2.11.2</version>
66
<description>Depthai ROS Monolithic node.</description>
77
<maintainer email="[email protected]">Adam Serafin</maintainer>
88

depthai_ros_driver/src/param_handlers/imu_param_handler.cpp

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,93 @@
99
namespace depthai_ros_driver {
1010
namespace param_handlers {
1111
ImuParamHandler::ImuParamHandler(std::shared_ptr<rclcpp::Node> node, const std::string& name) : BaseParamHandler(node, name) {
12-
imuSyncMethodMap = {
12+
syncMethodMap = {
1313
{"COPY", dai::ros::ImuSyncMethod::COPY},
1414
{"LINEAR_INTERPOLATE_GYRO", dai::ros::ImuSyncMethod::LINEAR_INTERPOLATE_GYRO},
1515
{"LINEAR_INTERPOLATE_ACCEL", dai::ros::ImuSyncMethod::LINEAR_INTERPOLATE_ACCEL},
1616
};
17-
imuMessagetTypeMap = {
17+
messagetTypeMap = {
1818
{"IMU", imu::ImuMsgType::IMU}, {"IMU_WITH_MAG", imu::ImuMsgType::IMU_WITH_MAG}, {"IMU_WITH_MAG_SPLIT", imu::ImuMsgType::IMU_WITH_MAG_SPLIT}};
1919
rotationVectorTypeMap = {{"ROTATION_VECTOR", dai::IMUSensor::ROTATION_VECTOR},
2020
{"GAME_ROTATION_VECTOR", dai::IMUSensor::GAME_ROTATION_VECTOR},
2121
{"GEOMAGNETIC_ROTATION_VECTOR", dai::IMUSensor::GEOMAGNETIC_ROTATION_VECTOR},
2222
{"ARVR_STABILIZED_ROTATION_VECTOR", dai::IMUSensor::ARVR_STABILIZED_ROTATION_VECTOR},
2323
{"ARVR_STABILIZED_GAME_ROTATION_VECTOR", dai::IMUSensor::ARVR_STABILIZED_GAME_ROTATION_VECTOR}};
24+
accelerometerModeMap = {{"ACCELEROMETER_RAW", dai::IMUSensor::ACCELEROMETER_RAW},
25+
{"ACCELEROMETER", dai::IMUSensor::ACCELEROMETER},
26+
{"LINEAR_ACCELERATION", dai::IMUSensor::LINEAR_ACCELERATION},
27+
{"GRAVITY", dai::IMUSensor::GRAVITY}};
28+
gyroscopeModeMap = {{"GYROSCOPE_RAW", dai::IMUSensor::GYROSCOPE_RAW},
29+
{"GYROSCOPE_CALIBRATED", dai::IMUSensor::GYROSCOPE_CALIBRATED},
30+
{"GYROSCOPE_UNCALIBRATED", dai::IMUSensor::GYROSCOPE_UNCALIBRATED}};
31+
magnetometerModeMap = {{"MAGNETOMETER_RAW", dai::IMUSensor::MAGNETOMETER_RAW},
32+
{"MAGNETOMETER_CALIBRATED", dai::IMUSensor::MAGNETOMETER_CALIBRATED},
33+
{"MAGNETOMETER_UNCALIBRATED", dai::IMUSensor::MAGNETOMETER_UNCALIBRATED}};
2434
}
2535
ImuParamHandler::~ImuParamHandler() = default;
2636
void ImuParamHandler::declareParams(std::shared_ptr<dai::node::IMU> imu, const std::string& imuType) {
2737
declareAndLogParam<bool>("i_get_base_device_timestamp", false);
2838
declareAndLogParam<int>("i_max_q_size", 8);
2939
auto messageType = declareAndLogParam<std::string>("i_message_type", "IMU");
3040
declareAndLogParam<std::string>("i_sync_method", "LINEAR_INTERPOLATE_ACCEL");
31-
declareAndLogParam<float>("i_acc_cov", 0.0);
32-
declareAndLogParam<float>("i_gyro_cov", 0.0);
33-
declareAndLogParam<float>("i_rot_cov", -1.0);
34-
declareAndLogParam<float>("i_mag_cov", 0.0);
3541
declareAndLogParam<bool>("i_update_ros_base_time_on_ros_msg", false);
36-
bool rotationAvailable = imuType == "BNO086";
37-
if(declareAndLogParam<bool>("i_enable_rotation", false)) {
42+
if(declareAndLogParam<bool>("i_enable_acc", true)) {
43+
const std::string accelerometerModeName = utils::getUpperCaseStr(declareAndLogParam<std::string>("i_acc_mode", "ACCELEROMETER_RAW"));
44+
const dai::IMUSensor accelerometerMode = utils::getValFromMap(accelerometerModeName, accelerometerModeMap);
45+
const int accelerometerFreq = declareAndLogParam<int>("i_acc_freq", 400);
46+
declareAndLogParam<float>("i_acc_cov", 0.0);
47+
48+
imu->enableIMUSensor(accelerometerMode, accelerometerFreq);
49+
}
50+
51+
if(declareAndLogParam<bool>("i_enable_gyro", true)) {
52+
const std::string gyroscopeModeName = utils::getUpperCaseStr(declareAndLogParam<std::string>("i_gyro_mode", "GYROSCOPE_RAW"));
53+
const dai::IMUSensor gyroscopeMode = utils::getValFromMap(gyroscopeModeName, gyroscopeModeMap);
54+
const int gyroscopeFreq = declareAndLogParam<int>("i_gyro_freq", 400);
55+
declareAndLogParam<float>("i_gyro_cov", 0.0);
56+
57+
imu->enableIMUSensor(gyroscopeMode, gyroscopeFreq);
58+
}
59+
60+
const bool magnetometerAvailable = imuType == "BNO086";
61+
if(declareAndLogParam<bool>("i_enable_mag", magnetometerAvailable)) {
62+
if(magnetometerAvailable) {
63+
const std::string magnetometerModeName = utils::getUpperCaseStr(declareAndLogParam<std::string>("i_mag_mode", "MAGNETOMETER_RAW"));
64+
const dai::IMUSensor magnetometerMode = utils::getValFromMap(magnetometerModeName, magnetometerModeMap);
65+
const int magnetometerFreq = declareAndLogParam<int>("i_mag_freq", 100);
66+
declareAndLogParam<float>("i_mag_cov", 0.0);
67+
68+
imu->enableIMUSensor(magnetometerMode, magnetometerFreq);
69+
} else {
70+
RCLCPP_ERROR(getROSNode()->get_logger(), "Magnetometer enabled but not available with current sensor");
71+
declareAndLogParam<bool>("i_enable_mag", false, true);
72+
}
73+
}
74+
75+
const bool rotationAvailable = imuType == "BNO086";
76+
if(declareAndLogParam<bool>("i_enable_rotation", rotationAvailable)) {
3877
if(rotationAvailable) {
39-
auto rotationVecType = utils::getValFromMap(utils::getUpperCaseStr(declareAndLogParam<std::string>("i_rotation_vector_type", "ROTATION_VECTOR")),
40-
rotationVectorTypeMap);
41-
imu->enableIMUSensor(rotationVecType, declareAndLogParam<int>("i_rot_freq", 400));
42-
// if imu message type is IMU_WITH_MAG or IMU_WITH_MAG_SPLIT, enable magnetometer
43-
if(messageType == "IMU_WITH_MAG" || messageType == "IMU_WITH_MAG_SPLIT") {
44-
imu->enableIMUSensor(dai::IMUSensor::MAGNETOMETER_CALIBRATED, declareAndLogParam<int>("i_mag_freq", 100));
45-
}
78+
const std::string rotationModeName = utils::getUpperCaseStr(declareAndLogParam<std::string>("i_rot_mode", "ROTATION_VECTOR"));
79+
const dai::IMUSensor rotationMode = utils::getValFromMap(rotationModeName, rotationVectorTypeMap);
80+
const int rotationFreq = declareAndLogParam<int>("i_rot_freq", 400);
81+
declareAndLogParam<float>("i_rot_cov", -1.0);
82+
83+
imu->enableIMUSensor(rotationMode, rotationFreq);
4684
} else {
4785
RCLCPP_ERROR(getROSNode()->get_logger(), "Rotation enabled but not available with current sensor");
4886
declareAndLogParam<bool>("i_enable_rotation", false, true);
4987
}
88+
imu->setBatchReportThreshold(declareAndLogParam<int>("i_batch_report_threshold", 5));
89+
imu->setMaxBatchReports(declareAndLogParam<int>("i_max_batch_reports", 10));
5090
}
51-
imu->enableIMUSensor(dai::IMUSensor::ACCELEROMETER_RAW, declareAndLogParam<int>("i_acc_freq", 400));
52-
imu->enableIMUSensor(dai::IMUSensor::GYROSCOPE_RAW, declareAndLogParam<int>("i_gyro_freq", 400));
53-
imu->setBatchReportThreshold(declareAndLogParam<int>("i_batch_report_threshold", 5));
54-
imu->setMaxBatchReports(declareAndLogParam<int>("i_max_batch_reports", 10));
5591
}
5692

5793
dai::ros::ImuSyncMethod ImuParamHandler::getSyncMethod() {
58-
return utils::getValFromMap(utils::getUpperCaseStr(getParam<std::string>("i_sync_method")), imuSyncMethodMap);
94+
return utils::getValFromMap(utils::getUpperCaseStr(getParam<std::string>("i_sync_method")), syncMethodMap);
5995
}
6096

6197
imu::ImuMsgType ImuParamHandler::getMsgType() {
62-
return utils::getValFromMap(utils::getUpperCaseStr(getParam<std::string>("i_message_type")), imuMessagetTypeMap);
98+
return utils::getValFromMap(utils::getUpperCaseStr(getParam<std::string>("i_message_type")), messagetTypeMap);
6399
}
64100

65101
dai::CameraControl ImuParamHandler::setRuntimeParams(const std::vector<rclcpp::Parameter>& /*params*/) {

depthai_ros_msgs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS
22

3-
project(depthai_ros_msgs VERSION 2.11.1)
3+
project(depthai_ros_msgs VERSION 2.11.2)
44

55
if(POLICY CMP0057)
66
cmake_policy(SET CMP0057 NEW)

depthai_ros_msgs/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package format="3">
33
<name>depthai_ros_msgs</name>
4-
<version>2.11.1</version>
4+
<version>2.11.2</version>
55
<description>Package to keep interface independent of the driver</description>
66

77
<maintainer email="[email protected]">Adam Serafin</maintainer>

0 commit comments

Comments
 (0)