Changes UserData to use global identifiers and makes linkIndex optional.
This removes the need to specify the body id/link index when retrieving a user data entry. Additionally, user data can now optionally be set to visual shapes as well. The following public pybullet APIs have changed (backwards incompatible) addUserData and getUserDataId Makes linkIndex parameter optional (default value is -1) Adds optional visualShapeIndex parameter (default value is -1) getUserData and removeUserData Removes required parameters bodyUniqueId and linkIndex getNumUserData Removes required bodyUniqueId parameter getUserDataInfo Removes required linkIndex parameter Changes returned tuple from (userDataId, key) to (userDataId, key, bodyUniqueId, linkIndex, visualShapeIndex)
This commit is contained in:
@@ -21,16 +21,16 @@ plane_id = client.loadURDF(PLANE_PATH)
|
||||
print ("Plane ID: %s" % plane_id)
|
||||
|
||||
print ("Adding user data to plane")
|
||||
MyKey1 = client.addUserData(plane_id, 0, "MyKey1", "MyValue1")
|
||||
MyKey2 = client.addUserData(plane_id, 0, "MyKey2", "MyValue2")
|
||||
MyKey3 = client.addUserData(plane_id, 0, "MyKey3", "MyValue3")
|
||||
MyKey4 = client.addUserData(plane_id, 0, "MyKey4", "MyValue4")
|
||||
MyKey1 = client.addUserData(plane_id, "MyKey1", "MyValue1")
|
||||
MyKey2 = client.addUserData(plane_id, "MyKey2", "MyValue2")
|
||||
MyKey3 = client.addUserData(plane_id, "MyKey3", "MyValue3")
|
||||
MyKey4 = client.addUserData(plane_id, "MyKey4", "MyValue4")
|
||||
|
||||
print ("Retrieving cached user data")
|
||||
print (client.getUserData(plane_id, 0, MyKey1))
|
||||
print (client.getUserData(plane_id, 0, MyKey2))
|
||||
print (client.getUserData(plane_id, 0, MyKey3))
|
||||
print (client.getUserData(plane_id, 0, MyKey4))
|
||||
print (client.getUserData(MyKey1))
|
||||
print (client.getUserData(MyKey2))
|
||||
print (client.getUserData(MyKey3))
|
||||
print (client.getUserData(MyKey4))
|
||||
|
||||
print ("Disconnecting")
|
||||
del client
|
||||
@@ -39,18 +39,18 @@ print ("Reconnecting")
|
||||
client = bullet_client.BulletClient(connection_mode=CONNECTION_METHOD)
|
||||
|
||||
print ("Retrieving synced user data")
|
||||
print (client.getUserData(plane_id, 0, MyKey1))
|
||||
print (client.getUserData(plane_id, 0, MyKey2))
|
||||
print (client.getUserData(plane_id, 0, MyKey3))
|
||||
print (client.getUserData(plane_id, 0, MyKey4))
|
||||
print (client.getUserData(MyKey1))
|
||||
print (client.getUserData(MyKey2))
|
||||
print (client.getUserData(MyKey3))
|
||||
print (client.getUserData(MyKey4))
|
||||
|
||||
print ("Number of user data entries: %s" % client.getNumUserData(plane_id, 0))
|
||||
print ("Number of user data entries: %s" % client.getNumUserData(plane_id))
|
||||
|
||||
print ("Overriding user data")
|
||||
client.addUserData(plane_id, 0, "MyKey1", "MyNewValue")
|
||||
client.addUserData(plane_id, "MyKey1", "MyNewValue")
|
||||
|
||||
print ("Cached overridden data")
|
||||
print (client.getUserData(plane_id, 0, MyKey1))
|
||||
print (client.getUserData(MyKey1))
|
||||
|
||||
|
||||
print ("Disconnecting")
|
||||
@@ -61,50 +61,50 @@ client = bullet_client.BulletClient(connection_mode=CONNECTION_METHOD)
|
||||
|
||||
|
||||
print ("Synced overridden data")
|
||||
print (client.getUserData(plane_id, 0, MyKey1))
|
||||
print (client.getUserData(MyKey1))
|
||||
|
||||
print ("Getting user data ID")
|
||||
print ("Retrieved ID: %s, ID retrieved from addUserData: %s" % (client.getUserDataId(plane_id, 0, "MyKey2"), MyKey2))
|
||||
print ("Retrieved ID: %s, ID retrieved from addUserData: %s" % (client.getUserDataId(plane_id, "MyKey2"), MyKey2))
|
||||
|
||||
print ("Removing user data")
|
||||
client.removeUserData(plane_id, 0, MyKey2)
|
||||
client.removeUserData(MyKey2)
|
||||
|
||||
print ("Retrieving cached removed data")
|
||||
print (client.getUserData(plane_id, 0, MyKey2))
|
||||
print (client.getUserData(MyKey2))
|
||||
|
||||
print ("Syncing")
|
||||
client.syncUserData()
|
||||
|
||||
print ("Retrieving removed removed data")
|
||||
print (client.getUserData(plane_id, 0, MyKey2))
|
||||
print (client.getUserData(MyKey2))
|
||||
|
||||
print ("Iterating over all user data entries and printing results")
|
||||
for i in range(client.getNumUserData(plane_id, 0)):
|
||||
userDataId, key = client.getUserDataInfo(plane_id, 0, i)
|
||||
print ("Info: (%s, %s)" % (userDataId, key))
|
||||
print ("Value: %s" % client.getUserData(plane_id, 0, userDataId))
|
||||
for i in range(client.getNumUserData(plane_id)):
|
||||
userDataId, key, bodyId, linkIndex, visualShapeIndex = client.getUserDataInfo(plane_id, i)
|
||||
print ("Info: (%s, %s, %s, %s, %s)" % (userDataId, key, bodyId, linkIndex, visualShapeIndex))
|
||||
print ("Value: %s" % client.getUserData(userDataId))
|
||||
|
||||
print ("Removing body")
|
||||
client.removeBody(plane_id)
|
||||
|
||||
print ("Retrieving user data")
|
||||
print (client.getUserData(plane_id, 0, MyKey1))
|
||||
print (client.getUserData(plane_id, 0, MyKey3))
|
||||
print (client.getUserData(plane_id, 0, MyKey4))
|
||||
print (client.getUserData(MyKey1))
|
||||
print (client.getUserData(MyKey3))
|
||||
print (client.getUserData(MyKey4))
|
||||
|
||||
print ("Syncing")
|
||||
client.syncUserData()
|
||||
|
||||
print ("Retrieving user data")
|
||||
print (client.getUserData(plane_id, 0, MyKey1))
|
||||
print (client.getUserData(plane_id, 0, MyKey3))
|
||||
print (client.getUserData(plane_id, 0, MyKey4))
|
||||
print (client.getUserData(MyKey1))
|
||||
print (client.getUserData(MyKey3))
|
||||
print (client.getUserData(MyKey4))
|
||||
|
||||
plane_id2 = client.loadURDF(PLANE_PATH)
|
||||
print ("Plane1: %s, plane2: %s" % (plane_id, plane_id2))
|
||||
|
||||
print ("Retrieving user data")
|
||||
print (client.getUserData(plane_id, 0, MyKey1))
|
||||
print (client.getUserData(plane_id, 0, MyKey3))
|
||||
print (client.getUserData(plane_id, 0, MyKey4))
|
||||
print (client.getUserData(MyKey1))
|
||||
print (client.getUserData(MyKey3))
|
||||
print (client.getUserData(MyKey4))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user