moveit / moveit2

:robot: MoveIt for ROS 2
https://moveit.ai/
BSD 3-Clause "New" or "Revised" License
1.03k stars 508 forks source link

getCurrentPose() does not verify TF2 pose information #2903

Open roboticshard opened 2 months ago

roboticshard commented 2 months ago

I am working on so simple Moveit2 tutorial. I am trying to just get robot position and orientation information by using Moveit2 Script .

I am getting robot pose information by using ( getCurrentPose() method). When I tried to verify the getCurrentPose information, I found that it was inconsistent with TF information.

Your environment

Steps to reproduce

#include <moveit/move_group_interface/move_group_interface.h>

#include <geometry_msgs/msg/pose.hpp>
#include <rclcpp/rclcpp.hpp>

int main(int argc, char* argv[]) {
// Initialize ROS
rclcpp::init(argc, argv);

// Declare Node
std::shared_ptrrclcpp::Node node =
std::make_sharedrclcpp::Node("get_current_pose",
rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(
true));

// We spin up a SingleThreadedExecutor for the current state monitor to get
// information about the robot's state.
rclcpp::executors::SingleThreadedExecutor executor;
executor.add_node(node);
std::thread spinner = std::thread(&executor { executor.spin(); });

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

// print current pose
geometry_msgs::msg::Pose current_pose =
move_group_interface.getCurrentPose().pose;

// Print the current pose of the end effector
RCLCPP_INFO(node->get_logger(), "Current pose: X:%f Y:%f Z:%f x:%f y:%f z:%f w:%f",
current_pose.position.x,
current_pose.position.y,
current_pose.position.z,
current_pose.orientation.x,
current_pose.orientation.y,
current_pose.orientation.z,
current_pose.orientation.w);

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

github1 github2 github3

Expected behaviour

TF Gui Output tool0, wrist_3_link Position: X: 0.382871 Y:0.351937 Z:0.808952 Orientation X:-0.70715 Y:0.0057097 Z: 0.00065606 W: 0.70709

Actual behaviour

Moveit2 Output Current pose: pos.X:0.193414 pos.Y:0.286017 pos.Z:0.546773 ori.x:-0.707120 ori.y:0.000571 ori.z:0.000656 ori.w:0.707093

Why they are different from each other between Moveit2 Console and TF in Rviz GUI ?

Backtrace or Console output

Use gist.github.com to copy-paste the console output or segfault backtrace using gdb.

rhaschke commented 2 months ago

You didn't specify a concrete link for getCurrentPose(). Probably MoveIt reports the pose of a different link than the one you looked up in rviz' TF. Another reason could be a different base transform. MoveIt reports poses relative to the planning frame, which is usually the robot's root link. If you introduced a virtual joint or the robot is otherwise offset w.r.t. (0,0,0), a different pose will be reported. In that case, change rviz' fixed frame to the same frame too.

github-actions[bot] commented 1 week ago

This issue is being labeled as stale because it has been open 45 days with no activity. It will be automatically closed after another 45 days without follow-ups.