def test_check_type(self): # check_type() currently does not do harder checks like # type-checking class types. as soon as it does, it will need # test to validate this. from roslib.message import check_type, SerializationError from roslib.rostime import Time, Duration valids = [ ('byte', 1), ('byte', -1), ('string', ''), ('string', 'a string of text'), ('int32[]', []), ('int32[]', [1, 2, 3, 4]), ('time', Time()), ('time', Time.from_sec(1.0)), ('time', Time(10000)), ('time', Time(1000, -100)), ('duration', Duration()), ('duration', Duration()), ('duration', Duration(100)), ('duration', Duration(-100, -100)), ] for t, v in valids: try: check_type('n', t, v) except Exception, e: traceback.print_exc() raise Exception("failure type[%s] value[%s]: %s" % (t, v, str(e)))
def test_check_type(self): # check_type() currently does not do harder checks like # type-checking class types. as soon as it does, it will need # test to validate this. from roslib.message import check_type, SerializationError from roslib.rostime import Time, Duration valids = [ ('byte', 1), ('byte', -1), ('string', ''), ('string', 'a string of text'), ('int32[]', []), ('int32[]', [1, 2, 3, 4]), ('time', Time()), ('time', Time.from_sec(1.0)), ('time', Time(10000)), ('time', Time(1000, -100)), ('duration', Duration()),('duration', Duration()), ('duration', Duration(100)), ('duration', Duration(-100, -100)), ] for t, v in valids: try: check_type('n', t, v) except Exception, e: traceback.print_exc() raise Exception("failure type[%s] value[%s]: %s"%(t, v, str(e)))
numMsgsCopied = 0 bagStartTimeSec = None for topic, msg, t in bag.read_messages(): timeSec = t.to_sec() if bagStartTimeSec == None: bagStartTimeSec = timeSec timeSec -= bagStartTimeSec if timeSec < startTime: continue elif timeSec > endTime: break curTime = timeOffset + timeSec - startTime rosTime = Time.from_sec( curTime ) msg.header.seq = curSeq msg.header.stamp = rosTime outputBag.write( topic, msg, rosTime ) numMsgsCopied += 1 curSeq += 1 lastTime = curTime if numMsgsCopied == 0: print "No messages found within given time period for", bagFileSlice[ 0 ] else: print numMsgsCopied bag.close()
numMsgsCopied = 0 bagStartTimeSec = None for topic, msg, t in bag.read_messages(): timeSec = t.to_sec() if bagStartTimeSec == None: bagStartTimeSec = timeSec timeSec -= bagStartTimeSec if timeSec < startTime: continue elif timeSec > endTime: break curTime = timeOffset + timeSec - startTime rosTime = Time.from_sec(curTime) msg.header.seq = curSeq msg.header.stamp = rosTime outputBag.write(topic, msg, rosTime) numMsgsCopied += 1 curSeq += 1 lastTime = curTime if numMsgsCopied == 0: print "No messages found within given time period for", bagFileSlice[0] else: print numMsgsCopied bag.close()