moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
warehouse_fixture.cpp
Go to the documentation of this file.
1// Copyright 2024 Intrinsic Innovation LLC.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
19#include <thread>
20
21#include <gtest/gtest.h>
22#include <rclcpp/executors/single_threaded_executor.hpp>
23#include <rclcpp/rclcpp.hpp>
25
26#include "warehouse_fixture.hpp"
27
28WarehouseFixture::WarehouseFixture() : node_(rclcpp::Node::make_shared("warehouse_fixture"))
29{
30 node_->declare_parameter<std::string>("warehouse_plugin", "warehouse_ros_sqlite::DatabaseConnection");
31}
32
34{
35 is_spinning_ = false;
36 if (spin_thread_.joinable())
37 {
38 spin_thread_.join();
39 }
40}
41
43{
44 is_spinning_ = true;
45 spin_thread_ = std::thread(&WarehouseFixture::spinNode, this);
46
48 db_->setParams(":memory:", 1);
49 ASSERT_TRUE(db_->connect());
50}
51
53{
54 db_.reset();
55 is_spinning_ = false;
56 spin_thread_.join();
57}
58
59void WarehouseFixture::spinNode()
60{
61 rclcpp::executors::SingleThreadedExecutor executor;
62 executor.add_node(node_);
63 while (is_spinning_ && rclcpp::ok())
64 {
65 executor.spin_some();
66 }
67}
rclcpp::Node::SharedPtr node_
warehouse_ros::DatabaseConnection::Ptr db_
void TearDown() override
void SetUp() override
warehouse_ros::DatabaseConnection::Ptr loadDatabase(const rclcpp::Node::SharedPtr &node)
Load a database connection.