lego_2link_arm
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lego_2link_arm [2019/03/07 19:07] – ntorresreyes | lego_2link_arm [2019/03/08 07:14] (current) – [Theoretical Background] ntorresreyes | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | s====== LEGO 2-Link Robot Arm Tutorial ====== | + | ====== LEGO 2-Link Robot Arm Tutorial ====== |
**Author:** Norberto Torres-Reyes Email: torresre@unlv.nevada.edu | **Author:** Norberto Torres-Reyes Email: torresre@unlv.nevada.edu | ||
Line 8: | Line 8: | ||
\\ | \\ | ||
+ | {{: | ||
=====Motivation and Audience===== | =====Motivation and Audience===== | ||
+ | |||
+ | |||
This tutorial is for anyone who wishes to create a 2-link robotic arm using LEGO Mindstorm to reinforce theoretical knowledge about 2-link planar mechanisms. Readers of this tutorial are recommended to have the following background and interests: | This tutorial is for anyone who wishes to create a 2-link robotic arm using LEGO Mindstorm to reinforce theoretical knowledge about 2-link planar mechanisms. Readers of this tutorial are recommended to have the following background and interests: | ||
Line 22: | Line 25: | ||
*Interests in robotics | *Interests in robotics | ||
\\ | \\ | ||
- | * | + | *Experience with Solidworks |
</fc> | </fc> | ||
\\ | \\ | ||
Line 32: | Line 35: | ||
*[[lego_2link_arm# | *[[lego_2link_arm# | ||
*[[lego_2link_arm# | *[[lego_2link_arm# | ||
- | *[[lego_2link_arm# | ||
+ | ====Parts List==== | ||
+ | {{: | ||
- | ====Parts List==== | + | LEGO NXT parts list is given in full detail |
- | LEGO NXT parts list is given in full detail | + | |
====Theoretical Background==== | ====Theoretical Background==== | ||
- | The theoretical background needed for this tutorial can be fully covered | + | {{: |
+ | \\ | ||
+ | The theoretical background needed for this tutorial can be fully covered | ||
====Build Plans==== | ====Build Plans==== | ||
+ | A few different build plans are available. This includes photographic and 3D model based plans as well as a Solidworks based build plan. The reader may wish recreate the model in both Solidworks and with LEGO parts to familiarize themselves the procedures. The build plans are organized below: | ||
+ | \\ | ||
+ | *{{: | ||
+ | \\ | ||
+ | *{{: | ||
+ | \\ | ||
+ | *{{: | ||
+ | \\ | ||
+ | Solidworks Files: | ||
+ | {{: | ||
+ | \\ | ||
+ | Assembly Video | ||
+ | \\ | ||
+ | {{: | ||
+ | ====NXT Brick Code==== | ||
+ | 'Bricx Command Center' | ||
+ | \\ | ||
+ | ---- | ||
+ | < | ||
+ | // -------------------------------------------------------------------------// | ||
+ | // Inverse Kinematics for 2R planar manipulator with a closed-form solution // | ||
+ | // Created By: Sangsin Park, Ph. D. // | ||
+ | // Modified By: Norberto Torres-Reyes | ||
+ | // March 07 2019 // | ||
+ | // -------------------------------------------------------------------------// | ||
+ | // Motor' | ||
+ | #define JNT1 OUT_A | ||
+ | #define JNT2 OUT_B | ||
+ | #define FULL_SPEED (100) | ||
+ | // Gear's constants | ||
+ | #define gearRatio1 (2)*(56/ | ||
+ | #define gearRatio2 (3)*(-1) | ||
+ | // Links' constants | ||
+ | #define L1 (12) | ||
+ | #define L2 (10.4) | ||
- | ====NXT Brick Code==== | + | // Global variables |
+ | float theta1_ik | ||
+ | float theta2_ik | ||
+ | // Function declarations | ||
+ | bool IK_2R_Planar_closed(float px, float py); | ||
+ | |||
+ | task main() | ||
+ | { | ||
+ | // button variables | ||
+ | bool orangeBtnPushed = FALSE; | ||
+ | bool l_ArrowBtnPushed = FALSE; | ||
+ | bool r_ArrowBtnPushed = FALSE; | ||
+ | bool greyBtnPushed = FALSE; | ||
+ | |||
+ | int cnt_OrangeBtn = 0; | ||
+ | int cnt_l_ArrowBtn = 0; | ||
+ | int cnt_r_ArrowBtn = 0; | ||
+ | |||
+ | // reference joint angles | ||
+ | float theta1 = 0; | ||
+ | float theta2 = 0; | ||
+ | |||
+ | float px =12.0 ; | ||
+ | float py = 16.0; | ||
+ | bool IK_ok = FALSE; | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | // Code here for going to home postion after orange button is pushed // | ||
+ | |||
+ | | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | | ||
+ | { | ||
+ | | ||
+ | IK_ok = IK_2R_Planar_closed(px, | ||
+ | | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | bool IK_2R_Planar_closed(float px, float py) | ||
+ | { | ||
+ | float c2 = (px*px + py*py - L1*L1 - L2*L2)/ | ||
+ | float s2 = -sqrt(1 - c2*c2); | ||
+ | float c1 = (px*(L1 + L2*c2) + py*L2*s2)/ | ||
+ | float s1 = (py*(L1 + L2*c2) - px*L2*s2)/ | ||
+ | |||
+ | if(c2 >= -1 && c2 <= 1 && c1 >= -1 && c1 <= 1) | ||
+ | { | ||
+ | theta1_ik = atan2(s1, c1)*(180/ | ||
+ | theta2_ik = atan2(s2, c2)*(180/ | ||
+ | |||
+ | return TRUE; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | return FALSE; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | </ | ||
+ | ---- | ||
+ | \\ | ||
+ | {{: | ||
====Running, | ====Running, | ||
+ | ===Running the Code=== | ||
+ | [[https:// | ||
+ | \\ | ||
+ | If the code is compiled and uploaded to the brick successfully, | ||
+ | \\ | ||
+ | ===Testing and Analysis=== | ||
+ | The best way to test the arm is to use the studded wall as a reference. When the code is ran, the initial position of the arm is regarded as the zero angle position. With this in mind, it is important to have the arm as level as possible. Testing several points allows you to better see the response of the arm. Friction and slop in the arm will be the biggest factors in accuracy. This is where tuning the parameters will help. | ||
+ | \\ | ||
+ | < | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | </ | ||
+ | \\ | ||
+ | PosRegEnable() first defines the port (doesn' | ||
+ | \\ | ||
+ | PosRegSetMax() also defines port, maximum full speed, and max acceleration. | ||
+ | \\ | ||
+ | Changing the values will allow you to fine tune the arm. | ||
+ | \\ | ||
====Conclusions==== | ====Conclusions==== | ||
+ | In conclusion, it was found that it is possible to create a successful 2-link robot arm using LEGO and to control the arm using analytical solutions to the inverse kinematics. It is also possible to tune the arm to achieve better accuracy. Possible future iterations may include improving the mechanical stiffness of the arm to reduce the error in the final position. It is also possible to add a third link as an end-effector for practical uses of the arm. These can include various sensors or grippers. Solidworks can also be used to run simulations or test different iterations of the arm. As long as the parts are properly defined, it is possible to obtain moments of inertia and centers of gravity for each link. This can be used for further dynamic calculations. | ||
- | ====Final Words==== |
lego_2link_arm.1552014425.txt.gz · Last modified: 2019/03/07 19:07 by ntorresreyes