34 #include <gtest/gtest.h>
37 #include <urdf_parser/urdf_parser.h>
39 TEST(time_optimal_trajectory_generation, test_totg_with_torque_limits)
44 const std::string
urdf = R
"(<?xml version="1.0" ?>
45 <robot name="one_robot">
46 <link name="base_link"/>
47 <joint name="joint_a" type="continuous">
48 <axis xyz="0.7071 0.7071 0"/>
49 <parent link="base_link"/>
50 <child link="link_a"/>
55 const std::string
srdf = R
"(<?xml version="1.0" ?>
56 <robot name="one_robot">
57 <virtual_joint name="base_joint" child_link="base_link" parent_frame="odom_combined" type="planar"/>
58 <group name="single_dof_group">
59 <joint name="joint_a"/>
63 urdf::ModelInterfaceSharedPtr urdf_model = urdf::parseURDF(urdf);
65 srdf_model->initString(*urdf_model, srdf);
66 auto robot_model = std::make_shared<moveit::core::RobotModel>(urdf_model, srdf_model);
67 ASSERT_TRUE((
bool)
robot_model) <<
"Failed to load robot model";
69 auto group =
robot_model->getJointModelGroup(
"single_dof_group");
70 ASSERT_TRUE((
bool)group) <<
"Failed to load joint model group ";
80 const geometry_msgs::Vector3 gravity_vector = [] {
81 geometry_msgs::Vector3 gravity;
87 const std::vector<double> joint_torque_limits{ 250 };
88 const double accel_limit_decrement_factor = 0.1;
89 const std::unordered_map<std::string, double> velocity_limits = { {
"joint_a", 3 } };
90 const std::unordered_map<std::string, double> acceleration_limits = { {
"joint_a", 3 } };
96 const std::vector<geometry_msgs::Wrench> external_link_wrenches = [&group] {
97 geometry_msgs::Wrench zero_wrench;
98 zero_wrench.force.x = 0;
99 zero_wrench.force.y = 0;
100 zero_wrench.force.z = 0;
101 zero_wrench.torque.x = 0;
102 zero_wrench.torque.y = 0;
103 zero_wrench.torque.z = 0;
105 std::vector<geometry_msgs::Wrench> vector_of_zero_wrenches(group->getLinkModels().size(), zero_wrench);
106 return vector_of_zero_wrenches;
111 accel_limit_decrement_factor, velocity_limits, acceleration_limits,
113 ASSERT_TRUE(totg_success) <<
"Failed to compute timestamps";
117 const std::vector<double> lower_torque_limits{ 1 };
120 accel_limit_decrement_factor, velocity_limits, acceleration_limits,
122 ASSERT_TRUE(totg_success) <<
"Failed to compute timestamps";
124 EXPECT_GT(second_duration, first_duration) <<
"The second time parameterization should result in a longer duration";
127 int main(
int argc,
char** argv)
129 testing::InitGoogleTest(&argc, argv);
130 return RUN_ALL_TESTS();