<commit_before>
/// \author <NAME>

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

#include <moveit/move_group_interface/move_group_interface.h>
#include <moveit/planning_scene_interface/planning_scene_interface.h>

class CHOMPMoveitTest : public ::testing::Test
{
public:
  moveit::planning_interface::MoveGroupInterface move_group;

public:
  CHOMPMoveitTest() : move_group(moveit::planning_interface::MoveGroupInterface("arm"))
  {
  }
};

// TEST CASES
TEST_F(CHOMPMoveitTest, jointSpaceGoodGoal)
{
  move_group.setStartState(*(move_group.getCurrentState()));
  move_group.setJointValueTarget(std::vector<double>({ 1.0, 1.0 }));

  moveit::planning_interface::MoveGroupInterface::Plan my_plan;

  moveit::planning_interface::MoveItErrorCode error_code = move_group.plan(my_plan);
  EXPECT_GT(my_plan.trajectory_.joint_trajectory.points.size(), 0);
  EXPECT_EQ(error_code.val, moveit::planning_interface::MoveItErrorCode::SUCCESS);
}

TEST_F(CHOMPMoveitTest, jointSpaceBadGoal)
{
  move_group.setStartState(*(move_group.getCurrentState()));
  // joint2 is limited to [-PI/2, PI/2]
  move_group.setJointValueTarget(std::vector<double>({ 100.0, 2 * M_PI / 3.0 }));

  moveit::planning_interface::MoveGroupInterface::Plan my_plan;

  moveit::planning_interface::MoveItErrorCode error_code = move_group.plan(my_plan);
  EXPECT_EQ(error_code.val, moveit::planning_interface::MoveItErrorCode::INVALID_ROBOT_STATE);
}

TEST_F(CHOMPMoveitTest, cartesianGoal)
{
  move_group.setStartState(*(move_group.getCurrentState()));
  geometry_msgs::Pose target_pose1;
  target_pose1.orientation.w = 1.0;
  target_pose1.position.x = 10000.;
  target_pose1.position.y = 10000.;
  target_pose1.position.z = 10000.;
  move_group.setPoseTarget(target_pose1);

  moveit::planning_interface::MoveGroupInterface::Plan my_plan;

  moveit::planning_interface::MoveItErrorCode error_code = move_group.plan(my_plan);
  // CHOMP doesn't support Cartesian-space goals at the moment
  EXPECT_EQ(error_code.val, moveit::planning_interface::MoveItErrorCode::INVALID_GOAL_CONSTRAINTS);
}

TEST_F(CHOMPMoveitTest, noStartState)
{
  move_group.setJointValueTarget(std::vector<double>({ 0.2, 0.2 }));

  moveit::planning_interface::MoveGroupInterface::Plan my_plan;

  moveit::planning_interface::MoveItErrorCode error_code = move_group.plan(my_plan);
  EXPECT_EQ(error_code.val, moveit::planning_interface::MoveItErrorCode::INVALID_ROBOT_STATE);
}

int main(int argc, char** argv)
{
  testing::InitGoogleTest(&argc, argv);
  ros::init(argc, argv, "chomp_moveit_test");

  ros::AsyncSpinner spinner(1);
  spinner.start();
  int ret = RUN_ALL_TESTS();
  spinner.stop();
  ros::shutdown();
  return ret;
}<commit_msg>Add test for collision in path<commit_after>
/// \author <NAME>

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

#include <moveit/move_group_interface/move_group_interface.h>
#include <moveit/planning_scene_interface/planning_scene_interface.h>

class CHOMPMoveitTest : public ::testing::Test
{
public:
  moveit::planning_interface::MoveGroupInterface move_group;

public:
  CHOMPMoveitTest() : move_group(moveit::planning_interface::MoveGroupInterface("arm"))
  {
  }
};

// TEST CASES
TEST_F(CHOMPMoveitTest, jointSpaceGoodGoal)
{
  move_group.setStartState(*(move_group.getCurrentState()));
  move_group.setJointValueTarget(std::vector<double>({ 1.0, 1.0 }));

  moveit::planning_interface::MoveGroupInterface::Plan my_plan;

  moveit::planning_interface::MoveItErrorCode error_code = move_group.plan(my_plan);
  EXPECT_GT(my_plan.trajectory_.joint_trajectory.points.size(), 0);
  EXPECT_EQ(error_code.val, moveit::planning_interface::MoveItErrorCode::SUCCESS);
}

TEST_F(CHOMPMoveitTest, jointSpaceBadGoal)
{
  move_group.setStartState(*(move_group.getCurrentState()));
  // joint2 is limited to [-PI/2, PI/2]
  move_group.setJointValueTarget(std::vector<double>({ 100.0, 2 * M_PI / 3.0 }));

  moveit::planning_interface::MoveGroupInterface::Plan my_plan;

  moveit::planning_interface::MoveItErrorCode error_code = move_group.plan(my_plan);
  EXPECT_EQ(error_code.val, moveit::planning_interface::MoveItErrorCode::INVALID_ROBOT_STATE);
}

TEST_F(CHOMPMoveitTest, cartesianGoal)
{
  move_group.setStartState(*(move_group.getCurrentState()));
  geometry_msgs::Pose target_pose1;
  target_pose1.orientation.w = 1.0;
  target_pose1.position.x = 10000.;
  target_pose1.position.y = 10000.;
  target_pose1.position.z = 10000.;
  move_group.setPoseTarget(target_pose1);

  moveit::planning_interface::MoveGroupInterface::Plan my_plan;

  moveit::planning_interface::MoveItErrorCode error_code = move_group.plan(my_plan);
  // CHOMP doesn't support Cartesian-space goals at the moment
  EXPECT_EQ(error_code.val, moveit::planning_interface::MoveItErrorCode::INVALID_GOAL_CONSTRAINTS);
}

TEST_F(CHOMPMoveitTest, noStartState)
{
  move_group.setJointValueTarget(std::vector<double>({ 0.2, 0.2 }));

  moveit::planning_interface::MoveGroupInterface::Plan my_plan;

  moveit::planning_interface::MoveItErrorCode error_code = move_group.plan(my_plan);
  EXPECT_EQ(error_code.val, moveit::planning_interface::MoveItErrorCode::INVALID_ROBOT_STATE);
}

TEST_F(CHOMPMoveitTest, collisionAtEndOfPath)
{
  move_group.setStartState(*(move_group.getCurrentState()));
  move_group.setJointValueTarget(std::vector<double>({ M_PI/2.0, 0 }));
  moveit::planning_interface::MoveGroupInterface::Plan my_plan;

  moveit::planning_interface::MoveItErrorCode error_code = move_group.plan(my_plan);
  EXPECT_EQ(error_code.val, moveit::planning_interface::MoveItErrorCode::INVALID_MOTION_PLAN);
}

int main(int argc, char** argv)
{
  testing::InitGoogleTest(&argc, argv);
  ros::init(argc, argv, "chomp_moveit_test");

  ros::AsyncSpinner spinner(1);
  spinner.start();
  int ret = RUN_ALL_TESTS();
  spinner.stop();
  ros::shutdown();
  return ret;
}
{'fraction_non_alphanumeric': 0.13490696071674707, 'fraction_numerical': 0.015334252239834596, 'mean_word_length': 7.612759643916914, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1372200', 'n_tokens_mistral': 2131, 'n_tokens_neox': 2081, 'n_words': 258}