Closed Jailander closed 8 years ago
mousePressEvent coordinates implemented in pixels, will attempt to get metric pos() soon as i manage to get my head round the conversion to metrics
for metric coordinates you have these fields: http://wiki.ros.org/map_server#YAML_format
the definition of origin
is as follows:
origin : The 2-D pose of the lower-left pixel in the map, as (x, y, yaw), with yaw as counterclockwise rotation (yaw=0 means no rotation). Many parts of the system currently ignore yaw.
this means that in a map with 200 pixels of with x 100 pixels of height the pixel coordinate (0,200) (let's call these Xpo, Ypo) would correspond to the x,y coordinates of origin (lets not care about the yaw in the editor for now, no map that we create ignore the yaw) namely [Xo,Yo]. So if you have a resolution of 0.1 all you need to do is find the difference in pixel coordinates between the coordinates of origin and the coordinates of the point evaluated Xpe, Ype to find its metric coordinates [Xe, Ye], so you would have something like this:
Xe= [(Xpe-Xpo)/res] +Xo
Ye= [(Ype-Ypo)/res] +Yo
I think this should do it test please
@Jailander you are offering a good deal of help here!
I think @Laxnyama has to struggle with more important things now like being able to keep track of the nodes he is adding to the scene and modifying their properties. This is just a minor problem right now.
@marc-hanheide I sure could do with any help I can get, I think I've bitten more than I can chew but I relish the challenge, @Jailander I really appreciate your help, sort of makes sense now, I have managed to get the node position but in pixels so will apply your formula to see the results and will get back to you. Much appreciated.
I have managed to get the metric coordinates for the nodes, but this is only when the node is placed in the scene, however when node is selected or moved, the coordinates do not update but I'm working on it to see if i can keep track of position.
Done
we need to know the coordinates of the mouse click event in the map, preferably metric coordinates but you can try pixel coordinates first