Subscribe to Rostopic from flask app
Hi,
I have Ros melodic
installed in Ubuntu 18.04
. I have a sample rosbag
which have some rostopics
.
I have an existing flask
app in which I need to subscribe to these topics and get the response as message objects and pass that to catkin package
for further processing.
What I have done thus far is that in the flask
app I used subprocess
to trigger a listener
script which subscribes to the topics. But the subprocess
is not returning the message object.
p = subprocess.check_output(["./listener.py"])
When I run the listener
in python shell
, it executes correctly.
What I like to have is on calling the flask app
, the listener script
is executed and message object is returned back to flask app. Any suggestions will be much appreciated. Thanks.
Asked by Ajith on 2019-08-03 22:32:49 UTC
Answers
You have a few options :
Import the functions of your listener script to have access to the data from your flask app.
import
rospy
and subscribe directly in python (instead of calling a subprocess)If you want to have the data in the JS, then checkout roslibjs
Asked by MartensCedric on 2020-06-05 08:47:18 UTC
Comments