Ask Your Question

Changing a variable inside a running node

asked 2018-05-24 18:23:01 -0600

inani47 gravatar image

updated 2018-05-24 20:40:10 -0600

I'm trying to change a variable that sets the speed of a robot after it has been initialized with a specific value, say 0.5. After some time passes, I require to change the value to, say 1. How can I accomplish this?

edit retag flag offensive close merge delete


This sounds a bit like an XY Problem. Can you rephrase what you want to do without describing how you want to do it (ie, without describing it in terms of a service)

ahendrix gravatar imageahendrix ( 2018-05-24 20:33:06 -0600 )edit
inani47 gravatar imageinani47 ( 2018-05-24 20:39:32 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-05-24 21:16:24 -0600

ahendrix gravatar image

Most robots use topics for sending periodic or continuous commands to motors and actuators.

The tutorial gives a good overview of topics:

And this turtlesim tutorial gives a more in-depth look at how to use topics to control a robot (or simulator):

edit flag offensive delete link more


I considered this.. But I have the same node running with two different names.. And i need to change the variable for each node differently

inani47 gravatar imageinani47 ( 2018-05-24 21:26:53 -0600 )edit

If you have two copies of the same node running, I suggest you remap the service or topic names used by each copy of that node so that each copy of the node has it's own service and topic names.

ahendrix gravatar imageahendrix ( 2018-05-24 21:43:29 -0600 )edit

@ahendrix will launching nodes with different namespaces also achieve this?

inani47 gravatar imageinani47 ( 2018-05-30 17:57:45 -0600 )edit

Yes; namespaces will typically do this too (unless the node uses absolute topic names, but that's unusual).

ahendrix gravatar imageahendrix ( 2018-05-30 18:05:58 -0600 )edit

By the way, I was able to implement this using a service, I just felt it was a cleaner way to do things. Just personal preference. So I guess what I was really asking is will there be two sets of services created if I launch with different namespaces?

inani47 gravatar imageinani47 ( 2018-05-30 18:13:45 -0600 )edit

Yes; namespacing applies to services in the same way.

ahendrix gravatar imageahendrix ( 2018-05-30 18:20:44 -0600 )edit

answered 2018-05-24 20:51:04 -0600

do you means rqt_reconfigure

edit flag offensive delete link more


The variable is not a parameter, but can I make it one and then use this tool?

inani47 gravatar imageinani47 ( 2018-05-24 21:25:46 -0600 )edit

yes,try this dynamic_reconfigure tutorial and you can figure it out

pengjiawei gravatar imagepengjiawei ( 2018-05-24 21:33:06 -0600 )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



Asked: 2018-05-24 18:23:01 -0600

Seen: 128 times

Last updated: May 24 '18