Пример #1
0
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())}")

for i in range(9): 
    testBoolCmd(f"Move joint {i}", mymarty.move_joint(i, i * 10, 500))
for jointName in jointNames: 
    testBoolCmd(f"Move joint {jointName}", mymarty.move_joint(jointName, 123, 500))

logger.info(f"Accelerometer x {mymarty.get_accelerometer('x')}")
logger.info(f"Accelerometer y { mymarty.get_accelerometer('y')}")
logger.info(f"Accelerometer z { mymarty.get_accelerometer('z')}")

if martyVersion2:
    testBoolCmd("Dance", mymarty.dance())
    testBoolCmd("Eyes wiggle", mymarty.eyes('wiggle'))
    testBoolCmd("Hold position", mymarty.hold_position(6000))
    testBoolCmd("is_moving", mymarty.is_moving())
    logger.info("Joint positions: ", [mymarty.get_joint_position(pos) for pos in range(9)])

time.sleep(5)

mymarty.close()
Пример #2
0
This uses the blocking: False option so martypy queues up the
movements and sounds and then goes on to show the posiiotn of
marty as it moves
'''

# See README.md for instructions on how to run this

# Import Marty from the martypy library and the time library
from martypy import Marty
import time

# Connect to a Marty and# use the variable my_marty to refer to that Marty
# This assumes you are connecting via WiFi - check the documentation for other options
# You will need to set the ip_address variable with the IP address of your Marty
connection_method = "wifi"
ip_address = "192.168.86.18"
my_marty = Marty(connection_method, ip_address, blocking=False)

# Ask Marty to walk
my_marty.walk(20)
my_marty.dance()
time.sleep(1)

# Do something while marty is walking
while my_marty.is_moving():
    print(f"Marty's left leg is at {my_marty.get_joints()[0]['pos']}")
    time.sleep(0.5)

# Disconnect from Marty
my_marty.close()