1
0

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 1 year has passed since last update.

python node内でroscoreの実行

Last updated at Posted at 2022-11-18

pythonのrosプログラムを実行するときにroscoreの立ち上げを省略したい
pythonプログラムでrosnode実行前に以下を追加でOK
(※ tyr ..., except ...で囲むことでrosocreが起動している場合は,起動処理が無視できる)

run_roscore.py

import roslaunch
try:
    uuid = roslaunch.rlutil.get_or_generate_uuid(options_runid=None, options_wait_for_master=False)
    roslaunch.configure_logging(uuid)
    launch = roslaunch.parent.ROSLaunchParent(uuid, roslaunch_files=[], is_core=True)
    launch.start()
except:
    pass

# ========= write ros node =======
import rospy
rospy.init_node("aaa")
rospy.spin()

参考

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?