neka-nat / kinpy Goto Github PK
View Code? Open in Web Editor NEWSimple kinematics calculation toolkit for robotics
License: MIT License
Simple kinematics calculation toolkit for robotics
License: MIT License
Hi, I read the code for jacobian. It seems that the jacobian is in body frame. Is this correct?
Hello, I am trying to use your tool with the Shadow Hand but it seems to compute wrong the transforms when I move the joints.
In the initial position where joints are at 0 it seems to work fine:
(I visualized the transforms for each rigid body)
But when I move the joints around it seems to compute the transforms wrong, e.g. when I move the little finger:
(The red circled transforms are the ones computed wrong)
Have you tried it with any dexterous hands before?
My research interest is robustness of RL algorithms to environment parameters. I want to modify currents RL algorithms to make them achieve good performance when they are tested in environments with unfamilar parameters. (For example, an agent is trained in Cartpole environment with 1m pole. I want it achieve good performance in Cartpole environment with 3m pole.)
To achieve this goal, I want to get the relationship between model parameter values and RL algorithm's performance (reward). As a result, I want to get the gradient of reward with respect to the model parameters.
Mujoco simulator has applied in my experiments. But Mujoco simulator is not implemented by pure python. So I cannot get the the gradient of reward with respect to the model parameters. After searching in github, I notice that your code has the function of calculating FK, IK and jacobian, which gives me some hopes. ^_^
So my queation is:
Can kinpy compute the gradient of reward with respect to the model parameters? If so, how should I use it to achieve this goal?
Hey, I'm trying to use your library to do calculations with a URDF file and I can't actually install it due to the PyYAML library failing during "getting requirements to build wheel" step which only seems to occur for PyYAML 5.4.1, and as far as I can tell kinpy somehow forces use of that version when installing it which causes it to fail (other versions of PyYAML install successfully.
I'm not super familiar with wheel files and pip so if there's an obvious solution apologies
I try to use build_chain_from_mjcf function to read 'roboschool/mujoco_assets/hopper.xml'.
But I got error information as follows:
File "/root/aliyun/mymirror/test.py", line 122, in test
chain_kp = kp.build_chain_from_mjcf(open(xml_path).read())
File "/root/anaconda3/envs/distralmirror37/lib/python3.7/site-packages/kinpy/mjcf.py", line 75, in build_chain_from_mjcf
_build_chain_recurse(root_frame, root_body)
File "/root/anaconda3/envs/distralmirror37/lib/python3.7/site-packages/kinpy/mjcf.py", line 42, in _build_chain_recurse
cur_frame, cur_base = add_composite_joint(root_frame, root_body.joint, base)
File "/root/anaconda3/envs/distralmirror37/lib/python3.7/site-packages/kinpy/mjcf.py", line 33, in add_composite_joint
joint=joint_to_joint(joints[0], base))]
File "/root/anaconda3/envs/distralmirror37/lib/python3.7/site-packages/kinpy/mjcf.py", line 27, in joint_to_joint
joint_type=JOINT_TYPE_MAP[joint.type],
KeyError: 'slide'
In "kinpy/mjcf.py", I notice that 'JOINT_TYPE_MAP' is defined as a dictionary {'hinge': 'revolute'} at the beginning of mjcf.py. So 'JOINT_TYPE_MAP' can only receive joint of 'hinge' type.
But in 'roboschool/mujoco_assets/hopper.xml' in following figure, there are some joints of "slide" type.
1652669456(1)
So how to process joint of "slide" type? Do you have any advice? Thanks for your help in advance ^_^ @neka-nat
Currently only three joint types are supported. Is there any plan to support more joints according to the ROS docs? http://wiki.ros.org/urdf/XML/joint#Attributes
Best, Lukas
Hi there,
There seems to be a small issue while using a chain which includes a fixed joint at the very end of the chain. During FK computation for the chain, computing the transform for the last joint raises an index error.
To reproduce the issue, please consider using the following robot.txt.
arm = kp.build_serial_chain_from_urdf(
open("robot.txt").read(),
root_link_name="base_link",
end_link_name="ee_link",
)
fk_solution = arm.forward_kinematics(np.zeros(len(arm.get_joint_parameter_names())))
The issue occurs in the following function, with the cnt
-indexed access on line 129. There is not entry in th
for the last frame (a fixed joint):
Lines 124 to 133 in c4e5af4
Assuming my use of forwards_kinematics is correct, I have tried a small but very inelegant change. It seems to work, but I am concerned about the validity of the result:
if f.joint.joint_type != "fixed":
trans = trans * f.get_transform(th[cnt])
else:
trans = trans * f.get_transform(th[cnt - 1])
Here is a working example using kinpy to move the arm to the correct target positions:
Hello,
Thanks for the tool!
However, I have problems to run the IK function.
I do the following:
from scipy.spatial.transform import Rotation as R
import kinpy as kp
r = R.from_matrix([[-1, 0, 0],
[0, 1, 0],
[0, 0, -1]])
pos = np.array([0.5 , 0., 0.])
target = kp.transform.Transform(rot = r.as_quat(), pos= pos )
ik_sol = kp.ik.inverse_kinematics(chain, pose = target)
where chain points to my urdf , which works since I manage to use the forward_kinematics function of kinpy.
The last line does not work, as I get the error "AttributeError: 'dict' object has no attribute 'matrix' ".
I tried going into the ik.py file and changing tf.matrix() to tf["tool0"].matrix() (where tool0 is the name of my end effector). Then I do not get any error but I get completely wrong solutions, with values more than 10000.
Could you help, please ?
Thanks for the wonderful tool.
Can I use the DH not the urdf? Or are there any py file to convert the DH model to a simple URDF file?
Thanks
I've just installed kinpy with python setup.py build
and python setup.py install
. I can't use the package though, i'm getting the following error:
'''
import kinpy
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/kinpy/init.py", line 1, in
from .urdf import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/kinpy/urdf.py", line 1, in
from .urdf_parser_py.urdf import URDF, Mesh, Cylinder, Box, Sphere
ModuleNotFoundError: No module named 'kinpy.urdf_parser_py'
'''
How can this problem be fixed?
Thanks
Is it possible to lower down scipy requirement from 1.6.0 to 1.5.0 as python 3.6 does not support those latest scipy version? I believe the new features of scipy 1.6.0 do not impair kinpy function.
python version : 3.8.8
I have a conda environment and when i tried pip install
it gives error for trying to uninstall PyYAML
Attempting uninstall: PyYAML
Found existing installation: PyYAML 5.3.1
ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
any reason for this? do i need different version of PyYAML?
Currently there's no support for prismatic joints when computing the Jacobian. The Jacobian code seems to be from pybotics: code link, which also doesn't handle prismatic joints. This is seen by computing the Jacobian on a robot with only prismatic joints (URDF below):
For any joint configuration, the Jacobian returned is the zero matrix, but it should be
[[0., 0., 1.],
[0., -1., 0.],
[1., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]
<robot name="prismatic_robot">
<link name="link1" />
<link name="link2" />
<link name="link3" />
<link name="link4" />
<joint name="joint1" type="prismatic">
<origin xyz="0.0 0.0 1.0"/>
<axis xyz="0 0 1"/>
<limit lower="-0.5" upper="0.5" effort="1" velocity="1"/>
<parent link="link1"/>
<child link="link2"/>
</joint>
<joint name="joint2" type="prismatic">
<origin xyz="0.0 0.0 0.0" rpy="1.57079632679 0 0"/>
<axis xyz="0 0 1"/>
<limit lower="-0.5" upper="0.5" effort="1" velocity="1"/>
<parent link="link2"/>
<child link="link3"/>
</joint>
<joint name="joint3" type="prismatic">
<origin xyz="0.0 0.0 0.0" rpy="0 1.57079632679 0"/>
<axis xyz="0 0 1"/>
<limit lower="-0.5" upper="0.5" effort="1" velocity="1"/>
<parent link="link3"/>
<child link="link4"/>
</joint>
</robot>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.