Cmake error cartesian path

Hi, I am trying to launch the cartesian path code but I am getting the Cmake error pasted below. I have checked the Cmake file but I am not sure what is going wrong.

CMake Error at /opt/ros/humble/share/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake:77 (message):
ament_target_dependencies() the passed package name ‘grasping_msgs’ was not
found before
Call Stack (most recent call first):
CMakeLists.txt:131 (ament_target_dependencies)

Any suggestions?
Thanks

Hello @tumoney84 ,

You can remove grasping_msgs from the dependencies in the CMakeLists.txt file, line 140. This should get rid of the error message.

Best,

That works, thank you!

I have one more question. On the previous section Unit 3 Motion planning with C++ I was able to execute the final launch file to execute the approach_retreat trajectory. However the arm after doing the planning did not close the gripper and grabbed the object. I Initially thought it might be that my name of the gripper position was different from the one used in the final file, however when I changed the name of the positions from “open” to “gripper_open” and “close” to “gripper_close” as it is on my moveit config the program did not execute. So If that was not the issue I am not sure what It could have been as on the previous exercises the gripper opened and closed just fine as expected.

The same issue happened now when completing the pick_place exercise in Unit 4. Both times I have used the provided code, made the corresponding .py lauch file and the corresponding CMake lists adjustment. The arm completes all the trajectory but when it lowers to pick up the object the gripper does not close. Could this be related to removing grasping_msgs from the CMake lists?

Hello @tumoney84 ,

I just tested your approach&retreat program doing what you mentioned, and it worked correctly (it opened & closed the gripper). All I did was to change the named poses as you say in your post. From this:

move_group_gripper.setNamedTarget("open");
move_group_gripper.setNamedTarget("close");

to this:

move_group_gripper.setNamedTarget("gripper_open");
move_group_gripper.setNamedTarget("gripper_close");

Everything worked OK.

Hi, I have replaced that code, this time it worked (maybe before when I tried independentely I made some mistake somewhere not loading the package of moveit2 configs before executing it or at least thats what I think). The gripper closes fine and opens but now the problem is that after approaching the object, the arm instead of picking the object up it seems to colide with the object and make it fly away(it feels like the object is very light and at the slightest contact with the arm it moves, falls or flies away). This is the result from when I executed approach and retreat:


Cpp code for approach and retreat:

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

#include <moveit_msgs/msg/display_robot_state.hpp>
#include <moveit_msgs/msg/display_trajectory.hpp>

static const rclcpp::Logger LOGGER = rclcpp::get_logger(“move_group_demo”);

int main(int argc, char **argv) {
rclcpp::init(argc, argv);
rclcpp::NodeOptions node_options;
node_options.automatically_declare_parameters_from_overrides(true);
auto move_group_node =
rclcpp::Node::make_shared(“move_group_interface_tutorial”, node_options);

rclcpp::executors::SingleThreadedExecutor executor;
executor.add_node(move_group_node);
std::thread(&executor { executor.spin(); }).detach();

static const std::string PLANNING_GROUP_ARM = “ur_manipulator”;
static const std::string PLANNING_GROUP_GRIPPER = “gripper”;

moveit::planning_interface::MoveGroupInterface move_group_arm(
move_group_node, PLANNING_GROUP_ARM);
moveit::planning_interface::MoveGroupInterface move_group_gripper(
move_group_node, PLANNING_GROUP_GRIPPER);

const moveit::core::JointModelGroup *joint_model_group_arm =
move_group_arm.getCurrentState()->getJointModelGroup(PLANNING_GROUP_ARM);
const moveit::core::JointModelGroup *joint_model_group_gripper =
move_group_gripper.getCurrentState()->getJointModelGroup(
PLANNING_GROUP_GRIPPER);

// Get Current State
moveit::core::RobotStatePtr current_state_arm =
move_group_arm.getCurrentState(10);
moveit::core::RobotStatePtr current_state_gripper =
move_group_gripper.getCurrentState(10);

std::vector joint_group_positions_arm;
std::vector joint_group_positions_gripper;
current_state_arm->copyJointGroupPositions(joint_model_group_arm,
joint_group_positions_arm);
current_state_gripper->copyJointGroupPositions(joint_model_group_gripper,
joint_group_positions_gripper);

// Go Home
move_group_arm.setStartStateToCurrentState();
move_group_gripper.setStartStateToCurrentState();
RCLCPP_INFO(LOGGER, “Going Home”);

// joint_group_positions_arm[0] = 0.00; // Shoulder Pan
joint_group_positions_arm[1] = -2.50; // Shoulder Lift
joint_group_positions_arm[2] = 1.50; // Elbow
joint_group_positions_arm[3] = -1.50; // Wrist 1
joint_group_positions_arm[4] = -1.55; // Wrist 2
// joint_group_positions_arm[5] = 0.00; // Wrist 3

move_group_arm.setJointValueTarget(joint_group_positions_arm);

moveit::planning_interface::MoveGroupInterface::Plan my_plan_arm;
bool success_arm = (move_group_arm.plan(my_plan_arm) ==
moveit::core::MoveItErrorCode::SUCCESS);

move_group_arm.execute(my_plan_arm);

// Pregrasp

RCLCPP_INFO(LOGGER, “Pregrasp Position”);
current_state_arm = move_group_arm.getCurrentState(10);
current_state_gripper = move_group_gripper.getCurrentState(10);
current_state_arm->copyJointGroupPositions(joint_model_group_arm,
joint_group_positions_arm);
current_state_gripper->copyJointGroupPositions(joint_model_group_gripper,
joint_group_positions_gripper);

geometry_msgs::msg::Pose target_pose1;
target_pose1.orientation.x = -1.0;
target_pose1.orientation.y = 0.00;
target_pose1.orientation.z = 0.00;
target_pose1.orientation.w = 0.00;
target_pose1.position.x = 0.343;
target_pose1.position.y = 0.132;
target_pose1.position.z = 0.264;
move_group_arm.setPoseTarget(target_pose1);

success_arm = (move_group_arm.plan(my_plan_arm) ==
moveit::core::MoveItErrorCode::SUCCESS);

// Execute
move_group_arm.execute(my_plan_arm);

// Open Gripper

RCLCPP_INFO(LOGGER, “Open Gripper!”);

move_group_gripper.setNamedTarget(“gripper_open”);

moveit::planning_interface::MoveGroupInterface::Plan my_plan_gripper;
bool success_gripper = (move_group_gripper.plan(my_plan_gripper) ==
moveit::core::MoveItErrorCode::SUCCESS);

// Execute
move_group_gripper.execute(my_plan_gripper);

// Approach

current_state_arm = move_group_arm.getCurrentState(10);
current_state_gripper = move_group_gripper.getCurrentState(10);
current_state_arm->copyJointGroupPositions(joint_model_group_arm,
joint_group_positions_arm);
current_state_gripper->copyJointGroupPositions(joint_model_group_gripper,
joint_group_positions_gripper);
RCLCPP_INFO(LOGGER, “Approach to object”);

float delta = 0.04;
target_pose1.orientation.x = -1.0;
target_pose1.orientation.y = 0.00;
target_pose1.orientation.z = 0.00;
target_pose1.orientation.w = 0.00;
target_pose1.position.x = 0.343;
target_pose1.position.y = 0.132;
target_pose1.position.z = target_pose1.position.z - delta;
move_group_arm.setPoseTarget(target_pose1);

success_arm = (move_group_arm.plan(my_plan_arm) ==
moveit::core::MoveItErrorCode::SUCCESS);

// Execute
move_group_arm.execute(my_plan_arm);

// Close Gripper

RCLCPP_INFO(LOGGER, “Close Gripper!”);

move_group_gripper.setNamedTarget(“gripper_close”);

success_gripper = (move_group_gripper.plan(my_plan_gripper) ==
moveit::core::MoveItErrorCode::SUCCESS);

// Execute
move_group_gripper.execute(my_plan_gripper);

// Retreat

current_state_arm = move_group_arm.getCurrentState(10);
current_state_gripper = move_group_gripper.getCurrentState(10);
current_state_arm->copyJointGroupPositions(joint_model_group_arm,
joint_group_positions_arm);
current_state_gripper->copyJointGroupPositions(joint_model_group_gripper,
joint_group_positions_gripper);

target_pose1.orientation.x = -1.0;
target_pose1.orientation.y = 0.00;
target_pose1.orientation.z = 0.00;
target_pose1.orientation.w = 0.00;
target_pose1.position.x = 0.343;
target_pose1.position.y = 0.132;
target_pose1.position.z = target_pose1.position.z + delta;
move_group_arm.setPoseTarget(target_pose1);

success_arm = (move_group_arm.plan(my_plan_arm) ==
moveit::core::MoveItErrorCode::SUCCESS);

// Execute
move_group_arm.execute(my_plan_arm);

// Open Gripper

RCLCPP_INFO(LOGGER, “Open Gripper!”);

move_group_gripper.setNamedTarget(“gripper_open”);

success_gripper = (move_group_gripper.plan(my_plan_gripper) ==
moveit::core::MoveItErrorCode::SUCCESS);

// Execute
move_group_gripper.execute(my_plan_gripper);

rclcpp::shutdown();
return 0;
}

This is the result of when I executed pick and place:


Cpp code for pick and place:

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

#include <moveit_msgs/msg/display_robot_state.hpp>
#include <moveit_msgs/msg/display_trajectory.hpp>

static const rclcpp::Logger LOGGER = rclcpp::get_logger(“move_group_demo”);

int main(int argc, char **argv) {
rclcpp::init(argc, argv);
rclcpp::NodeOptions node_options;
node_options.automatically_declare_parameters_from_overrides(true);
auto move_group_node =
rclcpp::Node::make_shared(“move_group_interface_tutorial”, node_options);

rclcpp::executors::SingleThreadedExecutor executor;
executor.add_node(move_group_node);
std::thread(&executor { executor.spin(); }).detach();

static const std::string PLANNING_GROUP_ARM = “ur_manipulator”;
static const std::string PLANNING_GROUP_GRIPPER = “gripper”;

moveit::planning_interface::MoveGroupInterface move_group_arm(
move_group_node, PLANNING_GROUP_ARM);
moveit::planning_interface::MoveGroupInterface move_group_gripper(
move_group_node, PLANNING_GROUP_GRIPPER);

const moveit::core::JointModelGroup *joint_model_group_arm =
move_group_arm.getCurrentState()->getJointModelGroup(PLANNING_GROUP_ARM);
const moveit::core::JointModelGroup *joint_model_group_gripper =
move_group_gripper.getCurrentState()->getJointModelGroup(
PLANNING_GROUP_GRIPPER);

// Get Current State
moveit::core::RobotStatePtr current_state_arm =
move_group_arm.getCurrentState(10);
moveit::core::RobotStatePtr current_state_gripper =
move_group_gripper.getCurrentState(10);

std::vector joint_group_positions_arm;
std::vector joint_group_positions_gripper;
current_state_arm->copyJointGroupPositions(joint_model_group_arm,
joint_group_positions_arm);
current_state_gripper->copyJointGroupPositions(joint_model_group_gripper,
joint_group_positions_gripper);

move_group_arm.setStartStateToCurrentState();
move_group_gripper.setStartStateToCurrentState();

// Go Home
RCLCPP_INFO(LOGGER, “Going Home”);

// joint_group_positions_arm[0] = 0.00; // Shoulder Pan
joint_group_positions_arm[1] = -2.50; // Shoulder Lift
joint_group_positions_arm[2] = 1.50; // Elbow
joint_group_positions_arm[3] = -1.50; // Wrist 1
joint_group_positions_arm[4] = -1.55; // Wrist 2
// joint_group_positions_arm[5] = 0.00; // Wrist 3

move_group_arm.setJointValueTarget(joint_group_positions_arm);

moveit::planning_interface::MoveGroupInterface::Plan my_plan_arm;
bool success_arm = (move_group_arm.plan(my_plan_arm) ==
moveit::core::MoveItErrorCode::SUCCESS);

move_group_arm.execute(my_plan_arm);

// Pregrasp
RCLCPP_INFO(LOGGER, “Pregrasp Position”);

geometry_msgs::msg::Pose target_pose1;
target_pose1.orientation.x = -1.0;
target_pose1.orientation.y = 0.00;
target_pose1.orientation.z = 0.00;
target_pose1.orientation.w = 0.00;
target_pose1.position.x = 0.343;
target_pose1.position.y = 0.132;
target_pose1.position.z = 0.264;
move_group_arm.setPoseTarget(target_pose1);

success_arm = (move_group_arm.plan(my_plan_arm) ==
moveit::core::MoveItErrorCode::SUCCESS);

move_group_arm.execute(my_plan_arm);

// Open Gripper

RCLCPP_INFO(LOGGER, “Open Gripper!”);

move_group_gripper.setNamedTarget(“gripper_open”);

moveit::planning_interface::MoveGroupInterface::Plan my_plan_gripper;
bool success_gripper = (move_group_gripper.plan(my_plan_gripper) ==
moveit::core::MoveItErrorCode::SUCCESS);

move_group_gripper.execute(my_plan_gripper);

// Approach
RCLCPP_INFO(LOGGER, “Approach to object!”);

std::vector<geometry_msgs::msg::Pose> approach_waypoints;
target_pose1.position.z -= 0.03;
approach_waypoints.push_back(target_pose1);

target_pose1.position.z -= 0.03;
approach_waypoints.push_back(target_pose1);

moveit_msgs::msg::RobotTrajectory trajectory_approach;
const double jump_threshold = 0.0;
const double eef_step = 0.01;

double fraction = move_group_arm.computeCartesianPath(
approach_waypoints, eef_step, jump_threshold, trajectory_approach);

move_group_arm.execute(trajectory_approach);

// Close Gripper

RCLCPP_INFO(LOGGER, “Close Gripper!”);

move_group_gripper.setNamedTarget(“gripper_close”);

success_gripper = (move_group_gripper.plan(my_plan_gripper) ==
moveit::core::MoveItErrorCode::SUCCESS);

move_group_gripper.execute(my_plan_gripper);

// Retreat

RCLCPP_INFO(LOGGER, “Retreat from object!”);

std::vector<geometry_msgs::msg::Pose> retreat_waypoints;
target_pose1.position.z += 0.03;
retreat_waypoints.push_back(target_pose1);

target_pose1.position.z += 0.03;
retreat_waypoints.push_back(target_pose1);

moveit_msgs::msg::RobotTrajectory trajectory_retreat;

fraction = move_group_arm.computeCartesianPath(
retreat_waypoints, eef_step, jump_threshold, trajectory_retreat);

move_group_arm.execute(trajectory_retreat);

// Place

RCLCPP_INFO(LOGGER, “Rotating Arm”);

current_state_arm = move_group_arm.getCurrentState(10);
current_state_arm->copyJointGroupPositions(joint_model_group_arm,
joint_group_positions_arm);

joint_group_positions_arm[0] = 1.57; // Shoulder Pan

move_group_arm.setJointValueTarget(joint_group_positions_arm);

success_arm = (move_group_arm.plan(my_plan_arm) ==
moveit::core::MoveItErrorCode::SUCCESS);

move_group_arm.execute(my_plan_arm);

// Open Gripper

RCLCPP_INFO(LOGGER, “Release Object!”);

move_group_gripper.setNamedTarget(“gripper_open”);

success_gripper = (move_group_gripper.plan(my_plan_gripper) ==
moveit::core::MoveItErrorCode::SUCCESS);

move_group_gripper.execute(my_plan_gripper);

rclcpp::shutdown();
return 0;
}

If you would like to have a look at the animaton please let me know if there is a way to upload a small clip of the arm executing the trajectory.
Thanks again for your help. I am learning a lot with these tutorials.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.