Ordered List of Models in World
Hello Guys,
i use gazebo 7.0 with Ros kinetic.
First of all i want a ordered List of the models how i add them to the list.
Here is what my code looks like:
class Block:
def __init__(self, name, relative_entity_name):
self._name = name
self._relative_entity_name = relative_entity_name
class Tutorial:
_blockListDict = {
'a': Block('cardboard_box', 'link'),
'b': Block('cabinet', 'link'),
'c': Block('bookshelf_0', 'link'),
'e': Block('jersey_barrier', 'link'),
'd': Block('Dumpster_0', 'link'),
}
My problem actual is that my order when i print information for the objects is:
cardboard, bookshelf_0 , cabinet, jersey barrier, Dumpster_0
What i am expected was cardboard, cabinet, bookshelf_0 , Dumpster_0, Jersey_barrier.
Any ideas what i am doing wrong?
Thats how i iterate the list:
def update_gazebo_models(self):
try:
i = 0
model_coordinates = rospy.ServiceProxy('/gazebo/get_model_state', GetModelState)
vlist = []
for block in self._blockListDict.itervalues():
blockName = str(block._name)
resp_coordinates = model_coordinates(blockName, block._relative_entity_name)
value = resp_coordinates.pose.position.x + resp_coordinates.pose.position.y
vlist.append(round(value,2))
i = i +1
return vlist
except rospy.ServiceException as e:
rospy.loginfo("Get Model State service call failed: {0}".format(e))