Getting link index

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
ShravanTata
Posts: 3
Joined: Wed Jul 24, 2019 5:07 pm

Getting link index

Post by ShravanTata »

Hi All,

After loading an URDF/SDF using loadURDF/SDF method in pybullet, how can I get the index of a link by its name in the URDF/SDF.
I see in the documentation that there is getJointInfo method to do this for joints but nothing for links. Any help is appreciated. Thank you.

Cheers,
Shravan
ShravanTata
Posts: 3
Joined: Wed Jul 24, 2019 5:07 pm

Re: Getting link index

Post by ShravanTata »

Found an important information that helped solve this issue.
In bullet linkIndex == jointIndex

Using the above, I currently have the following solution below

Code: Select all

_link_name_to_index = {p.getBodyInfo(model_id)[0].decode('UTF-8'):-1,}
        
for _id in range(p.getNumJoints(model_id)):
	_name = p.getJointInfo(model_id, _id)[12].decode('UTF-8')
	_link_name_to_index[_name] = _id
Post Reply