1
1

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.

ros python 時間差取得

Last updated at Posted at 2022-03-09

ros pythonノード内pythonのtimeライブラリを使用した時間取得が行えません。rosノード内でそのような処理を行う場合は以下のようなプログラムになります。

import rospy

def now():
    return rospy.get_time()

rospy.init_node("time")

start = now()

while not rospy.is_shutdown():
    print( now() - start)

出力(単位:s)

0.3100881576538086
0.31009507179260254
0.3101022243499756
0.31010913848876953
0.3101155757904053
0.3101224899291992

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?