Ask Your Question
0

Two nodelet overwrite themselves?

asked 2019-01-27 01:49:31 -0500

gab27 gravatar image

Hi

I run two nodelets of the same name. They subcribe and publish to different topics, but they define the same variables. Are these variables allocate twice, because I start the nodelet twice, or does one nodelet overwrite the other?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-01-27 03:32:24 -0500

gvdhoorn gravatar image

updated 2019-01-27 03:41:02 -0500

Are these variables allocate twice, because I start the nodelet twice, or does one nodelet overwrite the other?

Assuming you didn't use any "tricks", so use standard member variables: each nodelet is independent of another, so each gets their own instance of your variables.

This is no different from other C++ classes you write: each object gets its own instance of all member variables. Nothing is shared, unless you specifically set things up such that they are.


Edit:

I run two nodelets of the same name.

Did you intend to write "of the same type"?

edit flag offensive delete link more

Comments

1

PS: note that this is not "special" for nodelets, it's essentially basic C++.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-27 03:33:39 -0500 )edit

ok thanks, then it should work. I have to check this.

gab27 gravatar imagegab27 ( 2019-01-27 03:37:55 -0500 )edit

Could you please mark the question as answered by ticking the checkmark (✓) to the left of the answer if you feel it has been answered? Thanks.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-27 03:40:14 -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

Stats

Asked: 2019-01-27 01:49:31 -0500

Seen: 22 times

Last updated: Jan 27