Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

[BLO-92] ROS 2 [RFC]: Stateful Blocks #29

@IsabelParedes

Description

@IsabelParedes

Context

Example of a minimal ROS 2 publisher block:


@flojoy
def ROS_PUBLISHER():

    ros_pub = Publisher()
    ros_pub.publish_message("Some message")
    rclpy.spin(ros_pub)
    ros_pub.destroy_node()

    return

Generally, ROS nodes are spun with rclpy.spin(ros_node).

rclpy.spin creates an event loop, which repeatedly checks for events and handles them
It is essentially an infinite loop that repeatedly calls spin_once()

Publishers have a timer which determines the frequency at which messages are published to a given topic. Each spin of a publisher is triggered by the the timer.

For subscribers, they spin every time a new message is published to the given topic.

Problem

Since block execution in flojoy is function based, the publisher must be created and destroyed every time the ROS_PUBLISHER block is executed. This is inefficient and also poses a problem when the user wants to publish messages repeatedly.

Under normal circumstances, a ROS node will spin indefinitely until the node is killed. However, doing this in a flojoy block would impede the execution of any other blocks.

Proposed Solution

Enable the storage of block states. When a publisher or a subscriber are created, they should be reusable to save resources. This would also allow us to publish a message and return control to the user without blocking execution.

References

From SyncLinear.com | BLO-92

Metadata

Metadata

Assignees

Labels

ImprovementCreated by Linear-GitHub Sync

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions