Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Get model position from objects ( Position is not exact)

Hello guys,

i never get an answer to my problem so i think i will describe the problem a bit better this time.

So i want to get the position of the Objects in my world. It worked good so far the problem is that the x value is 0.5 above or below the correct position. System is Linux 16.04. Ros Kinetic. Gezabo 7.0

Here is my code:

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('bookshelf_0', 'link'),
        'c': Block('cabinet', 'link'),
        'd': Block('mars_rover', 'link'),
        'e': Block('Dumpster_0', 'link'),
    'f': Block('unit_box_0', 'link'),
        'g': Block('fire_hydrant', 'link'),
    'h': Block('first_2015_trash_can', 'link'),

    def update_gazebo_modelPoints(self):
            i = 0
            plist = []
            model_coordinates = rospy.ServiceProxy('/gazebo/get_model_state',GetModelState)
            for block in self._blockListDict.itervalues():
                blockName = str(block._name)
                resp_coordinates = model_coordinates(blockName,block._relative_entity_name)
            return plist
        except rospy.ServiceException as e:
            rospy.loginfo("Get Model State service call failed:  {0}".format(e))

So my first object stands on Point(5,5,0)

Here is the screenshot from simulation: image description

If i run the code i got this: image description

Its the same with all objects .

Hope u can help me !