Home | Tutorials | Wiki | Issues
Ask Your Question

Get model position from objects ( Position is not exact)

asked 2018-11-01 05:54:58 -0600

Baumboon gravatar image

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 !

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-02 07:59:42 -0600

wentz gravatar image

Just a guess (cause i don't know the sdf files of your models), but it seems that you are asking for the model_states in a specific frame

   `resp_coordinates = model_coordinates(blockName,block._relative_entity_name)`

each model position will be relative to block._relative_entity_name. I assume that the service will just take the 'link' frame of the models. and there might be the static offset.

You should instead call the service like this:

   `resp_coordinates = model_coordinates(blockName,"")`

the empty relative frame will cause that the position is in global "world" or "map" frame.

edit flag offensive delete link more


thank u for ur help. It worked fine !

Baumboon gravatar imageBaumboon ( 2018-11-04 11:22:07 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-11-01 05:54:58 -0600

Seen: 57 times

Last updated: Nov 02