marcbone / liborl

Cartesian motion generation for Franka Emika Panda robots
European Union Public License 1.2
40 stars 10 forks source link

What is the best way for make orientation during motion? #1

Closed MMSSalem closed 1 year ago

MMSSalem commented 1 year ago

Hi,

I want to ask how can I control the orientation of the Pose/Gripper during RelativeMotion?

Best Regards, Mahmoud

marcbone commented 1 year ago

could not test it but this should work:

    Robot robot("robot-ip");
    Orientation goal_orientation;
    goal_orientation.set_RPY(-3 * M_PI / 8, 0, 0);

    // Option 1:
    // simple orientation generator that reaches the desired orientation at the
    // end of the trajectory.
    OrientationGenerator simple_orientation_generator =
        generate_orientation_interpolation_orientation_generator(
            goal_orientation.quaternion);

    // Option 2:
    // here you can define the orientation at every step yourself
    OrientationGenerator custom_orientation_generator =
        [=](const PoseGeneratorInput &input) -> Eigen::Quaterniond {
      return input.initial_pose.quaternion().slerp(input.progress,
                                                   goal_orientation.quaternion);
    };

    auto pose_generator = PoseGenerators::RelativeMotion(
        Position(0.2, 0, 0.), Frame::RobotBase, simple_orientation_generator);
    apply_speed_profile(pose_generator);
    robot.move_cartesian(pose_generator, 5);
MMSSalem commented 1 year ago

Dear Marco,

Thank you very much for your promote response. I tested it on a real robot, and it worked correctly. Thanks a lot.

Mahmoud