constants support in messages
See original GitHub issueis there a way to reference the constant value like in rclpy? Something like
const marker = {...
type: ImageMarker.CIRCLE,
...}
I can see that constants are generated in the js messages like so
// Define constants (7 in total)
Object.defineProperty(ImageMarkerWrapper, "CIRCLE", {value: 0, writable: false, enumerable: true, configurable: true});
Object.defineProperty(ImageMarkerWrapper, "LINE_STRIP", {value: 1, writable: false, enumerable: true, configurable: true});
Object.defineProperty(ImageMarkerWrapper, "LINE_LIST", {value: 2, writable: false, enumerable: true, configurable: true});
Object.defineProperty(ImageMarkerWrapper, "POLYGON", {value: 3, writable: false, enumerable: true, configurable: true});
Object.defineProperty(ImageMarkerWrapper, "POINTS", {value: 4, writable: false, enumerable: true, configurable: true});
Object.defineProperty(ImageMarkerWrapper, "ADD", {value: 0, writable: false, enumerable: true, configurable: true});
Object.defineProperty(ImageMarkerWrapper, "REMOVE", {value: 1, writable: false, enumerable: true, configurable: true});
But it needs to be imported like so
const ImageMarker = require('rclnodejs/generated/visualization_msgs/visualization_msgs__msg__ImageMarker');
which doesn’t seem like the intended usage.
Also, the typescript interfaces are generated like this
export type ImageMarker = {
CIRCLE: 0,
LINE_STRIP: 1,
LINE_LIST: 2,
POLYGON: 3,
POINTS: 4,
ADD: 0,
REMOVE: 1,
header: std_msgs.msg.Header,
ns: string,
id: number,
type: number,
action: number,
position: geometry_msgs.msg.Point,
scale: number,
outline_color: std_msgs.msg.ColorRGBA,
filled: undefined,
fill_color: std_msgs.msg.ColorRGBA,
lifetime: builtin_interfaces.msg.Duration,
points: geometry_msgs.msg.Point[],
outline_colors: std_msgs.msg.ColorRGBA[]
};
The constants have to be defined in objects that implements the type.
const marler: ImageMarker = {
// All the constants have to be defined
CIRCLE: 0,
LINE_STRIP: 1,
...
};
Is there an easier way to reference the constants in rclnodejs?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
SMS Text Message Marketing Software For Small Business
From email to ecommerce, SMS to social, CRM to see what's next, we deliver tools to help small businesses grow. We deliver for...
Read more >What happens to constants in a .msg? - ROS Answers
Hello,. If I have the following message: uint8 val uint8 a=0 uint32 b=0 string c=this is the string. Which I publish as follows:...
Read more >Constant Messaging - A Thin Line
3 QUESTIONS TO ASK YOURSELF ABOUT CONSTANT MESSAGING In a healthy relationship, partners trust each other and give each other room to breathe,...
Read more >Message Constants - Win32 apps - Microsoft Learn
This section describes the changes you can make to an application's main window procedure to enable a user to scroll text. WM_GETDLGCODE message...
Read more >Accessing SMS Message Type Constants - java - Stack Overflow
Message type constants are defined in Telephony.TextBasedSmsColumns. In a nutshell, as provided on other SO answers: MESSAGE_TYPE_ALL = 0; ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have been using a tool I made to generate typescript interfaces, now that rclnodejs has support for typescript, it would be better to use the native support. I will try to see if I can make a PR for this, thanks!
https://github.com/RobotWebTools/rclnodejs/pull/551 This PR improve typing information and generate constants as
const enum