Ask Your Question
1

rospy Subscriber object not getting destroyed?

asked 2012-11-16 18:25:05 -0500

Bill Smart gravatar image

updated 2012-11-17 12:10:18 -0500

This just came up in an assignment that I'm grading, and I can't figure out why it works. In the constructor of a class, there is:

self.sub = rospy.Subscriber('/odom', Odometry, self.seek_goal)

followed immediately by

self.sub = rospy.Subscriber('/base_scan', LaserScan, self.laser_agg)

My understanding is that, when self.sub is reassigned, the original Subscriber should go out of scope, get destroyed, and get garbage-collected. However, both callbacks seem to run happily for the duration of the node's existence.

Any Python gurus out there with any insight? I could guess about the object not getting reaped, but it should still go out of scope (and get destroyed), right?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-11-18 09:10:25 -0500

Lorenz gravatar image

After looking at rospy's source code, it looks like no __del__ method is implemented for subscribers. That means, topics are just not cleaned up when a subscriber object is destroyed. The user needs to manually unregister topics.

I'm not sure if this was intended behavior but I would consider filing an enhancement ticket.

edit flag offensive delete link more

Comments

I recently noticed a similar issue with rospy service advertisements.

joq gravatar imagejoq ( 2012-11-24 03:26:57 -0500 )edit

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: 2012-11-16 18:25:05 -0500

Seen: 338 times

Last updated: Nov 18 '12