Skip to content

Commit 5715a39

Browse files
committed
unmanaged instance, bump core, enable tests
1 parent 362f215 commit 5715a39

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh
1414
ENV WS=/ws
1515
RUN mkdir -p $WS/src
1616
COPY ./ $WS/src/depthai-ros
17-
RUN cd .${WS}/src && git clone --branch ros-v3.0.7 https://github.com/luxonis/depthai-core.git && cd depthai-core && git submodule update --init --recursive
17+
RUN cd .${WS}/src && git clone --branch ros-v3.1.0 https://github.com/luxonis/depthai-core.git && cd depthai-core && git submodule update --init --recursive
1818
RUN cd $WS/ && rosdep install --from-paths src --ignore-src -y
1919

2020
RUN cd $WS/ && . /opt/ros/${ROS_DISTRO}/setup.sh && ./src/depthai-ros/build.sh -s $BUILD_SEQUENTIAL -r 1 -m 1 -t $BUILD_TESTS

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ build_testing_flag="-DBUILD_TESTING=OFF"
5050
test_ros_driver_flag="-DTEST_DEPTHAI_ROS_DRIVER=OFF"
5151
if [ "$tests" == 1 ]; then
5252
build_testing_flag="-DBUILD_TESTING=ON"
53-
test_ros_driver_flag="-DTEST_DEPTHAI_ROS_DRIVER=OFF"
53+
test_ros_driver_flag="-DTEST_DEPTHAI_ROS_DRIVER=ON"
5454
fi
5555

5656

depthai_ros_driver/include/depthai_ros_driver/pipeline/pipeline_generator.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ class PipelineGenerator {
5353
*/
5454
void createPipeline(std::shared_ptr<rclcpp::Node> node, std::shared_ptr<dai::Device> device, std::shared_ptr<dai::Pipeline> pipeline, bool rsCompat);
5555

56+
void updateParams(const std::vector<rclcpp::Parameter>& params);
57+
5658
protected:
5759
std::unordered_map<std::string, std::string> pluginTypeMap;
5860
std::unordered_map<std::string, PipelineType> pipelineTypeMap;
5961

6062
private:
6163
std::shared_ptr<param_handlers::PipelineGenParamHandler> ph;
62-
std::vector<std::unique_ptr<dai_nodes::BaseNode>> daiNodes;
6364
std::shared_ptr<pluginlib::ClassLoader<BasePipeline>> pipelineLoader;
64-
class_loader::ClassLoader::UniquePtr<BasePipeline> pipelinePlugin;
65+
std::vector<std::unique_ptr<dai_nodes::BaseNode>> daiNodes;
6566
};
6667
} // namespace pipeline_gen
6768
} // namespace depthai_ros_driver

depthai_ros_driver/src/driver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ void Driver::stop() {
109109
RCLCPP_INFO(get_logger(), "Driver stopped!");
110110
}
111111
} else {
112-
RCLCPP_INFO(get_logger(), "Driver already stopped!");
112+
if(rclcpp::ok()) {
113+
RCLCPP_INFO(get_logger(), "Driver already stopped!");
114+
}
113115
}
114116
}
115117

@@ -307,9 +309,7 @@ rcl_interfaces::msg::SetParametersResult Driver::parameterCB(const std::vector<r
307309
}
308310
}
309311
}
310-
// for(const auto& node : daiNodes) {
311-
// node->updateParams(params);
312-
// }
312+
generator->updateParams(params);
313313
rcl_interfaces::msg::SetParametersResult res;
314314
res.successful = true;
315315
return res;

depthai_ros_driver/src/pipeline/pipeline_generator.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ PipelineGenerator::PipelineGenerator()
3939
{"THERMAL", PipelineType::Thermal}};
4040
}
4141

42-
PipelineGenerator::~PipelineGenerator() {
43-
pipelinePlugin.reset();
44-
daiNodes.clear();
45-
pipelineLoader.reset();
46-
}
42+
PipelineGenerator::~PipelineGenerator() = default;
4743
void PipelineGenerator::createPipeline(std::shared_ptr<rclcpp::Node> node,
4844
std::shared_ptr<dai::Device> device,
4945
std::shared_ptr<dai::Pipeline> pipeline,
@@ -66,8 +62,11 @@ void PipelineGenerator::createPipeline(std::shared_ptr<rclcpp::Node> node,
6662
}
6763

6864
try {
69-
pipelinePlugin = pipelineLoader->createUniqueInstance(pluginType);
65+
// other types of instancing (shared/unique ptr) seem to cause memory issues when shutting down the driver
66+
auto pipelinePlugin = pipelineLoader->createUnmanagedInstance(pluginType);
7067
daiNodes = pipelinePlugin->createPipeline(node, device, pipeline, ph, deviceName, rsCompat, nnType);
68+
pipelineLoader->unloadLibraryForClass(pluginType);
69+
delete pipelinePlugin;
7170
} catch(pluginlib::PluginlibException& ex) {
7271
RCLCPP_ERROR(node->get_logger(), "The plugin failed to load for some reason. Error: %s\n", ex.what());
7372
throw std::runtime_error("Plugin loading failed.");
@@ -106,6 +105,11 @@ void PipelineGenerator::createPipeline(std::shared_ptr<rclcpp::Node> node,
106105
RCLCPP_INFO(node->get_logger(), "Finished setting up pipeline.");
107106
}
108107

108+
void PipelineGenerator::updateParams(const std::vector<rclcpp::Parameter>& params) {
109+
for(const auto& node : daiNodes) {
110+
node->updateParams(params);
111+
}
112+
}
109113
std::string PipelineGenerator::validatePipeline(std::shared_ptr<rclcpp::Node> node, const std::string& typeStr, int sensorNum, const std::string& deviceName) {
110114
auto pType = utils::getValFromMap(typeStr, pipelineTypeMap);
111115
if(deviceName == "OAK-D-SR-POE") {

0 commit comments

Comments
 (0)