You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: programming/robot_api/comp_mode.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,4 +5,37 @@ title: Competition Mode
5
5
6
6
# Competition Mode
7
7
8
-
TODO
8
+
9
+
## What is Comp Mode
10
+
11
+
During a competition match a Competition Mode USB is inserted into a spare USB port on your robot (See the [kit assembly guide]({{ site.baseurl }}/tutorials/assembly) for details on the spare USB port you need to leave).
12
+
This will instruct your robot that it is in competition mode and will enable a game timeout, disable the WiFi and update certain `robot` attributes.
13
+
14
+
15
+
## Effects of Comp Mode
16
+
17
+
* Enabling Game timeout
18
+
19
+
When in competition mode the robot will automatically stop at the end of a match, where the duration of a match is defined in the [rules]({{ site.baseurl }}/tutorials/assembly).
20
+
The duration of the match is defined from when the start button is pressed.
21
+
22
+
* Disabling of WiFi and Web interface
23
+
24
+
During competition matches remote control of robots is forbidden ([rules]({{ site.baseurl }}/tutorials/assembly)), so the WiFi and web interface are disabled to ensure a fair game.
25
+
26
+
* Updating of match-specific `robot` attributes
27
+
28
+
Certain robot attributes will change when in comp mode, these can be used to change your robot's behaviour.
29
+
The affected attributes are:
30
+
31
+
mode
32
+
: Whether the robot is running in competition mode.
33
+
When in a competition match, this will be `COMP`, and at all other times this will be `DEV`.
34
+
35
+
zone
36
+
: The number of the scoring zone that the robot is associated with.
37
+
Between `0` and `3`.
38
+
39
+
The zone you are in defines which arena markers are near your scoring zone.
40
+
You can use the knowledge of your zone to compensate for this, so your robot behaves correctly in all starting positions.
41
+
See the [rules]({{ site.baseurl }}/tutorials/assembly) for where the scoring zones and arena markers are positioned.
Copy file name to clipboardExpand all lines: programming/robot_api/index.md
+56-63Lines changed: 56 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,126 +3,119 @@ layout: page
3
3
title: Robot API
4
4
---
5
5
6
-
Robot API
7
-
=========
6
+
# Robot API
8
7
9
8
Student Robotics has written a module —`sr.robot3`— which is used to interface with the hardware.
10
9
It handles all the low-level interactions so you don't have to.
11
-
To set the output power of output 0 of the first motor board to -30%, for example, you would simply write:
12
10
13
-
~~~~~python
14
-
R.motor_board.motors[0].power =-0.3
15
-
~~~~~
16
-
17
-
`-0.3` would be backwards (depending upon which way you wired up the motor) — 30% power in reverse.
18
-
19
-
To gain access to all of this functionality, all you need to do is write:
11
+
For example, to set the power of output 0 on a Motor Board to 30%, you would simply write:
20
12
21
13
~~~~~python
22
-
from sr.robot3 import*
14
+
robot.motor_board.motors[0].power =0.3
23
15
~~~~~
24
16
25
-
...at the top of your code (before you use any of its functionality, basically).
26
-
This imports the Student Robotics module that we've written to interface with our hardware.
17
+
<divclass="info"markdown="1">
18
+
See the [Motor Board]({{ site.baseurl }}/programming/motors) page for more details about this example.
19
+
</div>
27
20
28
-
Then, within the `sr.robot3` module, there is a `Robot` class that should be instantiated, as follows:
21
+
To gain access to all of this functionality, all you need to do at the top of your code is the following:
29
22
30
23
~~~~~python
31
24
from sr.robot3 import*
32
-
R= Robot()
25
+
robot= Robot()
33
26
~~~~~
34
27
35
-
Within your `Robot` (`R` in this case), you then have access to the following attributes:
28
+
This imports the Student Robotics module that we've written to interface with our hardware.
29
+
We then use the `Robot` class from within the `sr.robot3` module, to create a `robot` object that sets up and gives you access to your robot's hardware.
36
30
37
-
*[motors](/docs/programming/motors)
38
-
*[power](/docs/programming/power)
39
-
*[servos](/docs/programming/servos)
40
-
*[ruggeduinos](/docs/programming/arduino/)
41
-
*[vision](/docs/programming/vision/)
31
+
<divclass="info"markdown="1">
32
+
Most examples in the documentation will assume you have created a `robot` object from the `Robot` class.
33
+
If you see `robot` in a code example, it is assumed you have run the two lines above.
34
+
</div>
42
35
43
-
They can be used in your code just like the example above.
44
-
Note that `motors`, `ruggeduinos`, and `servos` are Python lists, and so should be accessed as such.
45
-
Here are some examples:
36
+
Then, within your `robot` you can use the following attributes to access to the robot's hardware:
46
37
47
-
~~~~~python
48
-
R.motor_board.motors[0].power =0.5# WILL work, if motor 0 exists
49
-
R.motor_board.motors[1].power =-0.2# WILL work, if motor 1 exists
0 commit comments