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: + + 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 @@ + + + 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. - +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.