RegisterMessageConverterArgsTopic
type RegisterMessageConverterArgsTopic = object;
This type represents the arguments you pass to ExtensionContext.registerMessageConverter when you want to register a topic message converter.
Properties
type
type: "topic";
inputTopics
inputTopics: string[];
outputTopic
outputTopic: string;
outputSchemaName
outputSchemaName: string;
Name of the schema for messages output by the converter.
If you output well-known messages like a foxglove CompressedImage then your schema name would
be foxglove.CompressedImage
.
If you are creating a new custom schema you can assign any name. Avoid picking an existing name if your data uses a different schema.
NOTE: For ROS users, we also support names like sensor_msgs/msg/CompressedImage
. See the
supported messages documentation for each panel to learn what kinds of schemas it can display.
outputSchemaDescription?
optional outputSchemaDescription: MessageSchemaDescription;
Describes the structure of the output messages produced by this converter.
This optional field allows Foxglove to understand the structure of your messages, enabling features like autocompletion for message path selection.
The schema can include:
- Primitive types: "string", "number", "bool", "byte"
- Arrays of primitives: ["string"], ["number"], ["bool"], ["byte"]
- Nested objects with their own field definitions
- Arrays of objects (each element having the same structure)
Example
schemaDescription: {
// Simple fields
timestamp: "number",
label: "string",
enabled: "bool",
flags: "byte",
// Array of primitives
values: ["number"],
names: ["string"],
options: ["bool"],
data: ["byte"],
// Nested object
position: {
x: "number",
y: "number",
z: "number"
},
// Array of objects
landmarks: [{
id: "string",
position: {
x: "number",
y: "number"
}
}]
}
schemaName?
optional schemaName: string;
Deprecated
use outputSchemaName
instead
schemaDescription?
optional schemaDescription: MessageSchemaDescription;
Deprecated
use outputSchemaDescription
instead
create()
create: () => TopicConverterReturnType;
The create function initializes the converter. It is called by the app to create the converter when some panel subscribes to the output topic.
create: () => {
return (msgEvent: MessageEvent) => {
const msg = msgEvent.message as MySignal;
return { value: Math.abs(msg.acceleration) };
};
},
Returns
TopicConverterReturnType
A function that is called with a MessageEvent for every input message. It performs any computation and returns a new message(s) matching the schema description. The function can optionally return undefined to skip producing message(s) for the given input.