leggedrobotics / raisimLib

RAISIM, A PHYSICS ENGINE FOR ROBOTICS AND AI RESEARCH
http://www.raisim.com
327 stars 50 forks source link

add heightmap using textfile and png #39

Closed limbryan closed 4 years ago

limbryan commented 4 years ago

Hi,

Have been trying for a few weeks to read in heightmaps from png and and textfile but have not been able to get it to work. Went through the source code and saw that both formats were accepted and seems the easiest to load in more complex terrain that is self defined.

  1. PNG tried to read in a png file that looks like the one below. Successfully compiled and loaded it. However, in simulation, it is way too big, the the resolution seems to depend on the scale as well. image

image

  1. textfile Sucessfully compiled and loaded textfile but get "insufficient number of height values" error image

For both these formats, is there a certain format or form of png/txtfile that needs to be parsed in. Would appreciate examples of textfiles and png files that it accepts or more documentation and help on these issues if possible.

Thank you!

jhwangbo commented 4 years ago

All examples are in raisimOgre repo.

An example of heightmap creation using a png is under "examples/src/primitives/heightMapFromPng.cpp". That using the raisim text format was absent but I just added it to the same file and pushed.

  1. png file just defines pixel values for each coordinate. How big the map is and how high each pixel increment represents are defined by the user at the construction time. X, Y sizes are defined by "xSize" and "ySize" arguments respectively. In the case of the above black and white png file, black pixel value is 0 and white pixel value is 255. If you set the "heightScale" = 0.1, the black pixels will be 0m high and white pixels will be 25.5m high.

  2. I just pushed the description of the format in the header file "World.hpp".