diff --git a/_data/sidebar_tree.yaml b/_data/sidebar_tree.yaml index 103ccaff..da5aac1c 100644 --- a/_data/sidebar_tree.yaml +++ b/_data/sidebar_tree.yaml @@ -41,6 +41,8 @@ tree: title: PyCharm - url: /tutorials/editors/vscode title: Visual Studio Code + - url: /tutorials/editors/remote-debug + title: VS Code Remote Debugging - url: /tutorials/update_brain title: Updating your brain board - url: /tutorials/discord @@ -139,8 +141,8 @@ tree: - url: /competitor_resources/ title: Resources tree: - - url: /competitor_resources/pre_kickstart_activities - title: Pre-Kickstart Activities + - url: /competitor_resources/simulator_activities + title: Simulator Activities - url: /competitor_resources/microgames title: Microgames - url: /competitor_resources/markers diff --git a/competitor_resources/pre_kickstart_activities.md b/competitor_resources/pre_kickstart_activities.md deleted file mode 100644 index 84b45f15..00000000 --- a/competitor_resources/pre_kickstart_activities.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: page -title: Pre-Kickstart Activities ---- - -# Pre-Kickstart Activities - -The pre-Kickstart activities were first included for SR2025 to introduce the concepts of autonomous robotics that can be completed prior to receiving your kit or this year's game being announced. They use our simulator for a set of activities intended to be completed between registration and Kickstart. These will teach some core concepts of robotics and introduce some basic sensors that teams could use on their physical robots. - -We recommend you work through them as a team, so you can learn from each other. -If you have any issues, just ask us on [Discord](/docs/tutorials/discord). - -This year's activities will be available shortly and we will contact all team supervisors when they are released. - -## The Simulated Robot - -The robot used for the pre-Kickstart activities differs from the robot used in the regular simulator to have more of a focus on sensing the environment around the robot and lacks any mechanisms for picking up other objects. - -All sensors attached to the Arduino are the same, but there are no servos on this robot. diff --git a/competitor_resources/simulator_activities.md b/competitor_resources/simulator_activities.md new file mode 100644 index 00000000..5ec891a3 --- /dev/null +++ b/competitor_resources/simulator_activities.md @@ -0,0 +1,32 @@ +--- +redirect_from: + - /competitor_resources/pre_kickstart_activities +layout: page +title: Simulator Activities +--- + +# Simulator Activities + +We have created a set of activities to introduce the concepts of autonomous robotics that can be completed without a kit or this year's game being announced. +They use a special version of our simulator for a set of activities intended to be completed between registration and Kickstart. +These will teach some core concepts of robotics and introduce some basic sensors that teams could use on their physical robots. + +We recommend you work through them as a team, so you can learn from each other. +If you have any issues, just ask us on [Discord]({{ site.baseurl}}/tutorials/discord). + +You can access the [the activities here](https://drive.google.com/file/d/1HdddMfZFeciXrP_EHFU5HUefce51VO_7/preview). + +## The Simulated Robot + +The robot used for the simulator activities differs from the robot used in the regular simulator to have more of a focus on sensing the environment around the robot and lacks any mechanisms for picking up other objects. + +All sensors attached to the Arduino are the same, but there are no servos on this robot. + +## Example Game: Tin Can Rally + +To allow us to demonstrate the utility of various sensors, the simulator is set up for a game called Tin Can Rally. +In this game, the robot must navigate around a course avoiding the tin cans placed around the course. + +Below is the diagram of the arena: + +![arena diagram]({{ site.baseurl}}/resources/simulator/fig-arena.svg) diff --git a/resources/2026/sr-markers-sr2026.pdf b/resources/2026/sr-markers-sr2026.pdf new file mode 100644 index 00000000..087d28ae Binary files /dev/null and b/resources/2026/sr-markers-sr2026.pdf differ diff --git a/resources/simulator/fig-arena.svg b/resources/simulator/fig-arena.svg new file mode 100644 index 00000000..422389ac --- /dev/null +++ b/resources/simulator/fig-arena.svg @@ -0,0 +1,413 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100 + 101 + + 100 + 101 + + 102 + 103 + + 102 + 103 + + 104 + 105 + + 104 + 105 + + 106 + 107 + + 106 + 107 + + + + 1220mm + + + + 1220mm + + + + 610mm + + + 1480mm + + + 1220mm + + + 1220mm + + + 380mm + + + 460mm + + + 600mm + + + + + 610mm + + + + + 150mm + + + + 740mm + + + + 1220mm + + + 750mm + + + + 370mm + + + + 370mm + + + 5400mm + + + 5400mm + + + + + + Robot starting area + + + Can + + + 2 + Marker (with ID) + + + + Scoring Line + + + Inner wall + + + + + Line follow guide + + diff --git a/resources/simulator/sim_activities_code.txt b/resources/simulator/sim_activities_code.txt new file mode 100644 index 00000000..a7f5e75d --- /dev/null +++ b/resources/simulator/sim_activities_code.txt @@ -0,0 +1,141 @@ +## Student Robotics Simulator Activities Code ## +## To use each segment of code, copy it into a robot.py file ## +############################################################### + +#### 3. Making a Move #### + +from sr.robot3 import Robot + +#Create the robot object +robot = Robot() + +#set the left motor to 50% power and right motor to 0% power +robot.motor_board.motors[0].power = 0.5 +robot.motor_board.motors[1].power = 0 +#Robot power goes off at end of code, so wait for 1 second +robot.sleep(1) + +#### 3.1. Open Loop Control #### + +from sr.robot3 import Robot + +robot = Robot() + +#Go forward and backward at 50% power for 1 second 10 times, ending at the starting point +for i in range(10): + robot.motor_board.motors[0].power = 0.5 + robot.motor_board.motors[1].power = 0.5 + robot.sleep(1) + robot.motor_board.motors[0].power = -0.5 + robot.motor_board.motors[1].power = -0.5 + robot.sleep(1) + +#### 4.2. Bump Switches #### + +from sr.robot3 import Robot + +robot = Robot() + +#pin 11 is the front right microswitch +#Consult the docs for the other switch pins +frontright = robot.arduino.pins[11].digital_read() + +#### 4.3. Ultrasound Distance Sensors #### + +from sr.robot3 import Robot + +robot = Robot() + +def set_motors(left,right): + robot.motor_board.motors[0].power = left + robot.motor_board.motors[1].power = right + +set_motors(0.2,0.2) +while True: + distance_left = robot.arduino.ultrasound_measure(4, 5) #This is the left sensor + print(distance_left) + +#### 4.4. Infrared Reflectance Sensors #### + +from sr.robot3 import Robot, A0, A1, A2 + +robot = Robot() + +while True: + left_IR = robot.arduino.pins[A0].analog_read() + centre_IR = robot.arduino.pins[A1].analog_read() + right_IR = robot.arduino.pins[A2].analog_read() + print(left_IR, centre_IR, right_IR) + +#### 4.4.1. Finite State Machines (Bang Bang Control) #### + +from sr.robot3 import Robot, A0, A1, A2 + +robot = Robot() + +def set_motors(left,right): + robot.motor_board.motors[0].power = left + robot.motor_board.motors[1].power = right + +def set_state(state): + if state == "forward": + set_motors(0.2,0.2) + elif state == "left": + set_motors(0,0) #Add your code here for left and right + +while True: + left_IR = robot.arduino.pins[A0].analog_read() + centre_IR = robot.arduino.pins[A1].analog_read() + right_IR = robot.arduino.pins[A2].analog_read() + print(left_IR, centre_IR, right_IR) + if left_IR < 1.2 and centre_IR > 3.5 and right_IR < 1.2: + current_state="forward" + #Add your code here for left and right + set_state(current_state) + +#### 4.5. Vision System #### + +from sr.robot3 import Robot + +robot = Robot() + +while True: + markerlist = robot.camera.see() + print(markerlist) + robot.sleep(1) + +#### 4.5.1. What's in a Marker? #### + +from sr.robot3 import Robot, A0, A1, A2 + +robot = Robot() + +target_id = 100 + +#Helper to set both motors +def set_motors(left,right): + robot.motor_board.motors[0].power = left + robot.motor_board.motors[1].power = right + +#Helper to find the target marker in the list of markers +def find_target(markerlist, target): + for marker in markerlist: + if marker.id == target: + return marker + return None + +while True: + markerlist = robot.camera.see() + targetmarker = find_target(markerlist, target_id) + if targetmarker != None: + angle_error = targetmarker.position.horizontal_angle + if angle_error > 0.2: #target is on the right, 0.2 radians is about 11° + set_motors(0.1,-0.1) + elif angle_error < -0.2: #target is on the left + set_motors(-0.1,0.1) + else: #target is straight ahead + set_motors(0.2,0.2) + robot.sleep(0.2) + set_motors(0,0) #stop to take a new photo + else: #can't see the target + set_motors(0,0) diff --git a/simulator/setting_up_simulator.md b/simulator/setting_up_simulator.md index dde17439..41dd3522 100644 --- a/simulator/setting_up_simulator.md +++ b/simulator/setting_up_simulator.md @@ -9,11 +9,14 @@ Setting up the Simulator ## Required Software In order to use the simulator a few set-up steps need to be done. -First you need to install Python 3, between 3.9 and 3.12, and Webots R2025a. -Python 3.13 is not currently supported by the simulator. +First you need to install Python 3, between 3.10 and 3.13, and Webots R2025a. +Python 3.14 is not currently supported by the simulator. -To install Python, you can download the latest version from the [Python website](https://www.python.org/downloads/). If you have already installed Python from a package manager, such as homebrew on MacOS, apt on Ubuntu, or the Windows store on Windows, you can skip this step. -![python download site]({{ site.baseurl }}/images/content/simulator/python-download.png) +To install an appropriate version of Python from below. If you have already installed Python from a package manager, such as homebrew on MacOS, apt on Ubuntu, or the Windows store on Windows, you can skip this step, however please ensure the versions are compatible.. + +- [MacOS Installer](https://www.python.org/ftp/python/3.11.8/python-3.11.8-macos11.pkg) +- [Windows x86 Installer](https://www.python.org/ftp/python/3.11.8/python-3.11.8-amd64.exe) +- [Windows ARM Installer](https://www.python.org/ftp/python/3.11.8/python-3.11.8-arm64.exe) We recommend using **Python 3.11** as it is the version which is used on your physical robot. @@ -22,11 +25,11 @@ To install Webots, you can download the latest version from the [Webots website] ## Simulator Bundle -Once you have installed these, you need to download our simulator bundle. The bundle for the main competition will be released at Kickstart. +Once you have installed these, you need to download our [simulator bundle](https://github.com/srobo/sbot_simulator/releases/download/2026.1.0/sbot-simulator-2026.1.0.zip). The bundle for the main competition will be released at Kickstart. This is a zip file containing the arena and the necessary files to allow the sr-robot3 library to be used in the simulator.
-The simulator bundle used for the [Pre-Kickstart Activities]({{ site.baseurl }}/competitor_resources/pre_kickstart_activities) is available [here](https://github.com/srobo/sbot_simulator/releases/download/2026.0.1/sbot-simulator-2026.0.1.zip). +The simulator bundle used for the [Simulator Activities]({{ site.baseurl }}/competitor_resources/pre_kickstart_activities) is available [here](https://github.com/srobo/sbot_simulator/releases/download/2026.0.2/sbot-simulator-2026.0.2.zip).
Once this has downloaded, extract the contents to an empty folder. diff --git a/tutorials/assembly.md b/tutorials/assembly.md index 01f2c47c..edffd7d8 100644 --- a/tutorials/assembly.md +++ b/tutorials/assembly.md @@ -43,7 +43,7 @@ Board | Power In order to connect the Brain, Motor and Servo Boards to the Power Board, you will need to create some power cables. This should be done using the provided red and black _power wire_ (this is the thicker wire provided in the kit) and a pair of green CamCon connectors. The blue power wire should only be used to connect motors to the motor board. -_Remember you **must** use black wire for any ground connections as defined in the [Rules](/docs/rules)._ +_Remember you **should** use black wire for any ground connections as this will make debugging issues later much easier._ When creating your power cables be sure to refer to the pages for each board so that you connect the wires the right way around. In our diagrams, the + outputs from the the Power Board should be connected to the + inputs on the board being powered. diff --git a/tutorials/editors/remote-debug.md b/tutorials/editors/remote-debug.md new file mode 100644 index 00000000..7806cac7 --- /dev/null +++ b/tutorials/editors/remote-debug.md @@ -0,0 +1,53 @@ +--- +layout: page +title: VS Code Remote Debugging +--- +# VS Code Remote Debugging + +When connected to the [robot's WiFi hotspot]({{ site.baseurl }}/kit/brain_board/web_interface), it is possible to attach VS Code's +debugger to the robot by performing the following steps: + +1. Ensure the [Python extension]({{ site.baseurl }}/tutorials/editors/vscode#python-extension) is installed. +2. Open the Run and Debug panel. +3. Click the cog icon at the top of the panel. +4. Paste the following configuration: +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Robot", + "type": "python", + "request": "attach", + "connect": { + "host": "robot.lan", + "port": 5678 + }, + "pathMappings": [ + { + "localRoot": "${workspaceFolder}", + "remoteRoot": "." + } + ], + "justMyCode": true + } + ] +} +``` +5. Add the following snippet to the top of your code: +```python +import debugpy +debugpy.listen(("0.0.0.0", 5678)) +``` + +If you would like for your code to not run until the debugger is attached, you can also add the following: +```python +print("Waiting for debugger...") +debugpy.wait_for_client() +``` + +6. In order to debug, you can now either click the green play button at the top of the Run and Debug panel or press F5. + +For more information on debugging with Visual Studio Code, please visit the [VS Code documentation][vs-code-debug-docs] + +[vs-code-debug-docs]: https://code.visualstudio.com/Docs/editor/debugging diff --git a/tutorials/editors/vscode.md b/tutorials/editors/vscode.md index 83919fa2..c75e4c61 100644 --- a/tutorials/editors/vscode.md +++ b/tutorials/editors/vscode.md @@ -37,53 +37,3 @@ you'll need to make the library available within the Python environment that you 3. Run `pip install sr.robot3`. [code-completion]: https://en.wikipedia.org/wiki/Autocomplete#In_source_code_editors - -## Remote Debugging - -When connected to the [robot's WiFi hotspot]({{ site.baseurl }}/kit/brain_board/web_interface), it is possible to attach VS Code's -debugger to the robot by performing the following steps: - -1. Ensure the [Python extension](#python-extension) is installed. -2. Open the Run and Debug panel. -3. Click the cog icon at the top of the panel. -4. Paste the following configuration: -```json -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Attach to Robot", - "type": "python", - "request": "attach", - "connect": { - "host": "robot.lan", - "port": 5678 - }, - "pathMappings": [ - { - "localRoot": "${workspaceFolder}", - "remoteRoot": "." - } - ], - "justMyCode": true - } - ] -} -``` -5. Add the following snippet to the top of your code: -```python -import debugpy -debugpy.listen(("0.0.0.0", 5678)) -``` - -If you would like for your code to not run until the debugger is attached, you can also add the following: -```python -print("Waiting for debugger...") -debugpy.wait_for_client() -``` - -6. In order to debug, you can now either click the green play button at the top of the Run and Debug panel or press F5. - -For more information on debugging with Visual Studio Code, please visit the [VS Code documentation][vs-code-debug-docs] - -[vs-code-debug-docs]: https://code.visualstudio.com/Docs/editor/debugging