Skip to content

Commit b8c73b7

Browse files
authored
Functional Tweaks for Jazzy Migration (#3)
* Compiler and functional tweaks for MoveIt jazzy * Format fixes * More updates * More changed functions and add re-planning
1 parent 9dedfff commit b8c73b7

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

clr_pick_and_place_demo/src/run_demo.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
#include <map>
2323
#include <thread>
2424

25-
#include <moveit/move_group_interface/move_group_interface.h>
26-
#include <moveit/trajectory_processing/iterative_time_parameterization.h>
2725
#include <moveit_visual_tools/moveit_visual_tools.h>
26+
#include <moveit/move_group_interface/move_group_interface.hpp>
27+
#include <moveit/trajectory_processing/time_optimal_trajectory_generation.hpp>
28+
#include <moveit/utils/moveit_error_code.hpp>
2829
#include <moveit_msgs/msg/allowed_collision_matrix.hpp>
2930
#include <moveit_msgs/srv/apply_planning_scene.hpp>
3031
#include <moveit_msgs/srv/get_planning_scene.hpp>
@@ -701,10 +702,9 @@ class RunDemoNode : public rclcpp::Node
701702
RCLCPP_INFO(LOGGER, "End effector link: %s", move_group->getEndEffectorLink().c_str());
702703
RCLCPP_INFO(LOGGER, "Using planning group: %s", move_group->getName().c_str());
703704

704-
const double jump_threshold = 0.0;
705705
const double eef_step = 0.01;
706706

707-
double trajectory_percent = move_group->computeCartesianPath(poses, eef_step, jump_threshold, trajectory);
707+
double trajectory_percent = move_group->computeCartesianPath(poses, eef_step, trajectory);
708708

709709
if (trajectory_percent == 1.0)
710710
{
@@ -728,10 +728,10 @@ class RunDemoNode : public rclcpp::Node
728728
// The page below is referenced, which recommends manual velocity scaling:
729729
// https://groups.google.com/g/moveit-users/c/MOoFxy2exT4
730730

731-
trajectory_processing::IterativeParabolicTimeParameterization iptp;
731+
trajectory_processing::TimeOptimalTrajectoryGeneration totg;
732732

733733
bool success;
734-
success = iptp.computeTimeStamps(rt, scaling, scaling);
734+
success = totg.computeTimeStamps(rt, scaling, scaling);
735735
RCLCPP_INFO(LOGGER, "Computed time stamp %s", success ? "SUCCEEDED" : "FAILED");
736736

737737
if (success)
@@ -760,38 +760,37 @@ class RunDemoNode : public rclcpp::Node
760760
{
761761
move_group->setJointValueTarget(move_group->getNamedTargetValues(waypoint.preset_name));
762762
}
763-
if (waypoint.use_jconfig)
763+
else if (waypoint.use_jconfig)
764764
{
765765
move_group->setJointValueTarget(waypoint.config);
766-
move_group->setNumPlanningAttempts(10);
767766
}
768767
else
769768
{
770-
geometry_msgs::msg::Pose start_pose = move_group->getCurrentPose().pose;
771769
geometry_msgs::msg::Pose end_pose = waypoint.pose;
772770
if (waypoint.is_relative)
773771
{
772+
geometry_msgs::msg::Pose start_pose = move_group->getCurrentPose().pose;
774773
end_pose = this->relative_to_global(start_pose, end_pose);
775774
}
776-
move_group->setJointValueTarget(end_pose);
777-
move_group->setNumPlanningAttempts(10);
775+
move_group->setPoseTarget(end_pose);
778776
}
779777

778+
move_group->setNumPlanningAttempts(5);
780779
move_group->setMaxVelocityScalingFactor(scaling);
781780
move_group->setMaxAccelerationScalingFactor(scaling);
782781

783782
moveit::planning_interface::MoveGroupInterface::Plan plan;
784783
moveit::core::MoveItErrorCode error_code = move_group->plan(plan);
785784

786-
if (error_code == moveit::core::MoveItErrorCode::SUCCESS)
785+
if (error_code)
787786
{
788787
RCLCPP_INFO(LOGGER, "Successfully computed trajectory");
789-
trajectory = plan.trajectory_;
788+
trajectory = plan.trajectory;
790789
return true;
791790
}
792791
else
793792
{
794-
RCLCPP_ERROR(LOGGER, "Planning failed with error code %s", error_code_to_string(error_code).c_str());
793+
RCLCPP_ERROR(LOGGER, "Planning failed: %s", error_code.message.c_str());
795794
return false;
796795
}
797796
}
@@ -801,7 +800,7 @@ class RunDemoNode : public rclcpp::Node
801800
moveit::core::MoveItErrorCode move_success = move_group->execute(trajectory);
802801
if (move_success != moveit::core::MoveItErrorCode::SUCCESS)
803802
{
804-
error_code_to_string(move_success);
803+
RCLCPP_ERROR(LOGGER, "Execution failed with error code %s", move_success.message.c_str());
805804
return false;
806805
}
807806
return true;

0 commit comments

Comments
 (0)