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

Is it possible to publish msg in rospy.on_shutdown

asked 2022-11-22 06:57:08 -0600

anonymous user

Anonymous

I want to publish message while roscore is closing. I tried to use rospy.on_shutdown but it didn't work. In wiki it says "Messages are not guaranteed to be published." for on_shutdown. I am coding with python. How can i do that?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2022-11-22 12:54:50 -0600

tfoote gravatar image

Once the communication system is shutting down, it's too late to publish a message reliably via the communication system. You will want to design your system to communicate prior to shutting down the node.

A simple analogy to this is that you want to say goodbye after someone has hung up the phone. It's not going to work well. You want to have an expected exchange prior to hanging up the phone.

edit flag offensive delete link more

Comments

So, i can't publish message during the roscore closing right? Isn't there any way to publish message without design my system and if i have to design my system, how can i do that?

anonymous userAnonymous ( 2022-11-22 13:29:01 -0600 )edit
1

Just to be clear, roscore and rospy are different things. roscore is remote, rospy is local. When rospy.on_shutdown is called that's to tell you that the connections are being shutdown and you cannot expect to communicate any more. You're asking to do something that the callback is explicitly informing you that you can't do anymore. I suspect that on_shutdown is not the right thing to use for your use case. This is more likey an X-Y problem, but without knowing your use case I can't help much more.

tfoote gravatar image tfoote  ( 2022-11-22 16:41:31 -0600 )edit
-1

answered 2022-11-23 06:08:41 -0600

anonymous user

Anonymous

When i first try, i used rosmsg and it didn't work. After that i tried it with rosservices and now it's working. I set arduino as a server and python code as a client. If anyone has this issue, i recommend to use rosservices.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-11-22 06:57:08 -0600

Seen: 169 times

Last updated: Nov 23 '22