Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spike Essential projects #87

Open
laurensvalk opened this issue May 8, 2023 · 3 comments
Open

Add Spike Essential projects #87

laurensvalk opened this issue May 8, 2023 · 3 comments

Comments

@laurensvalk
Copy link
Member

Need to make instructions and publish code for:

Tic Tac Toe

image

Balancer

image

@laurensvalk
Copy link
Member Author

We could also ask @ZPhilo for permission to share his Pybricks Gymnast:

image

@ZPhilo
Copy link

ZPhilo commented May 8, 2023

Sure! I can share code and LDraw file...

from pybricks.hubs import EssentialHub
from pybricks.pupdevices import Motor, ColorSensor, ColorLightMatrix
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop, Axis
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch

hub = EssentialHub()

# Motor order doesn't matter
hipsmotor1=Motor(Port.A)
hipsmotor2=Motor(Port.B,Direction.COUNTERCLOCKWISE)

# Set capabilities well above physical limits to maximize power/speed
maxspeed=1000
hipsmotor1.control.limits(maxspeed,8000)
hipsmotor2.control.limits(maxspeed,8000)

# This hips angle provides a good match with natural period of pendulum
hipsangle=55
wait(1000)
while True:
    # Wait till we are on top of swing
    while hub.imu.angular_velocity(Axis.X)>0:
        continue
    # Then rotate legs
    hipsmotor1.run_target(maxspeed,hipsangle,wait=False)
    hipsmotor2.run_target(maxspeed,hipsangle)
    while hub.imu.angular_velocity(Axis.X)<0:
        continue
    hipsmotor1.run_target(maxspeed,-hipsangle,wait=False)
    hipsmotor2.run_target(maxspeed,-hipsangle)

gymnast.mpd.txt

@laurensvalk
Copy link
Member Author

Thank you @ZPhilo !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants