def main(): """ Main function """ node = cyber.Node("data_collector") data_collector = DataCollector(node) plotter = Plotter() node.create_reader('/apollo/localization/pose', localization_pb2.LocalizationEstimate, data_collector.callback_localization) node.create_reader('/apollo/canbus/chassis', chassis_pb2.Chassis, data_collector.callback_canbus) print('Enter q to quit.') print('Enter p to plot result from last run.') print('Enter x to remove result from last run.') print('Enter x y z, where x is acceleration command, ' + 'y is speed limit, z is decceleration command.') print('Positive number for throttle and negative number for brake.') while True: cmd = raw_input("Enter commands: ").split() if len(cmd) == 0: print('Quiting.') break elif len(cmd) == 1: if cmd[0] == "q": break elif cmd[0] == "p": print('Plotting result.') if os.path.exists(data_collector.outfile): plotter.process_data(data_collector.outfile) plotter.plot_result() else: print('File does not exist: %s' % data_collector.outfile) elif cmd[0] == "x": print('Removing last result.') if os.path.exists(data_collector.outfile): os.remove(data_collector.outfile) else: print('File does not exist: %s' % date_collector.outfile) elif len(cmd) == 3: data_collector.run(cmd)
def main(): """ Main function """ node = cyber.Node("data_collector") data_collector = DataCollector(node) plotter = Plotter() node.create_reader('/apollo/localization/pose', localization_pb2.LocalizationEstimate, data_collector.callback_localization) node.create_reader('/apollo/canbus/chassis', chassis_pb2.Chassis, data_collector.callback_canbus) print "Enter q to quit" print "Enter p to plot result from last run" print "Enter x to remove result from last run" print "Enter x y z, where x is acceleration command, y is speed limit, z is decceleration command" print "Positive number for throttle and negative number for brake" while True: cmd = raw_input("Enter commands: ").split() if len(cmd) == 0: print "Quiting" break elif len(cmd) == 1: if cmd[0] == "q": break elif cmd[0] == "p": print "Plotting result" if os.path.exists(data_collector.outfile): plotter.process_data(data_collector.outfile) plotter.plot_result() else: print "File does not exist" elif cmd[0] == "x": print "Removing last result" if os.path.exists(data_collector.outfile): os.remove(data_collector.outfile) else: print "File does not exist" elif len(cmd) == 3: data_collector.run(cmd)
def main(): """ Main function """ rospy.init_node('data_collector', anonymous=True) data_collector = DataCollector() plotter = Plotter() localizationsub = rospy.Subscriber('/apollo/localization/pose', localization_pb2.LocalizationEstimate, data_collector.callback_localization) canbussub = rospy.Subscriber('/apollo/canbus/chassis', chassis_pb2.Chassis, data_collector.callback_canbus) print "Enter q to quit" print "Enter p to plot result from last run" print "Enter x to remove result from last run" print "Enter x y z, where x is acceleration command, y is speed limit, z is decceleration command" print "Positive number for throttle and negative number for brake" while True: cmd = raw_input("Enter commands: ").split() if len(cmd) == 0: print "Quiting" break elif len(cmd) == 1: if cmd[0] == "q": break elif cmd[0] == "p": print "Plotting result" if os.path.exists(data_collector.outfile): plotter.process_data(data_collector.outfile) plotter.plot_result() else: print "File does not exist" elif cmd[0] == "x": print "Removing last result" if os.path.exists(data_collector.outfile): os.remove(data_collector.outfile) else: print "File does not exist" elif len(cmd) == 3: data_collector.run(cmd)
def main(): """ Main function """ node = cyber.Node("data_collector") data_collector = DataCollector(node) plotter = Plotter() print("create data_collector") node.create_reader('/apollo/localization/pose', localization_pb2.LocalizationEstimate, data_collector.callback_localization) node.create_reader('/apollo/canbus/chassis', chassis_pb2.Chassis, data_collector.callback_canbus) print('Enter q to quit.') print('Enter p to plot result from last run.') print('Enter x to remove result from last run.') print('Enter x y z, where x is acceleration command, ' + 'y is speed limit, z is decceleration command.') print('Positive number for throttle and negative number for brake.') while True: #data_collector.case == 'a' # if (self.controlcmd.gear_location == chassis_pb2.Chassis.GEAR_NEUTRAL): # self.controlcmd.brake = 50 # time.sleep(0.5) # self.controlcmd.gear_location = chassis_pb2.Chassis.GEAR_NEUTRAL # self.control_pub.write(self.controlcmd) # print("first gear %d" %(self.controlcmd.gear_location)) # time.sleep(0.5) # self.controlcmd.gear_location = chassis_pb2.Chassis.GEAR_DRIVE # self.control_pub.write(self.controlcmd) # print("second gear %d" %(self.controlcmd.gear_location)) # #self.controlcmd.gear_location = chassis_pb2.Chassis.GEAR_DRIVE # test by why # self.controlcmd.brake = 0 #self.control_pub.write(self.controlcmd) #print("third gear %d" %(self.controlcmd.gear_location)) #self.canmsg_received = False # test by why cmd = raw_input("Enter commands: ").split() if len(cmd) == 0: print('Quiting.') break elif len(cmd) == 1: if cmd[0] == "q": break elif cmd[0] == "p": print('Plotting result.') if os.path.exists(data_collector.outfile): plotter.process_data(data_collector.outfile) plotter.plot_result() else: print('File does not exist: %s' % data_collector.outfile) elif cmd[0] == "x": print('Removing last result.') if os.path.exists(data_collector.outfile): os.remove(data_collector.outfile) else: print('File does not exist: %s' % date_collector.outfile) elif len(cmd) == 3: data_collector.run(cmd)