moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
move_group_api_test.cpp
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2024, PickNik Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of PickNik Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35/* Author: Sebastian Jahr
36 Description: Integration tests for the move_group interface
37*/
38
39#include <gtest/gtest.h>
40#include <rclcpp/rclcpp.hpp>
41
43
44class MoveGroupFixture : public testing::Test
45{
46protected:
47 void SetUp() override
48 {
49 rclcpp::NodeOptions node_options;
50 node_options.automatically_declare_parameters_from_overrides(true);
51 test_node_ = std::make_shared<rclcpp::Node>("move_group_param_test_node", node_options);
52 }
53
54 void TearDown() override
55 {
56 }
57
58 std::shared_ptr<rclcpp::Node> test_node_;
59};
60
62{
63 // Create parameter client
64 auto params_client = std::make_shared<rclcpp::SyncParametersClient>(test_node_, "move_group");
65 bool reach_param_client = params_client->wait_for_service(std::chrono::seconds(5));
66 // This pattern helps with debugging if service is not available.
67 if (!reach_param_client)
68 {
69 RCLCPP_ERROR(test_node_->get_logger(), "Couldn't reach parameter server. Is the move_group up and running?");
70 }
71 ASSERT_TRUE(reach_param_client);
72
73 // GIVEN a running move_group
74 // WHEN a parameter name from parameter API checked
75 // THEN that parameter exists
76 for (const auto& param_name : move_group_test::PARAMETER_NAME_LIST)
77 {
78 bool param_exists = false;
79 if (params_client->wait_for_service(std::chrono::milliseconds(1)))
80 {
81 param_exists = params_client->has_parameter(param_name);
82 if (!param_exists)
83 {
84 RCLCPP_ERROR(test_node_->get_logger(), "Parameter %s doesn't exists", param_name.c_str());
85 }
86 }
87 else
88 {
89 RCLCPP_ERROR(test_node_->get_logger(), "Cannot read parameter %s because service couldn't be reached",
90 param_name.c_str());
91 }
92 EXPECT_TRUE(param_exists);
93 }
94}
95
96// TODO(sjahr): Add more API tests e.g. from move_group_interface_cpp_test.cpp
97
98int main(int argc, char** argv)
99{
100 rclcpp::init(argc, argv);
101 ::testing::InitGoogleTest(&argc, argv);
102 int result = RUN_ALL_TESTS();
103 rclcpp::shutdown();
104 return result;
105}
void TearDown() override
std::shared_ptr< rclcpp::Node > test_node_
int main(int argc, char **argv)
TEST_F(MoveGroupFixture, testParamAPI)
const std::vector< std::string > PARAMETER_NAME_LIST