Ask Your Question
1

Subscribe to Rostopic from flask app

asked 2019-08-03 22:32:49 -0500

Ajith gravatar image

updated 2019-08-04 16:59:09 -0500

jayess gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-06-05 08:47:18 -0500

MartensCedric gravatar image

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

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-08-03 22:32:49 -0500

Seen: 309 times

Last updated: Jun 05 '20