Skip to content

Commit

Permalink
[test] duplicate scenes in Solution.msg
Browse files Browse the repository at this point in the history
  • Loading branch information
captain-yoshi committed Dec 14, 2024
1 parent 5d23cb8 commit 904020f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if (CATKIN_ENABLE_TESTING)
mtc_add_gmock(test_pruning.cpp)
mtc_add_gtest(test_properties.cpp)
mtc_add_gtest(test_cost_terms.cpp)
mtc_add_gtest(test_storage.cpp)

mtc_add_gmock(test_fallback.cpp)
mtc_add_gmock(test_cost_queue.cpp)
Expand Down
35 changes: 35 additions & 0 deletions core/test/test_storage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "models.h"

#include <moveit/task_constructor/task.h>
#include <moveit/task_constructor/stages/fixed_state.h>

#include <moveit/planning_scene/planning_scene.h>

#include <ros/console.h>
#include <gtest/gtest.h>

using namespace moveit::task_constructor;
using namespace planning_scene;
using namespace moveit::core;

// https://github.com/moveit/moveit_task_constructor/issues/638
TEST(SolutionMsg, DuplicateScenes) {
Task t;
PlanningScenePtr scene;

t.setRobotModel(getModel());
scene = std::make_shared<PlanningScene>(t.getRobotModel());
t.add(std::make_unique<stages::FixedState>("start", scene));

EXPECT_TRUE(t.plan(1));
EXPECT_EQ(t.solutions().size(), 1u);

// create solution
moveit_task_constructor_msgs::Solution solution_msg;
t.solutions().front()->toMsg(solution_msg);

// all sub trajectories `scene_diff` should be a diff
EXPECT_EQ(solution_msg.sub_trajectory.size(), 1u);
EXPECT_EQ(solution_msg.start_scene.is_diff, false);
EXPECT_EQ(solution_msg.sub_trajectory.front().scene_diff.is_diff, true);
}

0 comments on commit 904020f

Please sign in to comment.