ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

genmsg.base.InvalidMsgSpec: array is not a legal constant type

asked 2016-09-27 10:41:11 -0500

spmaniato gravatar image

updated 2016-09-27 11:37:11 -0500

According to http://wiki.ros.org/msg , "With the exception of time and duration, you may declare any built-in type as a constant."

However, when I try this:

uint8[3] color
uint8[3] BLACK = {0,0,0}

I get:

genmsg.base.InvalidMsgSpec: [...] uint8[3] is not a legal constant type

I've also tried [0,0,0] and (0,0,0) but it didn't make a difference. The error is about the the type, not the value. std_msgs/UInt8[3] didn't work either.

Am I messing up the syntax or is it just that ROS msg constants cannot be arrays?

PS1. My goal here is to create constants for common RGB colors, such as BLACK, RED, GREEN, BLUE.

PS2. Can I somehow leverage std_msgs/ColorRGBA in order to define these constants in my custom message?


Update: As Dirk's answer points out, arrays of built-in types are not built-in types themselves. For my usecase (RGB colors), I ended up using a single integer to represent the 3 RGB values. See, for example, http://www.shodor.org/stella2java/rgb...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-09-27 10:58:39 -0500

Dirk Thomas gravatar image

Arrays are not built-in types. Therefore you can't define constants of type array.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-09-27 10:41:11 -0500

Seen: 1,037 times

Last updated: Sep 27 '16