moveit2_tutorials icon indicating copy to clipboard operation
moveit2_tutorials copied to clipboard

simple move

Open lu4k87 opened this issue 9 months ago • 0 comments

hi, how is it possible to implement a simple cartesian motion with movieit?

I've tried pretty much everything now and can't get any further... (i probably have a comprehension problem).

i want to move the end effector with the moveit interface to a certain position in 3d space. it should read the current position of the end effector and then move to a position (in relation to the base_link).

how do I best implement this with which method (moveit interface, planning interface? )? -> setPoseTarget? -> setPose? -> setPositionTarget?

i get functions from the interface to run and even if i specify the values for pose:x,y,z, the end effector does not move as expected. it rotates instead of moving to the position.

Please help :)

iam using the script from the tutorial - panda_arm

#include <memory>

#include <rclcpp/rclcpp.hpp>
#include <moveit/move_group_interface/move_group_interface.hpp>

int main(int argc, char* argv[])
{
  // Initialize ROS and create the Node
  rclcpp::init(argc, argv);
  auto const node = std::make_shared<rclcpp::Node>(
      "hello_moveit", rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true));

  // Create a ROS logger
  auto const logger = rclcpp::get_logger("hello_moveit");

  // Create the MoveIt MoveGroup Interface
  using moveit::planning_interface::MoveGroupInterface;
  auto move_group_interface = MoveGroupInterface(node, "manipulator");

  // Set a target Pose
  auto const target_pose = [] {
    geometry_msgs::msg::Pose msg;
    msg.orientation.w = 1.0;
    msg.position.x = 0.28;
    msg.position.y = -0.2;
    msg.position.z = 0.5;
    return msg;
  }();
  move_group_interface.setPoseTarget(target_pose);

  // Create a plan to that target pose
  auto const [success, plan] = [&move_group_interface] {
    moveit::planning_interface::MoveGroupInterface::Plan msg;
    auto const ok = static_cast<bool>(move_group_interface.plan(msg));
    return std::make_pair(ok, msg);
  }();

  // Execute the plan
  if (success)
  {
    move_group_interface.execute(plan);
  }
  else
  {
    RCLCPP_ERROR(logger, "Planning failed!");
  }

  // Shutdown ROS
  rclcpp::shutdown();
  return 0;
}

lu4k87 avatar Mar 03 '25 08:03 lu4k87