3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ros nodeが死んでしまった際に自動再起動する方法

Last updated at Posted at 2021-12-04

内容

rosノードプロセスが死んでしまったときに,自動で検知して再起動する方法がないかと調べたところ,roslaunch内でrespawnをtrueにすると自動で再起動してくれることが分かりました。(※例えばデバイスを扱うノードとかはデバイスが無いと死んでしまったりするのですが,これを使うとデバイスをつないだタイミングでノードが立ち上がるなどの動作ができるようになります)

以下のようにrespawn="true"と記載するだけでOKです。

respawn.launch
<roslaunch>
  <node name="foo" pkg="package" type="node" respawn="true" />
</roslaunch>

ちなみに,再起動のdelayなども設定可能みたいですので、興味がある方は公式ドキュメントをご参照ください。(デフォルトではdelayは0秒なので負荷軽減のためには入れた方がいいのかもしれません)

さいごに

自分でbashファイルなどでプロセスが死んだか監視して再起動みたいな事をしなくていいためとても便利ですね!

参考

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?