Interruption in ROS for UART communication
Hi everyone,
I am working on an ultra96 which is a bit like a raspberry with an FPGA soc and my version of ROS is melodic. The ultra96 communicate with an STM32 processor. That communication is using to send move orders to the STM32 and the odometry to the Ultra96. In my ROS conception, I have a node, postman, that is in charge of that communication. To send orders to the STM32, there is no problems, for example: when a message is publishing in the topic cmd_vel, the Postman send that message through the UART communication. But I don’t know how can I do to Interrupt ROS process when a message is receive by the Ultra96 from the STM32. Currently, I wake up the postman node every 10 milliseconds to scan if a new message is received. But that method is not very optimized and very time-consuming. Is someone know how to manage interruptions in ROS? Or do you have any link that could help me?
Thanks,
Will
def listener():
rospy.init_node('postman', anonymous=True)
rospy.Subscriber('cmd_vel',Twist, send_cmd)
timer = rospy.Timer(rospy.Duration(0.1), dispatcher)
rospy.spin()
timer.shutdown()
if __name__ == '__main__':
print ("Postman is running")
start_uart()
listener()