Closed VictorLamoine closed 7 years ago
I'm not sure if this answers your question, but my rviz_visual_tools::color
type is a quick way to choose a color, but it is limiting to what colors you can choose from. For this reason, most of the publish functions also accept const std_msgs::ColorRGBA &color
.
But if you must use an int
, I have a function for that helpful for libraries such as OMPL:
/** \brief Used by interfaces that do not directly depend on Rviz Visual Tools, such as OMPL */
colors intToRvizColor(std::size_t color);
Well it's been a long time but your answer didn't fall on deaf ears! https://gitlab.com/InstitutMaupertuis/ros_additive_manufacturing/merge_requests/28/diffs
Thank you for your help
Let's say I have a service to publish a marker with a given color and size.
My service would look like:
The service implementation needs to convert the unsigned int color to a rviz visual tool color; this can be done with
But this results in undefined behavior if
req.color
is not represented in the enum. A work-around would be to define something likeKEEP_ME_AT_THE_END_ENUM_SIZE
to be able to determine ifcolor
is in the allowed range. This only works for contingous enums starting from 0.We would like to avoid a big switch case for each color.
Did you face this issue? How did you solve it? What do you think?