Skip to content

Instantly share code, notes, and snippets.

@defunctzombie
Created April 1, 2022 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defunctzombie/aa18ae159c1c078e23ef34198d80f6e1 to your computer and use it in GitHub Desktop.
Save defunctzombie/aa18ae159c1c078e23ef34198d80f6e1 to your computer and use it in GitHub Desktop.
// The ./types module provides helper types for your Input events and messages.
import { Input, Message } from "./types";
// Your node can output well-known message types, any of your custom message types, or
// complete custom message types.
//
// Use `Message` to access your data source types or well-known types:
// type Twist = Message<"geometry_msgs/Twist">;
//
// Conventionally, it's common to make a _type alias_ for your node's output type
// and use that type name as the return type for your node function.
// Here we've called the type `Output` but you can pick any type name.
type PolygonStamped = Message<"geometry_msgs/PolygonStamped">
// These are the topics your node "subscribes" to. Studio will invoke your node function
// when any message is received on one of these topics.
export const inputs = ["/SampleInputTopic"];
// Any output your node produces is "published" to this topic. Published messages are only visible within Studio, not to your original data source.
export const output = "/studio_node/SampleOutputTopic";
// This function is called with messages from your input topics.
// The first argument is an event with the topic, receive time, and message.
// Use the `Input<...>` helper to get the correct event type for your input topic messages.
export default function node(event: Input<"/SampleInputTopic">): PolygonStamped {
const msg = event.message;
return {
header: msg.header,
polygon: msg.custom_field_name_array[0].to_be_visualized_polygon,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment