Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple move #1022

Open
lu4k87 opened this issue Mar 3, 2025 · 0 comments
Open

simple move #1022

lu4k87 opened this issue Mar 3, 2025 · 0 comments

Comments

@lu4k87
Copy link

lu4k87 commented Mar 3, 2025

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant