gazebosim / gazebosim/gz-rendering
LINE_STRIP and LINE_LIST markers have no width
- Dominant language
- C++
- Stars
- 81
- Forks
- 90
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 10
Description
## Environment
* Gazebo Sim Garden
## Description
I was expecting the LINE_STRIP and LINE_LIST markers to have the same behavior as their [RViz counterparts](http://wiki.ros.org/rviz/DisplayTypes/Marker#Line_Strip_.28LINE_STRIP.3D4.29):
> Line strips/lists also have some special handling for scale: **only scale.x is used** and it controls the width of the line segments."
However, in Gazebo the scale is an actual scale of the point _coordinates_, and the line is always very thin (1 pixel width?).
E.g. a thin line from `{0,0,0}` to `{0,1,0}` is scaled by `scale:{x:1,y:10,z:1}` into an equally thin line from `{0,0,0}` to `{0,10,0}`.
(Note also that the RViz 'scale' has units, e.g. `scale.x == 0.05` implies a line width of 5 cm.)
## Test
- Open an empty world that loads the MarkerManager plugin,
- Run following command with different values for the scale and compare the output:
```
gz service -s /marker --reqtype gz.msgs.Marker --reptype gz.msgs.Empty --req 'action:ADD_MODIFY,ns:"line_ns",id:1,type:LINE_LIST,lifetime:{sec:10,nsec:0},pose:{position:{x:0,y:0,z:0},orientation{x:0,y:0,z:0,w:1}},point:{x:0,y:0,z:0.15},point:{x:0,y:10,z:0.15},point:{x:2,y:10,z:0.15},point:{x:2,y:0,z:0.15},materials:{ambient:{r:1,g:0,b:0,a:1},diffuse:{r:1,g:0,b:0,a:1},specular:{r:1,g:0,b:0,a:1},emissive:{r:1,g:0,b:0,a:1}},materials:{ambient:{r:0,g:0,b:1,a:1},diffuse:{r:0,g:0,b:1,a:1},specular:{r:0,g:0,b:1,a:1},emissive:{r:0,g:0,b:1,a:1}},scale:{x:1,y:1,z:1},visibility:ALL' --timeout 3000
```
## Proposed solution
Implement similar behavior to RViz
Pro:
- Identical to RViz,
- I assume for Ogre2 this would allow for PBR textures to be applied to the line, so you could very easily create lines with blurred edges, or dashed lines, etc. (similar to the fog albedo map for a particle emitter). That is nice!
Con:
- It breaks behavior for somebody who is currently applying a scale to a line marker.
- However here's an idea for a possible backwards-compatible implementation:
- It is very unlikely that someone currently would specify a scale zero for both y and z (as that would imply projecting all line coordinates onto the X-axis). So the change could be implemented such that:
- The new behavior explicitly requires `scale:x` to be non-zero and `scale:y` and `scale:z` both to be zero,
- If that is not the case, the old behavior is kept,
- So this is likely to be backwards compatible for any 'real life' application.
## Alternatives considered
Draw a thick line by calculating the corner coordinates instead of just the start and end point, and drawing a TRIANGLE_LIST instead of a line
Pro:
- This is currently possible, i.e. requires no change to `gz-rendering`,
Con:
- Different behavior than RViz,
- Extra burden to calculate the corner coordinates,
- Not possible to add PBR textures, or at least not trivially, as I assume that some sort of UV mapping would be needed between the texture and the triangles?
Contributor guide
Research direction
Start by reproducing the LINE_LIST marker through the MarkerManager plugin using the supplied gz service command, varying the scale values and comparing the rendered width and coordinates. Trace the gz-rendering marker path across the supported rendering behavior, then verify that the chosen RViz-compatible or backward-compatible interpretation produces line width controlled by scale.x without losing the documented coordinate-scaling behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100