ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How can I remove active topic?

asked 2022-11-18 03:52:46 -0500

Ima gravatar image

Hi, I wanted to use a python script to record a bag instead of using the command line in terminal. My script is based on how record rosbag with python. However, the recorded topic stay active in the topic list even after I kill the process with Ctrl+C.

The code snippet is as follows:

import subprocess, shlex, psutil
command = "ros2 bag record -o subset /sensor/position"
command = shlex.split(command)
rosbag_proc = subprocess.Popen(command)

How can I fix this?

Any help is appreciated

edit retag flag offensive close merge delete

Comments

Follow the answer..

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2022-11-18 06:02:56 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-11-18 06:45:02 -0500

Ranjit Kathiriya gravatar image

Hello,

You can write a proper node for recoding a bag file.

You can follow a tutorial for recording a bag file using the python ros2 node.

https://docs.ros.org/en/galactic/Tuto...

I kill the process

Instead, you can unsubscribe to that by using the following line.

self.Node.destroy_subscription(self,self.subscriber)

edit flag offensive delete link more

Comments

Thanks for the reply! I, however, tried writing a ros2 node for recording a rosbag but Ros2 foxy doesn't provide the package rosbag2_py.

Ima gravatar image Ima  ( 2022-11-18 07:06:45 -0500 )edit

Have a look in the future branch you will be able to get rosbag2_py

https://github.com/ros2/rosbag2/tree/...

https://github.com/ros2/rosbag2/issue...

If you got your answer then accept the answer by pressing tick button.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2022-11-18 07:28:02 -0500 )edit

I can't change the whole branch to a new one, and what I'm looking for is removing the remaining active topics from the topic list

Ima gravatar image Ima  ( 2022-11-21 01:51:21 -0500 )edit

Clone the git repo, then after change the branch to foxy, build it. I think you will be ready to go.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2022-11-21 04:43:45 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-11-18 03:52:46 -0500

Seen: 225 times

Last updated: Nov 18 '22