Skip to content

Commit faaacce

Browse files
committed
sets: Add Audi Xbox example.
1 parent 9ccd119 commit faaacce

File tree

6 files changed

+83
-0
lines changed

6 files changed

+83
-0
lines changed

sets/technic/42160-audi-rs-q-e-tron/powered-up-remote/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ video:
1010
youtube: "c0KVNdJlAkc"
1111
description: "Control the Technic Audi RS Q e-tron with the Powered Up Remote."
1212
code: "#program"
13+
building_instructions:
14+
external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6508358.pdf
1315
---
1416

1517
In this project we'll show you how to control the Audi RS Q e-tron with the Powered Up remote.
Loading
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# pybricks blocks file:{"blocks":{"languageVersion":0,"blocks":[{"type":"blockGlobalSetup","id":"bjK,wS1MYO7aiYkFSwd{","x":254,"y":17,"deletable":false,"next":{"block":{"type":"variables_set_motor","id":"g??RF]?65}mDL*lODRv`","fields":{"VAR":{"id":"Sfkt5!a|mBRd)veW}%@V"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"|^1Nfd(Dhq5-aHpPbK8(","fields":{"NAME":"A"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":".{{l7YMM6{J=2P$%DL}~","fields":{"SELECTION":"Direction.CLOCKWISE"}}}},"next":{"block":{"type":"variables_set_motor","id":"{s*h:+G,8yg8gJ~,~22#","fields":{"VAR":{"id":"VeQJ3bN/NZ@%t]W;@|j0"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"/wf]Q3.hq(|?BbXDYFxy","fields":{"NAME":"B"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"oT;4{l#}-P{P+YWsua[V","fields":{"SELECTION":"Direction.CLOCKWISE"}}}},"next":{"block":{"type":"variables_set_motor","id":"/5/4E([a|w*HXH3lCeZ1","fields":{"VAR":{"id":"g4h(Hwe2rwZ;t+I3jn}-"}},"inputs":{"PORT":{"shadow":{"type":"blockParametersPort","id":"]M-5kmKcDnx$UGMu-3Nr","fields":{"NAME":"D"}}},"POSITIVE_DIRECTION":{"shadow":{"type":"blockParametersDirection","id":"*$Utn7SALQwJcW0gvs{g","fields":{"SELECTION":"Direction.CLOCKWISE"}}}},"next":{"block":{"type":"variables_set_car","id":"7D9,d+uH1$jJcu/L|.{R","extraState":{"optionLevel":1},"fields":{"VAR":{"id":"N?o:_)gI%v:qMoTdDK3}"}},"inputs":{"VAR":{"shadow":{"type":"variables_get_motor_device","id":"eih^k6;{Y:2},r/h9j;C","fields":{"VAR":{"id":"g4h(Hwe2rwZ;t+I3jn}-","name":"steer","type":"Motor"}}}},"VAR2":{"shadow":{"type":"variables_get_motor_device","id":"ZTl,ay[tn5`#UT;r:]iI","fields":{"VAR":{"id":"Sfkt5!a|mBRd)veW}%@V","name":"front","type":"Motor"}}}},"DRIVE1":{"shadow":{"type":"variables_get_motor_device","id":"Ga45HDGU4T`=MJLb`X|s","fields":{"VAR":{"id":"VeQJ3bN/NZ@%t]W;@|j0","name":"rear","type":"Motor"}}}}},"next":{"block":{"type":"variables_set_xbox_controller","id":"s+_^IwVdquWW*)1{jXc2","fields":{"VAR":{"id":"jO|qF()?HGJCju9#H|@j"}}}}}}}}}}}}},{"type":"blockGlobalStart","id":"3tJe|AWl0baN(wH9a$@.","x":252,"y":363,"deletable":false,"next":{"block":{"type":"blockFlowWhile","id":"VoVB}x{TNVKlM$2,bw4@","fields":{"MODE":"WHILE"},"inputs":{"BOOL":{"shadow":{"type":"blockLogicTrue","id":"BomU1(Vt;1T,#9Ll{diM"}},"DO":{"block":{"type":"blockCarDrive","id":"lgIQ`%W,O@d;1qGX*h_b","extraState":{"optionLevel":1},"fields":{"METHOD":"CAR_DRIVE_AT_POWER"},"inputs":{"VAR":{"shadow":{"type":"variables_get_car_device","id":"V`Y45418lIx03ytU24V]","fields":{"VAR":{"id":"N?o:_)gI%v:qMoTdDK3}","name":"car","type":"Car"}}}},"ARG0":{"shadow":{"type":"unit_percent","id":"qP{0iwt,H{]#fVY.!2+F","fields":{"VALUE0":50}},"block":{"type":"blockMathArithmetic","id":";|~g{SR=:PQ9N~]-oLE;","fields":{"OP":"MINUS"},"inputs":{"A":{"shadow":{"type":"blockMathNumber","id":"9t`X6Iq4$;G#@iTg1kAf","fields":{"NUM":1}},"block":{"type":"blockJoystickValue","id":"KCe/~Igl{lOj]y;|:zPN","fields":{"JOYSTICK":"XBOX_RT"},"inputs":{"VAR":{"shadow":{"type":"variables_get_gamepad","id":"rWy^~aM-oK3#%QMo9@)]","fields":{"VAR":{"id":"jO|qF()?HGJCju9#H|@j","name":"controller","type":"XboxController"}}}}}}},"B":{"shadow":{"type":"blockMathNumber","id":",ZJeGu5j/is]w/-j?v-k","fields":{"NUM":1}},"block":{"type":"blockJoystickValue","id":"}At`)tGf$m,y^=UIgKgc","fields":{"JOYSTICK":"XBOX_LT"},"inputs":{"VAR":{"shadow":{"type":"variables_get_gamepad","id":"JMyX.NUun;_JSNfS]F[h","fields":{"VAR":{"id":"jO|qF()?HGJCju9#H|@j","name":"controller","type":"XboxController"}}}}}}}}}}},"next":{"block":{"type":"blockCarSteer","id":"LK2khVSl+b:M_i(-avdQ","inputs":{"VAR":{"shadow":{"type":"variables_get_car_device","id":"RTR?tH8|$cNc4]c2QHNW","fields":{"VAR":{"id":"N?o:_)gI%v:qMoTdDK3}","name":"car","type":"Car"}}}},"VALUE0":{"shadow":{"type":"unit_percent","id":"I!FN])%J6VvXfJW$XlwZ","fields":{"VALUE0":0}},"block":{"type":"blockJoystickValue","id":"D;Q0R#_CDosKVXX%c[`6","fields":{"JOYSTICK":"XBOX_LJ_X"},"inputs":{"VAR":{"shadow":{"type":"variables_get_gamepad","id":"8up=nR.TaMD5=P@5R2?}","fields":{"VAR":{"id":"jO|qF()?HGJCju9#H|@j","name":"controller","type":"XboxController"}}}}}}}}}}}}}}}}]},"variables":[{"name":"red","id":"FzD$8|dNe|B#-2+Y.hdQ","type":"ColorDef"},{"name":"orange","id":"{of6uF9-$%Ft6U1VDf[Q","type":"ColorDef"},{"name":"yellow","id":"aKr)5Gf-6htFP?X%sbBO","type":"ColorDef"},{"name":"green","id":"WuP|e8`f=qfAVRiq19f2","type":"ColorDef"},{"name":"cyan","id":"}XXP6~EkM]eIFloyy2{d","type":"ColorDef"},{"name":"blue","id":"GxK}gQ$dvFo8D5[;mUiO","type":"ColorDef"},{"name":"violet","id":"WO-ukRlm7I.O6CxS~5(5","type":"ColorDef"},{"name":"magenta","id":"7%6im3e@o~v3Yf1Z9G81","type":"ColorDef"},{"name":"white","id":"/)?+7F;=2eSALN@0F)84","type":"ColorDef"},{"name":"none","id":"atL7YEXxu:k_%tXHmWx[","type":"ColorDef"},{"name":"car","id":"N?o:_)gI%v:qMoTdDK3}","type":"Car"},{"name":"controller","id":"jO|qF()?HGJCju9#H|@j","type":"XboxController"},{"name":"front","id":"Sfkt5!a|mBRd)veW}%@V","type":"Motor"},{"name":"rear","id":"VeQJ3bN/NZ@%t]W;@|j0","type":"Motor"},{"name":"steer","id":"g4h(Hwe2rwZ;t+I3jn}-","type":"Motor"}]}
2+
from pybricks.iodevices import XboxController
3+
from pybricks.parameters import Direction, Port
4+
from pybricks.pupdevices import Motor
5+
from pybricks.robotics import Car
6+
7+
# Set up all devices.
8+
front = Motor(Port.A, Direction.CLOCKWISE)
9+
rear = Motor(Port.B, Direction.CLOCKWISE)
10+
steer = Motor(Port.D, Direction.CLOCKWISE)
11+
car = Car(steer, [front, rear])
12+
controller = XboxController()
13+
14+
15+
# The main program starts here.
16+
while True:
17+
car.drive_power(controller.triggers()[1] - controller.triggers()[0])
18+
car.steer(controller.joystick_left()[0])
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from pybricks.iodevices import XboxController
2+
from pybricks.parameters import Direction, Port
3+
from pybricks.pupdevices import Motor
4+
from pybricks.robotics import Car
5+
6+
# Set up all devices.
7+
front = Motor(Port.A, Direction.CLOCKWISE)
8+
rear = Motor(Port.B, Direction.CLOCKWISE)
9+
steer = Motor(Port.D, Direction.CLOCKWISE)
10+
car = Car(steer, [front, rear])
11+
controller = XboxController()
12+
13+
14+
# The main program starts here.
15+
while True:
16+
17+
# Drive using the trigger inputs.
18+
brake, acceleration = controller.triggers()
19+
car.drive_power(acceleration - brake)
20+
21+
# Steer with the left joystick.
22+
horizontal, vertical = controller.joystick_left()
23+
car.steer(horizontal)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: "Xbox Controller"
3+
maintainer:
4+
user: "pybricks"
5+
name: "The Pybricks Team"
6+
image:
7+
local: "./audi-xbox.jpg"
8+
description: "Control the Technic Audi RS Q e-tron with the Xbox Controller."
9+
code: "#python-program"
10+
building_instructions:
11+
external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6508358.pdf
12+
video:
13+
youtube: "fxInp9cutNg"
14+
---
15+
16+
In this project we'll show you how to control the Audi RS Q e-tron with the
17+
Xbox Controller, using either block programming or Python.
18+
19+
Be sure to check out the documentation in the Pybricks app for instructions
20+
to pair the controller with the hub.
21+
22+
Note: This is brand a new feature. Try it with [Pybricks beta](https://beta.pybricks.com/)!
23+
24+
# Block Program
25+
26+
You can easily code this with the new block coding feature. Just drag and drop
27+
the blocks as shown below, or download the ready-made project here. In
28+
Pybricks, just go to the file menu and click the "Import a file" icon to open
29+
it.
30+
31+
<a href="./audi_blocks.py" target="_blank" class="btn btn--primary"><i class="fas fa-puzzle-piece"></i>&nbsp;&nbsp;Download block program</a>
32+
33+
![Xbox Block Program](audi-xbox-program.png)
34+
35+
# Python Program
36+
37+
{% include copy-code.html %}
38+
```python
39+
{% include_relative audi_python.py %}
40+
```

0 commit comments

Comments
 (0)