40 #include <rclcpp/rclcpp.hpp>
43 #include <gtest/gtest.h>
49 #include <geometry_msgs/PointStamped.h>
58 rclcpp::NodeOptions node_options;
63 node_options.automatically_declare_parameters_from_overrides(
true);
64 node_ = rclcpp::Node::make_shared(
"/moveit_cpp_test");
102 ros::Duration(1.0).sleep();
103 auto robot_model = moveit_cpp_ptr->getRobotModel();
104 auto robot_state = std::make_shared<moveit::core::RobotState>(robot_model);
105 EXPECT_TRUE(moveit_cpp_ptr->getCurrentState(robot_state, 0.0));
107 std::vector<double> joints_vals;
108 robot_state->copyJointGroupPositions(PLANNING_GROUP, joints_vals);
109 EXPECT_NEAR(joints_vals[0], 0.0, 0.001);
110 EXPECT_NEAR(joints_vals[1], -0.785, 0.001);
111 EXPECT_NEAR(joints_vals[2], 0.0, 0.001);
112 EXPECT_NEAR(joints_vals[3], -2.356, 0.001);
113 EXPECT_NEAR(joints_vals[4], 0.0, 0.001);
114 EXPECT_NEAR(joints_vals[5], 1.571, 0.001);
115 EXPECT_NEAR(joints_vals[6], 0.785, 0.001);
121 EXPECT_STREQ(planning_component_ptr->getPlanningGroupName().c_str(),
"panda_arm");
127 planning_component_ptr->setStartStateToCurrentState();
128 planning_component_ptr->setGoal(target_pose1,
"panda_link8");
130 ASSERT_TRUE(
static_cast<bool>(planning_component_ptr->plan()));
137 planning_component_ptr->setGoal(target_pose1,
"panda_link8");
139 ASSERT_TRUE(
static_cast<bool>(planning_component_ptr->plan()));
145 auto start_state = *(moveit_cpp_ptr->getCurrentState());
146 start_state.setFromIK(jmg_ptr, start_pose);
148 planning_component_ptr->setStartState(start_state);
149 planning_component_ptr->setGoal(target_pose1,
"panda_link8");
151 ASSERT_TRUE(
static_cast<bool>(planning_component_ptr->plan()));
157 auto target_state = *(moveit_cpp_ptr->getCurrentState());
159 target_state.setFromIK(jmg_ptr, target_pose2);
161 planning_component_ptr->setGoal(target_state);
163 ASSERT_TRUE(
static_cast<bool>(planning_component_ptr->plan()));
167 int main(
int argc,
char** argv)
169 testing::InitGoogleTest(&argc, argv);
170 ros::init(argc, argv,
"moveit_cpp_test");
172 ros::AsyncSpinner spinner(4);
175 int result = RUN_ALL_TESTS();
PlanningComponentPtr planning_component_ptr
const std::string PLANNING_GROUP
geometry_msgs::PoseStamped target_pose1
const moveit::core::JointModelGroup * jmg_ptr
moveit::core::RobotModelConstPtr robot_model_ptr
geometry_msgs::Pose start_pose
MoveItCppPtr moveit_cpp_ptr
geometry_msgs::Pose target_pose2
int main(int argc, char **argv)
TEST_F(MoveItCppTest, GetCurrentStateTest)