PickNikRobotics / rviz_visual_tools

C++ API wrapper for displaying shapes and meshes in Rviz
769 stars 243 forks source link

migrate to <random> #195

Closed v4hn closed 3 years ago

v4hn commented 3 years ago

rand/srand were probably already deprecated by the time this code was written... I took the error on MoveIt's CI as an incentive to migrate to std::random:

As example code referred to a seeding step, I added an explicit setRandomSeed to the API.

This is required to fix MoveIt's CI: https://github.com/ros-planning/moveit/pull/2792/commits/2989f44e50ea10a1bc1ef833d39bac766daf61f5

<<< rviz_visual_tools.cpp:2810:42: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion] float d = static_cast(rand()) / RAND_MAX; ~ ^~~~ /usr/include/stdlib.h:86:18: note: expanded from macro 'RAND_MAX' ^~~~~~ <<<

Please review @nbbrooks @tylerjw @JafarAbdi

v4hn commented 3 years ago

Are we accepting formatting comments?

:question:

griswaldbrooks commented 3 years ago

Don't worry about it. There was some comma spacing I was going to ask about but if the linter is fine with it then I don't care.