P1 Exercise 1 - Introduction ============================ The aim of these exercises is to get you familiar with the basic concepts of programming which are fundamental to any programming language, namely **variables**, **events**, **conditionals**, and **loops**. Although robotics is not only about programming, it involves mechanical engineering, electrical engineering, control theory, and lots more, but programming is figuratively the glue that holds the system together and allows the robot to perform complex behaviors. If you are already familiar with the basic programming concepts, then this section (P1 Exercise 1-5) can still help you out in solving the tasks in the later section. Yet if you are new to programming, then this section will hopefully provide you the tools to get you going. Getting to Know the iRobot Root Environment ------------------------------------------- This practice session will be based on iRobot Root RT1 simulation. It is very simplistic and maybe even child-like, but don't be fooled about it's appearence. This environment is enough to learn and test the basic concepts of programming that are essential in robotics. * Link to the environment: https://code.irobot.com * Introductory video about the environment: https://edu.irobot.com/learning-library/getting-started-with-root .. note:: The web environment may take some time to load and you can ingnore the warnings about the lack of bluetooth support (firefox) Starting a New Project ~~~~~~~~~~~~~~~~~~~~~~ Project is where you keep your code. For example if you go through the exercises, then each exercise can be in its own project. Also each solution to the later tasks (P1 Task 1-3) must be in its own project. See figure 1.1 for a reference on how to create a new project. .. figure:: /figures/irobot_root/p1_e1_1.gif :width: 650px :align: center **Figure. 1.1:** Start a new project in the iRobot Root RT1 simulation environment. Downloading an Existing Project ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you follow the exercises, you will notice that **there is a five digit code under each figure**. With this five digit code you can **download the shown example into your own project workspace** and play around with it. See figure 1.2 for a reference on how to download other projcets. .. figure:: /figures/irobot_root/p1_e1_2.gif :width: 650px :align: center **Figure. 1.2:** Download an existing project in the iRobot Root RT1 simulation environment. Uploading Your Project ~~~~~~~~~~~~~~~~~~~~~~ After you finish with the exercises, you need to solve the three tasks (P1 Task 1-3). Each task must be in its own project and you have to upload them and **submit the five digit project code in moodle**. See figure 1.3 for a reference on how to upload projects. .. figure:: /figures/irobot_root/p1_e1_3.gif :width: 650px :align: center **Figure. 1.3:** Exporting and sharing your project in the iRobot Root RT1 simulation environment. Explore the Environment ~~~~~~~~~~~~~~~~~~~~~~~ Please do explore this programming environment (figure 1.4) and for further explanations see `this tutorial video `_. You can start simple on level 1 but all the examples are going to be on programming level 3, as it is more flexible than level 1 and more close to industrial programming languages compared to level 2. Try out the motion primitives - forward, backward, rotate left, rotate right. Everything can be clicked and dragged. If you want to erase a block, you can just click it and drag it to the dumpster icon which appears below. The further tutorials do provide examples of different functions that this environment has to offer, but not all will be covered that you might find useful when solving the obligatory tasks. So please, explore! Try to move the robot, try to draw a line (set ``markerDown``), see what happens if you click on different numbers and values, etc. .. figure:: /figures/irobot_root/p1_e1_4.gif :width: 650px :align: center **Figure. 1.4:** Explore the iRobot Root RT1 simulation environment.