def main(): global outFile global outWriter parent_dir = os.path.join(os.environ['HOME'], 'mrover-data') if not os.path.exists(parent_dir): os.makedirs(parent_dir) path = os.path.join(parent_dir, "SensorData.csv") needsHeader = not os.path.exists(path) outFile = open(path, 'a+', newline='') outWriter = csv.writer(outFile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) if needsHeader: outWriter.writerow(print_order) outFile.flush() os.fsync(outFile.fileno()) lcm_.subscribe("/sensor_switch", switch_callback) lcm_.subscribe("/sensors", sensor_callback) run_coroutines(lcm_.loop())
def main(): # how you get lcm messages lcm = aiolcm.AsyncLCM() # instantiates Simulator class Simulator = SimulatorMetaClass() # constantly queries lcm server lcm.subscribe("/autonstate", Simulator.autonstate_cb) lcm.subscribe("/course", Simulator.course_cb) lcm.subscribe("/gps", Simulator.gps_cb) lcm.subscribe("/joystick", Simulator.joystick_cb) lcm.subscribe("/navstatus", Simulator.navstatus_cb) lcm.subscribe("/obstacle", Simulator.obstacle_cb) lcm.subscribe("/obstacles", Simulator.obstacles_cb) lcm.subscribe("/odometry", Simulator.odometry_cb) lcm.subscribe("/target", Simulator.target_cb) lcm.subscribe("/targetlist", Simulator.targetlist_cb) lcm.subscribe("/waypoint", Simulator.waypoint_cb) # creates loop to execute this code repeatedly with the lcm run_coroutines(lcm.loop(), Simulator.publish_autonstate(lcm), Simulator.publish_course(lcm), Simulator.publish_gps(lcm), Simulator.publish_joystick(lcm), Simulator.publish_navstatus(lcm), Simulator.publish_obstacle(lcm), Simulator.publish_obstacles(lcm), Simulator.publish_odometry(lcm), Simulator.publish_target(lcm), Simulator.publish_targetlist(lcm), Simulator.publish_waypoint(lcm) # runSimulator(Simulator) )
def main(): hb = heartbeatlib.OnboardHeartbeater(connection_state_changed, 0) # look LCMSubscription.queue_capacity if messages are discarded lcm_.subscribe("/drive_control", drive_control_callback) lcm_.subscribe("/autonomous", autonomous_callback) lcm_.subscribe('/motor', motor_callback) lcm_.subscribe('/arm_control', arm_control_callback) lcm_.subscribe('/sa_control', sa_control_callback) lcm_.subscribe('/encoder', encoder_callback) lcm_.subscribe('/arm_demand', enc_out_callback) # lcm_.subscribe('/arm_demand', transmit_fake_encoders) new_encoder = Encoder() new_encoder.joint_a = 0 new_encoder.joint_b = 0 new_encoder.joint_c = 0 new_encoder.joint_d = 0 new_encoder.joint_e = 0 new_encoder.joint_f = 0 lcm_.publish('/encoder', new_encoder.encode()) run_coroutines(hb.loop(), transmit_fake_odometry(), transmit_fake_sensors(), lcm_.loop(), transmit_temperature(), transmit_drive_status())
def main(): config_path = os.environ['MROVER_CONFIG'] geom_file = config_path + '/config_kinematics/mrover_arm_geom.json' args = { 'geom_file': geom_file, } lcm_ = aiolcm.AsyncLCM() arm = MRoverArm(args, lcm_) config = ConfigurationSpaceTest(arm) config.straight_up_torque_test() # config.write_file() # config.read_file() # tester = KinematicsTester(arm) # tester.kinematics_test() lcm_.subscribe("/arm_position", arm.arm_position_callback) lcm_.subscribe("/target_orientation", arm.target_orientation_callback) lcm_.subscribe("/target_angles", arm.target_angles_callback) lcm_.subscribe("/confirmation", arm.arm_position_callback) lcm_.subscribe("/motion_execute", arm.motion_execute_callback) lcm_.subscribe("/simulation_mode", arm.simulation_mode_callback) lcm_.subscribe("/ik_arm_control", arm.cartesian_control_callback) lcm_.subscribe("/lock_joint_e", arm.lock_e_callback) lcm_.subscribe("/ik_enabled", arm.ik_enabled_callback) run_coroutines(lcm_.loop(), arm.execute_spline())
def main(): lcm_.subscribe("/ik_arm_control", ik_callback) lcm_.subscribe("/arm_position", fk_callback) lcm_.subscribe('/arm_motors', open_loop_callback) thread = threading.Thread(target=listen_blender) thread.start() run_coroutines(lcm_.loop())
def main(): global out_data make_science_directories() lcm_.subscribe("/rgb_frame", rgb_frame_callback) lcm_.subscribe("/rgb", rgb_callback) run_coroutines(lcm_.loop())
def main(): hb = heartbeatlib.OnboardHeartbeater(connection_state_changed, 0) # look LCMSubscription.queue_capacity if messages are discarded lcm_.subscribe("/drive_control", drive_control_callback) lcm_.subscribe("/autonomous", autonomous_callback) lcm_.subscribe('/arm_control', arm_control_callback) lcm_.subscribe('/sa_control', sa_control_callback) run_coroutines(hb.loop(), lcm_.loop(), transmit_temperature(), transmit_drive_status())
def main(): global rover rover = Rover() lcm_.subscribe("/motor", drive_motor_callback) lcm_.subscribe("/setparam", set_param_callback) lcm_.subscribe("/setdemand", set_demand_callback) lcm_.subscribe("/sa_motors", sa_motor_callback) # lcm_.subscribe("/arm_demand", arm_demand_callback) lcm_.subscribe("/arm_motors", open_loop_arm_callback) run_coroutines(publish_arm_encoders(), lcm_.loop(), rover.run_all())
def main(): if len(sys.argv) != 2: print( "[LocSim] Error: Usage is ./jarvis exec simulators/loc <path_file>" ) exit() sim = LocSimulator(sys.argv[1]) plot_thread = threading.Thread(target=sim.plotOdom) plot_thread.start() run_coroutines(sim.lcm.loop(), sim.sendTrajectory())
def main(): global index index = int(sys.argv[1]) Gst.init(None) read_settings() lcm_.subscribe("/pi_camera", camera_callback) lcm_.subscribe("/pi_settings", settings_callback) run_coroutines(lcm_.loop())
def main(): # Uses a context manager to ensure serial port released with ScienceBridge() as bridge: _lcm = aiolcm.AsyncLCM() _lcm.subscribe("/mosfet_cmd", bridge.mosfet_transmit) _lcm.subscribe("/auton_led", bridge.auton_led) _lcm.subscribe("/servo_cmd", bridge.servo_transmit) _lcm.subscribe("/heater_cmd", bridge.heater_transmit) _lcm.subscribe("/heater_auto_shutdown_cmd", bridge.heater_auto_transmit) print("properly started") run_coroutines(_lcm.loop(), bridge.receive(_lcm))
def main(): global out_data global parent_dir parent_dir = os.path.join(os.environ['HOME'], 'mrover-data') if not os.path.exists(parent_dir): os.makedirs(parent_dir) print(parent_dir) lcm_.subscribe("/rgb_frame", rgb_frame_callback) lcm_.subscribe("/rgb", rgb_callback) run_coroutines(lcm_.loop())
def main(): hb = heartbeatlib.OnboardHeartbeater(connection_state_changed, 0) # look LCMSubscription.queue_capacity if messages are discarded lcm_.subscribe("/joystick", joystick_callback) lcm_.subscribe("/autonomous", autonomous_callback) lcm_.subscribe('/motor', motor_callback) new_kill_msg = Kill_switches() new_kill_msg.killed = False lcm_.publish('/kill_switch', new_kill_msg.encode()) run_coroutines(hb.loop(), transmit_fake_odometry(), transmit_fake_sensors(), lcm_.loop())
def main(): global index index = int(sys.argv[1]) hb = heartbeatlib.OnboardHeartbeater(connection_state_changed, index) Gst.init(None) read_settings() write_settings() lcm_.subscribe("/pi_camera", camera_callback) lcm_.subscribe("/pi_settings", settings_callback) lcm_.subscribe("/pi_picture", picture_callback) run_coroutines(lcm_.loop(), hb.loop(), connection_monitor())
def main(): # Perform arming squence for ESCs for pin in escs: esc_arm(pin) # Initialize servos at 0 position for pin in servos: servo_init(pin, 0) lcm_.subscribe("/servo", servo_callback) lcm_.subscribe("/esc_toggle", esc_toggle_callback) lcm_.subscribe("/esc_throttle", esc_throttle_callback) run_coroutines(escs_execute(), lcm_.loop())
def main(): if len(sys.argv) < 3: usage() sys.exit(1) type_name = sys.argv[1] channel = sys.argv[2] if not hasattr(rover_msgs, type_name): print('error: no such type {}'.format(type_name)) sys.exit(1) lcm_ = aiolcm.AsyncLCM() lcm_.subscribe(channel, functools.partial(recv_message, type_name)) run_coroutines(lcm_.loop())
def main(): global encoder_value_send_task if len(sys.argv) != 2: usage() sys.exit(1) device_id = int(sys.argv[1]) if device_id < 0 or device_id >= 63: usage() sys.exit(1) iface = os.environ.get('MROVER_TALON_CAN_IFACE', 'vcan0') bus = aiocan.AsyncBCM(iface) wait_for(setup_bus(bus, device_id)) run_coroutines(bus.loop(), status_3(bus, device_id))
def main(): # how you get lcm messages lcm = aiolcm.AsyncLCM() # instantiates Simulator class Simulator = SimulatorMetaClass() # constantly queries lcm server lcm.subscribe("/ping", Simulator.ping_cb) lcm.subscribe("/obstacle", Simulator.obstacle_cb) # lcm.subscribe("\nav_state", Simulator.nav_state_cb) # lcm.subscribe("\drive_control", Simulator.joystick_cb) # creates loop to execute this code repeatedly with the lcm run_coroutines(lcm.loop(), Simulator.publish_ping(lcm), Simulator.publish_obstacle(lcm) # runSimulator(Simulator) )
def main(): arm = ArmControl() drive = Drive(reverse=False) camera = Camera() def connection_state_changed(c, _): global connection if c: print("Connection established.") connection = True else: connection = False print("Disconnected.") drive.send_drive_kill() arm.send_ra_kill() arm.send_sa_kill() hb = heartbeatlib.JetsonHeartbeater(connection_state_changed, 0) # look LCMSubscription.queue_capacity if messages are discarded lcm_.subscribe("/auton_enabled", drive.auton_enabled_callback) lcm_.subscribe("/teleop_enabled", drive.teleop_enabled_callback) lcm_.subscribe('/teleop_reverse_drive', drive.reverse_callback) lcm_.subscribe("/drive_control", drive.teleop_drive_callback) lcm_.subscribe("/auton_drive_control", drive.auton_drive_callback) lcm_.subscribe('/ra_control', arm.ra_control_callback) lcm_.subscribe('/sa_control', arm.sa_control_callback) lcm_.subscribe('/arm_control_state', arm.arm_control_state_callback) lcm_.subscribe('/ra_b_calib_data', arm.ra_calibration_callback) lcm_.subscribe('/sa_b_calib_data', arm.sa_calibration_callback) lcm_.subscribe('/arm_slow_mode', arm.arm_slow_mode_callback) lcm_.subscribe('/gimbal_control', gimbal_control_callback) # Subscribe to updated GUI camera channels lcm_.subscribe('/cameras_control_ish', camera.update_ish_cameras) lcm_.subscribe('/cameras_control', camera.update_cameras) lcm_.subscribe('/cameras_mission', camera.update_mission) run_coroutines(hb.loop(), lcm_.loop())
def main(): config_path = os.environ['MROVER_CONFIG'] geom_file = config_path + '/config_kinematics/mrover_arm_geom.json' args = { 'geom_file': geom_file, } lcm_ = aiolcm.AsyncLCM() arm = MRoverArm(args, lcm_) lcm_.subscribe("/arm_position", arm.arm_position_callback) lcm_.subscribe("/target_point", arm.target_point_callback) lcm_.subscribe("/target_angles", arm.target_angles_callback) lcm_.subscribe("/confirmation", arm.arm_position_callback) lcm_.subscribe("/motion_execute", arm.motion_execute_callback) lcm_.subscribe("/simulation_mode", arm.simulation_mode_callback) lcm_.subscribe("/ik_arm_control", arm.cartesian_control_callback) lcm_.subscribe("/lock_joint_e", arm.lock_e_callback) lcm_.subscribe("/ik_enabled", arm.ik_enabled_callback) run_coroutines(lcm_.loop(), arm.execute_spline())
def main(): # how you get lcm messages lcm = aiolcm.AsyncLCM() # instantiates Simulator class Simulator = SimulatorMetaClass() # constantly queries lcm server lcm.subscribe("\nav_state", Simulator.nav_state_cb) lcm.subscribe("\drive_control", Simulator.joystick_cb) # creates loop to execute this code repeatedly with the lcm run_coroutines(lcm.loop(), Simulator.publish_auton_state(lcm), Simulator.publish_course(lcm), Simulator.publish_GPS(lcm), Simulator.publish_obstacle(lcm), Simulator.publish_tennis_ball(lcm), runSimulator(Simulator)) # as a general improvement, it may be worth threading all of the # lcm-related bruhaha to offload the worst of the performance hits # as the sim becomes more complex and computationally intensive # time to run this mf'er runSimulator(Simulator)
def main(): lcm_.subscribe("/ik_arm_control", ik_callback) thread = threading.Thread(target=listen_blender) thread.start() run_coroutines(lcm_.loop())
def main(): # look LCMSubscription.queue_capacity if messages are discarded lcm_.subscribe("/start_test", start_test_callback) run_coroutines(lcm_.loop())
def main(): hb = heartbeatlib.OnboardHeartbeater(connection_state_changed) run_coroutines(hb.loop(), transmit_fake_odometry())
def main(): fuser = SensorFusion() run_coroutines(fuser.lcm.loop(), fuser.run())
def main(): lcm_.subscribe("/motor", motor_callback) run_coroutines(lcm_.loop())
def main(): lcm_.subscribe("/camera_servos", camera_servo_callback) run_coroutines(lcm_.loop())
def main(): lcm_.subscribe("/raman_collect", collect_callback) run_coroutines(lcm_.loop())
def main(): # Uses a context manager to ensure serial port released with GPS_Manager() as manager: lcm = aiolcm.AsyncLCM() lcm.subscribe("/rtcm", manager.transmit) run_coroutines(lcm.loop(), manager.recieve(lcm))
def main(): hb = heartbeatlib.OnboardHeartbeater(connection_state_changed, sys.argv[1]) run_coroutines(hb.loop())