Closed csmith-rtr closed 2 years ago
Is there an option you can set somewhere that changes what the type actually is?
This is not a bug but by design. See the Options
interface in node.d.ts.
/**
* Configuration options when creating new Publishers, Subscribers,
* Clients and Services.
*
* See {@link DEFAULT_OPTIONS}
*/
interface Options<T = QoS | QoS.ProfileRef> {
/**
* A messages will use TypedArray if necessary, default: true.
*/
enableTypedArray?: boolean;
/**
* Indicates messages are serialized, default: false.
*
* @remarks
* See {@link Node#createSubscription | Node.createSubscription}
*/
isRaw?: boolean;
/**
* ROS Middleware "quality of service" setting, default: QoS.profileDefault.
*/
qos?: T;
}
/**
* Default options when creating a Node, Publisher, Subscription, Client or Service
*
* ```ts
* {
* enableTypedArray: true,
* qos: QoS.profileDefault,
* isRaw: false
* }
* ```
*/
const DEFAULT_OPTIONS: Options;
DEFAULT_OPTIONS is the default parameter value when creating publishers, subscribers, services and actions. Here's the createPublishers()
declaration that illustrates the optional Options
parameter.
/**
* Create a Publisher.
*
* @param typeClass - Type of message that will be published.
* @param topic - Name of the topic the publisher will publish to.
* @param options - Configuration options, see DEFAULT_OPTIONS
* @returns New instance of Publisher.
*/
createPublisher<T extends TypeClass<MessageTypeClassName>>(
typeClass: T,
topic: string,
options?: Options
): Publisher<T>;
So you can customize the message serialization as shown:
node.createPublisher(
'std_msgs/msg/String',
'msg',
{ enableTypedArray: true } // this is the default value and usually omitted in most of the examples
);
Great! Thanks - sorry for the invalid bug.
Description
Not sure if this is a bug or a question... Is there a reason numeric arrays are union types? Is there an option you can set somewhere that changes what the type actually is?
Steps To Reproduce
Expected Behavior
Actual Behavior