Open IsabelParedes opened 1 year ago
The saved resources solution is similar to how we handle the connections to the Mecademic robot. Check out studio/PYTHON/utils/mecademic_state
-- maybe you could use some of our solution or come up with something better that might improve hardware connections in general
It may also be relevant to check out the work on the reactive nodes system, as it addresses a lot of the same problems that this is solving :)
Context
Example of a minimal ROS 2 publisher block:
Generally, ROS nodes are spun with
rclpy.spin(ros_node)
.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