testBoolCmd("Calibration flag clear", mymarty.clear_calibration()) if martyVersion2: logger.info(f"Calibration flag should be False ... {mymarty.is_calibrated()}") assert not mymarty.is_calibrated() testBoolCmd("Calibration flag set", mymarty.save_calibration()) if martyVersion2: logger.info(f"Calibration flag should be True ... {mymarty.is_calibrated()}") time.sleep(0.1) if martyVersion2: assert mymarty.is_calibrated() logger.info(f"Marty interface stats {json.dumps(mymarty.get_interface_stats())}") testBoolCmd("Get ready", mymarty.get_ready()) testBoolCmd("Circle Dance", mymarty.circle_dance()) testBoolCmd("Eyes excited", mymarty.eyes('excited')) testBoolCmd("Eyes wide", mymarty.eyes('wide')) testBoolCmd("Eyes angry", mymarty.eyes('angry')) testBoolCmd("Eyes normal", mymarty.eyes('normal')) testBoolCmd("Kick left", mymarty.kick('left')) testBoolCmd("Kick right", mymarty.kick('right')) testBoolCmd("Stop", mymarty.stop()) testBoolCmd("Arms 45", mymarty.arms(45, 45, 500)) testBoolCmd("Arms 0", mymarty.arms(0, 0, 500)) testBoolCmd("Arms 0", mymarty.play_sound("disbelief")) testBoolCmd("Arms 0", mymarty.play_sound("excited")) testBoolCmd("Arms 0", mymarty.play_sound("screenfree")) logger.info(f"Marty interface stats {json.dumps(mymarty.get_interface_stats())}")
# Callback function for when a report message is received # Example is free-fall or over-current detected def report_callback(report_info): print(f"report_callback {report_info}") # Start Marty # This code can be blocking because we're going to be getting messages # via the callbacks. # We also set the subscribe rate to 1Hz (normally its 10Hz) to reduce the # number of callbacks we get with published information my_marty = Marty("wifi", "192.168.0.42", blocking=True, subscribeRateHz=1) # Register callbacks my_marty.register_publish_callback(publish_callback) my_marty.register_report_callback(report_callback) # Move Marty's eyes my_marty.eyes(100) my_marty.eyes(0) # Walk a little for i in range(5): my_marty.walk(1) time.sleep(10) # Disconnect from Marty my_marty.close()