def _to_time_inst(msg, rostype, inst=None):
# Create an instance if we haven't been provided with one
if rostype == "time" and msg == "now":
return rospy.get_rostime()
if inst is None:
if rostype == "time":
inst = rospy.rostime.Time()
elif rostype == "duration":
inst = rospy.rostime.Duration()
else:
return None
# Copy across the fields
for field in ["secs", "nsecs"]:
try:
if field in msg:
setattr(inst, field, msg[field])
except TypeError:
continue
return inst
评论列表
文章目录