Let’s code your first simulation robot in SoccerSim! First, open up the Blocks editor.
You can write Blocks programs for each of the blue robots, and use different blocks to loop forever, check the ball angle, or move the motors.
The most common and useful blocks are:
The best way to start is to try get the robot moving!
First, place a ‘repeat forever’ block (Control) into the workspace. This means that our robot is always going to repeatedly move and react to the ball. We also should set the starting position for the robot, meaning we should use a ‘set starting position’ block (Events) at the very beginning of our program.
Let’s make our robot move forward. Add two ‘set motor speed’ blocks (Motors) - one for motor A (left) and motor B (right). Change the speeds to 50.
Then hit the green Run all button! You should see the robot move forward. You can click and drag on the robot to move it back. To rotate the robot, click and drag on the robot’s wheels.
To stop the robot, click the red ‘Stop all’ button.
If we want to rotate on the spot, we can easily set one of the motors to be a negative value. The motor speeds can be between -100 and 100.
If we set the left wheel to -50, and the right wheel to 50, then it will rotate anti-clockwise.