diff --git a/01_IntroductionToPython/01_Tutorial_PythonIntroduction.ipynb b/01_IntroductionToPython/Tutorial/01_Tutorial_PythonIntroduction.ipynb similarity index 100% rename from 01_IntroductionToPython/01_Tutorial_PythonIntroduction.ipynb rename to 01_IntroductionToPython/Tutorial/01_Tutorial_PythonIntroduction.ipynb diff --git a/01_IntroductionToPython/Tutorial/README.md b/01_IntroductionToPython/Tutorial/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7927a7a3c41fa1c5e4dab18eef8f34ee97f252d2 --- /dev/null +++ b/01_IntroductionToPython/Tutorial/README.md @@ -0,0 +1,32 @@ +## 01 Tutorial: Introduction to Python + +The task for this tutorial can be found in the [01_Tutorial_PythonIntroduction jupyter notebook](01_Tutorial_PythonIntroduction.ipynb). Following, the steps how to import the jupyter notebook to [jupyter hub](https://jupyter.rwth-aachen.de/hub/login). + +1. Download the [01_Tutorial_PythonIntroduction jupyter notebook](https://git.rwth-aachen.de/introduction-to-robotics-course/introduction-to-robotics-2023/-/blob/main/01_IntroductionToPython/01_Tutorial_PythonIntroduction.ipynb). + +  + +2. Open the [RWTH JupyterHub](https://jupyter.rwth-aachen.de/hub/login) website and sign in using RWTH Single Sign-On. + +  + +3. Inside RWTH JupyterHub create a new folder named **i2r**. + +  + +4. Upload the [01_Tutorial_PythonIntroduction jupyter notebook](01_Tutorial_PythonIntroduction.ipynb) and the [forward_kinematics module](forward_kinematics.py) to the **i2r** folder. + +  + +5. You can open the file by just double-click the file name in the file browser. + +  + +6. To run/execute the code you implemented in a cell, click into that cell and click the ***Run the selected cells and advance*** button like show below. + +  + +7. Once you made changes inside the file **forward_kinematics.py** make sure to save the file (Press `Ctrl` + `S` (on a german keyboard `Strg` + `S`)) and click on ***Restart the kernal, then re-run the whole notebook*** inside of the notebook from which you are calling a function of the module. + +  + diff --git a/01_IntroductionToPython/Tutorial/forward_kinematics.py b/01_IntroductionToPython/Tutorial/forward_kinematics.py new file mode 100644 index 0000000000000000000000000000000000000000..3f50df7ca14e62a782e1edac4efa01926e51d24a --- /dev/null +++ b/01_IntroductionToPython/Tutorial/forward_kinematics.py @@ -0,0 +1,77 @@ +# This Python file contains different functions we implemented to perform forward kinematics +# +# First we have to make sure to import the modules with the functions we need for the functions. +# Here we just need the 'math' module which includes among others the following functions: +# - cos(x): returns cosine of x in radians +# - sin(x): returns sine of x in radians +# - radians(x): converts x from degree to radians + +import math + +# Here we define the function of the name 'forward_kinematics_nLinks_2'. +# For an elbow manipulator in planar space with 2 DoF the function calculates +# the coordinates of the end effector joint. +# The function has to be called with the follwing arguments: +# - a_1: length of link 1 +# - a_2: lenght of link 2 +# - theta_1: rotation of joint 1 +# - theta_2: rotation of joint 2 +# The function returns the x and y coordinate of the end effector joint. +def forward_kinematics_nLinks_2(a_1, a_2, theta_1, theta_2): + + x = a_1 * math.cos(math.radians(theta_1)) + a_2 * math.cos(math.radians(theta_1 + theta_2)) + y = a_1 * math.sin(math.radians(theta_1)) + a_2 * math.sin(math.radians(theta_1 + theta_2)) + + return x, y + +# Here we define the function of the name 'forward_kinematics'. +# For an elbow manipulator in planar space with n DoF the function calculates +# the coordinates of the end effector joint. +# The function has to be called with the follwing arguments: +# - x_0: x coordinate of the refernce coordinate frame +# - y_0: y coordinate of the reference coordinate frame +# - list_a: list with the lenghts [a_1, a_2, ..., a_n] of the links +# - list_theta: list with the rotations [theta_1, theta_2, ..., theta_n] of the joints +# The function returns the x and y coordinate of the end effector joint. +def forward_kinematics(x_0, y_0, list_a, list_theta): + x = x_0 + y = y_0 + sum_theta = 0 + # The zip() function takes iterables (can be zero or more), aggregates them in a tuple, and returns it. + for a, theta in zip(list_a, list_theta): + sum_theta = sum_theta + theta + x = x + a * math.cos(math.radians(sum_theta)) + y = y + a * math.sin(math.radians(sum_theta)) + + return x, y + + +# Here we define the function of the name 'fk_getJointCoords'. +# For an elbow manipulator in planar space with n DoF the function calculates +# the coordinates of the joints. +# The function has to be called with the follwing arguments: +# - x_0: x coordinate of the refernce coordinate frame +# - y_0: y coordinate of the reference coordinate frame +# - list_a: list with the lenghts [a_1, a_2, ..., a_n] of the links +# - list_theta: list with the rotations [theta_1, theta_2, ..., theta_n] of the joints +# The function returns two lists. 'joint_x_coords' contains the x coordinates of the joints and +# 'joint_y_coords' contains the y coordinates of the joints. +# This function is used to be able to plot the resulting elbow manipulator configuration. +def fk_getJointCoords(x_0, y_0, list_a, list_theta): + x = x_0 + y = y_0 + sum_theta = 0 + + joint_x_coords = [x_0] + joint_y_coords = [y_0] + + # The zip() function takes iterables (can be zero or more), aggregates them in a tuple, and returns it. + for a, theta in zip(list_a, list_theta): + sum_theta = sum_theta + theta + x = x + a * math.cos(math.radians(sum_theta)) + y = y + a * math.sin(math.radians(sum_theta)) + joint_x_coords.append(x) + joint_y_coords.append(y) + + return joint_x_coords, joint_y_coords + \ No newline at end of file diff --git a/01_IntroductionToPython/Tutorial/media/creating_folder.gif b/01_IntroductionToPython/Tutorial/media/creating_folder.gif new file mode 100644 index 0000000000000000000000000000000000000000..c22eefc2681829b604e6740c5348dfeb921bc0bc Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/creating_folder.gif differ diff --git a/01_IntroductionToPython/Tutorial/media/creating_folder.webm b/01_IntroductionToPython/Tutorial/media/creating_folder.webm new file mode 100644 index 0000000000000000000000000000000000000000..a15ea4d3911df94ee9b5b14c5b3f92b032827392 Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/creating_folder.webm differ diff --git a/01_IntroductionToPython/Tutorial/media/download_jupyter_notebook.gif b/01_IntroductionToPython/Tutorial/media/download_jupyter_notebook.gif new file mode 100644 index 0000000000000000000000000000000000000000..076ec0e099d9b5299242611d1227c27ed35a9780 Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/download_jupyter_notebook.gif differ diff --git a/01_IntroductionToPython/Tutorial/media/download_jupyter_notebook.webm b/01_IntroductionToPython/Tutorial/media/download_jupyter_notebook.webm new file mode 100644 index 0000000000000000000000000000000000000000..0a7412f6649bad609df74a7d1f5a6852eb12fdb2 Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/download_jupyter_notebook.webm differ diff --git a/01_IntroductionToPython/Tutorial/media/import_files.gif b/01_IntroductionToPython/Tutorial/media/import_files.gif new file mode 100644 index 0000000000000000000000000000000000000000..3e184c8187269439705dfc840927bfb7a533222c Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/import_files.gif differ diff --git a/01_IntroductionToPython/Tutorial/media/import_files.webm b/01_IntroductionToPython/Tutorial/media/import_files.webm new file mode 100644 index 0000000000000000000000000000000000000000..a68708df1817b5af0f3ec1419a318fa868e016eb Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/import_files.webm differ diff --git a/01_IntroductionToPython/Tutorial/media/jupyter_hub_rwth_login.png b/01_IntroductionToPython/Tutorial/media/jupyter_hub_rwth_login.png new file mode 100644 index 0000000000000000000000000000000000000000..a79090e2901ba58c116afd1f53c21e193e570171 Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/jupyter_hub_rwth_login.png differ diff --git a/01_IntroductionToPython/Tutorial/media/login_jupyterHub.gif b/01_IntroductionToPython/Tutorial/media/login_jupyterHub.gif new file mode 100644 index 0000000000000000000000000000000000000000..7bf6a45614ebcdface0657b7607fa2a54ce58000 Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/login_jupyterHub.gif differ diff --git a/01_IntroductionToPython/Tutorial/media/login_jupyterHub.webm b/01_IntroductionToPython/Tutorial/media/login_jupyterHub.webm new file mode 100644 index 0000000000000000000000000000000000000000..dbb7fd28b09bb2cd4b460e3d195e912741fb3813 Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/login_jupyterHub.webm differ diff --git a/01_IntroductionToPython/Tutorial/media/opening_files.gif b/01_IntroductionToPython/Tutorial/media/opening_files.gif new file mode 100644 index 0000000000000000000000000000000000000000..36a6ab9c8b35ca9f8209fbbfe2434c930e85955c Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/opening_files.gif differ diff --git a/01_IntroductionToPython/Tutorial/media/opening_files.webm b/01_IntroductionToPython/Tutorial/media/opening_files.webm new file mode 100644 index 0000000000000000000000000000000000000000..2bf32e483666077131b7f5b4f362c11eb0155555 Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/opening_files.webm differ diff --git a/01_IntroductionToPython/Tutorial/media/palette.png b/01_IntroductionToPython/Tutorial/media/palette.png new file mode 100644 index 0000000000000000000000000000000000000000..e29ad3f1b21772516447668f0396a0cfb593c04b Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/palette.png differ diff --git a/01_IntroductionToPython/Tutorial/media/restart_kernal.gif b/01_IntroductionToPython/Tutorial/media/restart_kernal.gif new file mode 100644 index 0000000000000000000000000000000000000000..beda3f29ddd43ec032d75889d171f611cdf30d45 Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/restart_kernal.gif differ diff --git a/01_IntroductionToPython/Tutorial/media/restart_kernal.webm b/01_IntroductionToPython/Tutorial/media/restart_kernal.webm new file mode 100644 index 0000000000000000000000000000000000000000..85d55467560da39f890c680dd8f628e3f29bd9f6 Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/restart_kernal.webm differ diff --git a/01_IntroductionToPython/Tutorial/media/run_a_cell.gif b/01_IntroductionToPython/Tutorial/media/run_a_cell.gif new file mode 100644 index 0000000000000000000000000000000000000000..45e7abb6b202d5166f92ea45f373443960bb542c Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/run_a_cell.gif differ diff --git a/01_IntroductionToPython/Tutorial/media/run_a_cell.webm b/01_IntroductionToPython/Tutorial/media/run_a_cell.webm new file mode 100644 index 0000000000000000000000000000000000000000..e04a7fa887fc283e97847d91a55b05a90faca74f Binary files /dev/null and b/01_IntroductionToPython/Tutorial/media/run_a_cell.webm differ diff --git a/01_IntroductionToPython/__pycache__/forward_kinematics.cpython-310.pyc b/01_IntroductionToPython/__pycache__/forward_kinematics.cpython-310.pyc index 988e82bddce7827c11f452f838c0d2a4366b137a..94fdd675fff753b22769f7f4bd3adef7c5c4e6fb 100644 Binary files a/01_IntroductionToPython/__pycache__/forward_kinematics.cpython-310.pyc and b/01_IntroductionToPython/__pycache__/forward_kinematics.cpython-310.pyc differ