# Inverse Kinematics for base + end effector pose

**URL:** <https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177>\
**Category:** Discuss\
**Created:** [May 31, 2021, 12:40am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177 "2021-05-31T00:40:22Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zackory](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/zackory/32/114_2.png) [@Zackory](https://forum.hello-robot.com/u/Zackory)\
**Post date:** [May 31, 2021, 12:40am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/1 "2021-05-31T00:40:22Z")

</div>

Suppose we have a fiducial marker (AR tag) in the world and an end effector pose defined as some offset with respect to that marker.

Is there a currently implemented method to compute (and ideally move) both the Stretch base and arm actuators to match the given end effector pose? Essentially, inverse kinematics that optimizes for the robot base pose, lift, arm reach, and wrist angles?

Is there a related method for when the target end effector pose is defined with respect to the robot’s base pose (determined via the depth camera), rather than a fiducial marker?

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [May 31, 2021, 6:13pm UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/2 "2021-05-31T18:13:29Z")

</div>

Hi @Zackory, welcome to the forum! For the base + arm problem, there are a number of planning and navigation packages that can help. Here are some options:

- Stretch FUNMAP (Fast Unified Navigation, Mapping, and Planning) is designed with Stretch’s kinematic configuration in mind and generates sane and predictable trajectories. It can plan and move Stretch to reach the Stretch Gripper to a [given world point](https://github.com/hello-robot/stretch_ros/blob/ece0c2f276d662a2614c5ddf6e23b079c3372242/stretch_funmap/nodes/funmap#L653-L703) (does not take orientation right now). The [TF2 library](http://wiki.ros.org/tf2/Tutorials/Writing%20a%20tf2%20listener%20%28Python%29) can help you transform goals from fiducial frame to a map frame in ROS. The “Publish Point” tool in Rviz is a quick way to try it out, see [instructions here](https://github.com/hello-robot/stretch_ros/blob/master/stretch_funmap/README.md). For your reference, the [hand over object demo](https://github.com/hello-robot/stretch_ros/blob/master/stretch_demos/nodes/handover_object) defines a gripper point with respect to a detected mouth and uses FUNMAP to achieve it.
- In ROS land, the de facto standard is MoveIt. It can solve the IK for a target gripper pose, plan in a cluttered environment, and coordinate navigation. Other end-effectors beyond the Stretch Gripper can also be supported. We’ve partnered with PickNik Robotics (@DavidLu leads the project) to bring first class support for Stretch RE1 to MoveIt2. It’s good to have this on your radar, but the project is still early [in-development](https://github.com/PickNikRobotics/stretch_ros/blob/galactic_devel/GalacticDemo.md), so I don’t recommend delving into it yet. Updates will be posted here on the forum.
- The [ROS Navigation Stack](https://github.com/hello-robot/stretch_ros/blob/master/stretch_navigation/README.md) is commonly used to get Stretch’s base close enough, and then use another method to achieve the target gripper pose. Once Stretch is in a known position, it can be easy to compute base translation, lift, arm, and wrist joints thanks to Stretch’s cartesian configuration. This is how the [grasp object demo](https://github.com/hello-robot/stretch_ros/blob/master/stretch_demos/nodes/grasp_object) works.
- The previous three options use ROS packages, however, there are promising Python options as well. [IKPy](https://github.com/Phylliade/ikpy) is one option that could be used in conjunction with [Stretch Body](https://github.com/hello-robot/stretch_body/) to achieve your goal.
- Finally, depending on what you had in mind, visual servoing may be a valid option. If interested in this avenue, I can provide more information.

These options should also apply to the problem of achieving target gripper poses that are with respect to the base frame. Let me know if you’d like to know more about any of these options or had another approach in mind.

---

<div class="post-metadata">

**Author:** ![Zackory](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/zackory/32/114_2.png) [@Zackory](https://forum.hello-robot.com/u/Zackory)\
**Post date:** [March 1, 2023, 5:59pm UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/3 "2023-03-01T17:59:15Z")

</div>

Hi Binit,

Thanks for the responses above. I wanted to follow up on this if there has been any substantial progress in this path?

Separate question: Is there a tutorial for doing inverse kinematics on the robot, if we assume the base remains fixed?

---

<div class="post-metadata">

**Author:** ![Boyu\_Chen](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/boyu_chen/32/365_2.png) [@Boyu\_Chen](https://forum.hello-robot.com/u/Boyu_Chen)\
**Post date:** [March 2, 2023, 9:16am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/4 "2023-03-02T09:16:11Z")

</div>

Hi Zackory,

I also started to work on trajectory planning of manipulators recently. I have a question about a MATLAB command.

**[configSol,solInfo] = ik(endeffector,pose,weights,initialguess)**

It finds a joint configuration that achieves the specified end-effector pose.

My question is does the end-effector pose mean that the homogeneous matrix from the base to the end-effector?

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [March 7, 2023, 12:14am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/5 "2023-03-07T00:14:26Z")

</div>

Hi @Zackory, since my original response, there’s been a lot of development on MoveIt2 and it ships on all robots now, so I can wholeheartedly recommend using it. The getting started [tutorials are here](https://docs.hello-robot.com/0.2/stretch-tutorials/ros2/moveit_basics/).

I don’t think we have a tutorial for IK with a fixed base. Let me know if this is of interest and I can create one.

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [March 7, 2023, 12:17am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/6 "2023-03-07T00:17:52Z")

</div>

Hi @Boyu_Chen, welcome to the forum! I don’t have much experience with Matlab, but I can try to answer your question. Are you working with a Stretch?

---

<div class="post-metadata">

**Author:** ![Zackory](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/zackory/32/114_2.png) [@Zackory](https://forum.hello-robot.com/u/Zackory)\
**Post date:** [March 7, 2023, 1:16am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/7 "2023-03-07T01:16:17Z")

</div>

Hey Binit,

A quick tutorial on IK with a fixed base would be great! Would help my students too.

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [March 7, 2023, 2:52am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/8 "2023-03-07T02:52:48Z")

</div>

Great, I’ll post one here shortly

---

<div class="post-metadata">

**Author:** ![Zackory](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/zackory/32/114_2.png) [@Zackory](https://forum.hello-robot.com/u/Zackory)\
**Post date:** [March 17, 2023, 6:54pm UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/9 "2023-03-17T18:54:17Z")

</div>

@bshah any progress on this tutorial?

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [March 19, 2023, 10:11am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/10 "2023-03-19T10:11:20Z")

</div>

Good timing, it is available @Zackory! See the announcement post below. I’m also hosting a workshop to go through the Jupyter notebook and answer questions. Would be great to see your students there.

> [@Inverse Kinematics Tutorial & Workshop Recording](https://forum.hello-robot.com/t/inverse-kinematics-tutorial-mar-29-workshop/639):
>
> [[Screenshot from 2023-03-19 02-23-01]](https://github.com/hello-robot/stretch_tutorials/blob/master/stretch_body/jupyter/inverse_kinematics.ipynb) New tutorial for inverse kinematics on Stretch has been [released on Github](https://github.com/hello-robot/stretch_tutorials/blob/master/stretch_body/jupyter/inverse_kinematics.ipynb)! You can preview the tutorial on Github, and instructions to run it are within the notebook itself. Additionally, I’m hosting a workshop in 2 weeks to go through the tutorial and answer any questions. Here are the event details: Inverse Kinematics Workshop Date: March 29, 2023 at 11am PT Meeting Link: [meet.google.com/yhm-ecbh-uof](http://meet.google.com/yhm-ecbh-uof) Agenda: [https://docs.google.com/document/d/1mtFlc…](https://docs.google.com/document/d/1mtFlcYvDELelepcE6QZ5oN85sC8zxgTvQlybsxGQa6g/edit?usp=sharing)

---

<div class="post-metadata">

**Author:** ![Shashank\_Shiva](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/shashank_shiva/32/417_2.png) [@Shashank\_Shiva](https://forum.hello-robot.com/u/Shashank_Shiva)\
**Post date:** [April 7, 2023, 12:56am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/11 "2023-04-07T00:56:13Z")

</div>

@bshah I came across this thread. I am working on the stretch for a project. I am keeping the base fixed and moving the gripper. Is it possible to derive the IK for the joint states by giving the cartesian points of the end effector in the world frame?

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [April 7, 2023, 1:33am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/12 "2023-04-07T01:33:28Z")

</div>

Hi @Shashank_Shiva, welcome to the forum. Yes, you can do that! I recommend using an IK library like IKPy instead of deriving it. Check out the [tutorial/workshop](https://forum.hello-robot.com/t/inverse-kinematics-tutorial-workshop-recording/639) to see how this is done. Happy to answer any questions too.

---

<div class="post-metadata">

**Author:** ![Zackory](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/zackory/32/114_2.png) [@Zackory](https://forum.hello-robot.com/u/Zackory)\
**Post date:** [April 7, 2023, 2:44am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/13 "2023-04-07T02:44:24Z")

</div>

Binit, thanks for preparing this tutorial. I went through it in one of the lectures.

Here is the file we ran on the physical robot in class: [rc2023/stretch\_ik.py at main · Zackory/rc2023 · GitHub](https://github.com/Zackory/rc2023/blob/main/stretch_python/stretch_ik.py)

---

<div class="post-metadata">

**Author:** ![bshah](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/bshah/32/55_2.png) [@bshah](https://forum.hello-robot.com/u/bshah)\
**Post date:** [April 7, 2023, 2:57am UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/14 "2023-04-07T02:57:57Z")

</div>

Glad to hear it was useful @Zackory!

---

<div class="post-metadata">

**Author:** ![Shashank\_Shiva](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.hello-robot.com/shashank_shiva/32/417_2.png) [@Shashank\_Shiva](https://forum.hello-robot.com/u/Shashank_Shiva)\
**Post date:** [April 8, 2023, 5:23pm UTC](https://forum.hello-robot.com/t/inverse-kinematics-for-base-end-effector-pose/177/15 "2023-04-08T17:23:32Z")

</div>

Thank you @bshah. I will check it out and get back to you if I have questions. Appreciate the help and timely response.
