311 Sequence seq{ data_loader_->getSequence(
"SimpleSequence") };
314 std::size_t num_cmds{ 2 };
315 std::vector<planning_interface::MotionPlanResponse> responses(num_cmds);
317 for (
size_t index = 0; index < num_cmds; ++index)
329 lin_generator_->generate(planning_scene_, req, resp, sampling_time_);
330 if (resp.
error_code.val != moveit_msgs::msg::MoveItErrorCodes::SUCCESS)
332 std::runtime_error(
"Failed to generate trajectory.");
334 responses.at(index) = resp;
345 EXPECT_FALSE(blender_->blend(planning_scene_, blend_req, blend_res));
583 Sequence seq{ data_loader_->getSequence(
"SimpleSequence") };
587 std::vector<planning_interface::MotionPlanResponse> res{ generateLinTrajs(seq, 2) };
597 EXPECT_TRUE(blender_->blend(planning_scene_, blend_req, blend_res));
600 joint_acceleration_tolerance_, cartesian_velocity_tolerance_,
601 cartesian_angular_velocity_tolerance_));
629 const double sine_scaling_factor{ 0.01 };
630 const double time_scaling_factor{ 10 };
632 Sequence seq{ data_loader_->getSequence(
"SimpleSequence") };
634 std::vector<planning_interface::MotionPlanResponse> res{ generateLinTrajs(seq, 2) };
637 std::vector<robot_trajectory::RobotTrajectoryPtr> sine_trajs(2);
639 for (
size_t traj_index = 0; traj_index < 2; ++traj_index)
641 auto lin_traj{ res.at(traj_index).trajectory };
644 trajectory_msgs::msg::JointTrajectory joint_traj;
645 const double duration{ lin_traj->getWayPointDurationFromStart(lin_traj->getWayPointCount()) };
647 const double time_from_start_offset{ time_scaling_factor * lin_traj->getWayPointDurations().back() };
650 for (
size_t i = 0; i < lin_traj->getWayPointCount(); ++i)
653 const double sine_arg{ 4 * M_PI * lin_traj->getWayPointDurationFromStart(i) / duration };
657 const Eigen::Isometry3d eigen_pose{ lin_traj->getWayPointPtr(i)->getFrameTransform(target_link_) };
658 geometry_msgs::msg::Pose waypoint_pose = tf2::toMsg(eigen_pose);
661 waypoint_pose.position.x += sine_scaling_factor * sin(sine_arg);
662 waypoint_pose.position.y += sine_scaling_factor * sin(sine_arg);
663 waypoint_pose.position.z += sine_scaling_factor * sin(sine_arg);
666 waypoint.
pose = waypoint_pose;
668 time_from_start_offset + time_scaling_factor * lin_traj->getWayPointDurationFromStart(i));
669 cart_traj.
points.push_back(waypoint);
673 std::map<std::string, double> initial_joint_position, initial_joint_velocity;
674 for (
const std::string& joint_name :
675 lin_traj->getFirstWayPointPtr()->getJointModelGroup(planning_group_)->getActiveJointModelNames())
679 initial_joint_position[joint_name] = lin_traj->getFirstWayPoint().getVariablePosition(joint_name);
680 initial_joint_velocity[joint_name] = lin_traj->getFirstWayPoint().getVariableVelocity(joint_name);
684 initial_joint_position[joint_name] =
685 sine_trajs[traj_index - 1]->getLastWayPoint().getVariablePosition(joint_name);
686 initial_joint_velocity[joint_name] =
687 sine_trajs[traj_index - 1]->getLastWayPoint().getVariableVelocity(joint_name);
691 moveit_msgs::msg::MoveItErrorCodes error_code;
692 if (!
generateJointTrajectory(planning_scene_, planner_limits_.getJointLimitContainer(), cart_traj, planning_group_,
693 target_link_, initial_joint_position, initial_joint_velocity, joint_traj, error_code,
696 std::runtime_error(
"Failed to generate trajectory.");
699 joint_traj.points.back().velocities.assign(joint_traj.points.back().velocities.size(), 0.0);
700 joint_traj.points.back().accelerations.assign(joint_traj.points.back().accelerations.size(), 0.0);
703 sine_trajs[traj_index] = std::make_shared<robot_trajectory::RobotTrajectory>(robot_model_, planning_group_);
704 sine_trajs.at(traj_index)->setRobotTrajectoryMsg(lin_traj->getFirstWayPoint(), joint_traj);
717 EXPECT_TRUE(blender_->blend(planning_scene_, blend_req, blend_res));
720 joint_acceleration_tolerance_, cartesian_velocity_tolerance_,
721 cartesian_angular_velocity_tolerance_));
bool generateJointTrajectory(const planning_scene::PlanningSceneConstPtr &scene, const JointLimitsContainer &joint_limits, const KDL::Trajectory &trajectory, const std::string &group_name, const std::string &link_name, const std::map< std::string, double > &initial_joint_position, double sampling_time, trajectory_msgs::msg::JointTrajectory &joint_trajectory, moveit_msgs::msg::MoveItErrorCodes &error_code, bool check_self_collision=false)
Generate joint trajectory from a KDL Cartesian trajectory.
bool checkBlendResult(const pilz_industrial_motion_planner::TrajectoryBlendRequest &blend_req, const pilz_industrial_motion_planner::TrajectoryBlendResponse &blend_res, const pilz_industrial_motion_planner::LimitsContainer &limits, double joint_velocity_tolerance, double joint_acceleration_tolerance, double cartesian_velocity_tolerance, double cartesian_angular_velocity_tolerance)
check the blending result of lin-lin