Scara Robot Arm
Scara Robot Arm
Graduation Project
Name ID
Mazen Atef Shaker 1805320
Mechatronics Department
Table of Contents
Introduction .................................................................................................................................................. 5
1.1 Over View ...................................................................................................................................... 6
1.1.1 Fields of using robotic arm .................................................................................................... 6
1.1.2 Specific tasks of robotic arm ................................................................................................. 7
1.2 Types of robotic arms ......................................................................................................................... 7
1.2.1 Cartesian Robotic Arms................................................................................................................ 7
1.2.2 Cylindrical Robotic Arms .............................................................................................................. 8
1.2.3 Spherical Robotic Arms ................................................................................................................ 8
1.2.4 SCARA Robotic Arms .................................................................................................................... 8
Objectives & Methodology ........................................................................................................................... 9
2.1 Problem statement ........................................................................................................................... 10
2.2 Objectives.......................................................................................................................................... 10
2.3 Spics .................................................................................................................................................. 10
2.4 Needs ................................................................................................................................................ 11
2.5 Methodology..................................................................................................................................... 12
2.5 Software tools ................................................................................................................................... 14
2.5.1 CAD............................................................................................................................................. 14
2.5.2 Simulation .................................................................................................................................. 14
2.5.3 Programming Languages ............................................................................................................ 14
2.4 Expected outcomes ........................................................................................................................... 15
Mechanical design ...................................................................................................................................... 16
3.1 Overview ........................................................................................................................................... 17
3.2 First Joint ........................................................................................................................................... 18
3.3 Second joint ...................................................................................................................................... 19
3.5 Joint 3 ................................................................................................................................................ 19
3.6 The End Effector................................................................................................................................ 20
3.4 Robot Integration .............................................................................................................................. 21
Electrical design .......................................................................................................................................... 23
4.1 Electronic components ..................................................................................................................... 24
4.1.1 Arduino UNO .............................................................................................................................. 24
4.1.2 Stepper Motor – NEMA 17......................................................................................................... 24
4.1.3 CNC Shield .................................................................................................................................. 25
1|Page
4.1.4 A4988 Stepper Driver ................................................................................................................. 26
4.1.5 DC Power Supply ........................................................................................................................ 26
4.1.6 Servo Motor ............................................................................................................................... 27
4.1.7 Limit switch ................................................................................................................................ 27
4.2 Electrical circuit ................................................................................................................................. 28
4.3 Wiring ................................................................................................................................................ 28
Kinematics ................................................................................................................................................... 29
5.1 Forward Kinematics .......................................................................................................................... 30
5.2 Inverse Kinematics ............................................................................................................................ 32
Modeling & Simulation ............................................................................................................................... 35
6.1 Overview ..................................................................................................................................... 36
6.1.1 Objectives of Robot Simulation ................................................................................................. 36
6.1.2 Simulation Benefits .................................................................................................................... 37
6.2 MATLAB Simulation .................................................................................................................... 38
6.2.1 MATLAB overview ...................................................................................................................... 38
6.2.2 Simulation Steps......................................................................................................................... 40
6.2.2.8 Simulation Results ................................................................................................................... 46
6.3 ROS Simulation............................................................................................................................ 47
6.3.1 ROS Overview............................................................................................................................. 47
6.3.2 ROS Simulation benefits............................................................................................................. 47
6.3.3 The key features of the ROS....................................................................................................... 49
6.3.4 Rviz ............................................................................................................................................. 49
6.3.5 MoveIt ........................................................................................................................................ 51
6.3.6 Gazebo ....................................................................................................................................... 54
6.3.7 Simulation Steps......................................................................................................................... 56
6.3.8 Conclusion .................................................................................................................................. 65
System Overall Control ............................................................................................................................... 66
Cost Sheet ................................................................................................................................................... 69
Conclusion & limitations ............................................................................................................................. 72
9.1 Conclusion ......................................................................................................................................... 73
9.2 Limitations......................................................................................................................................... 73
Results and testing ...................................................................................................................................... 74
References .................................................................................................................................................. 76
2|Page
Appendices.................................................................................................................................................. 78
9.1 Drawings ........................................................................................................................................... 79
9.2 Codes........................................................................................................................................... 89
9.2.1 Python UI Code .......................................................................................................................... 89
9.2.1 Python Code for the listener node............................................................................................. 89
9..2.3 Arduino Code ............................................................................................................................ 90
Table of Figures
Figure 1. Cartesian Robotic Arms ..................................................................................................................................... 7
Figure 2. Cylindrical Robotic Arms .................................................................................................................................. 8
Figure 3. Spherical Robotic Arms...................................................................................................................................... 8
Figure 4 SCARA......................................................................................................................................................................... 8
Figure 5. Methodology ......................................................................................................................................................... 13
Figure 6. Mechanical design .............................................................................................................................................. 17
Figure 7. joint1........................................................................................................................................................................ 18
Figure 8. joint2........................................................................................................................................................................ 19
Figure 9. joint3........................................................................................................................................................................ 19
Figure 10. Gripper ................................................................................................................................................................. 20
Figure 11. Arduino ................................................................................................................................................................ 24
Figure 12. Nema17 ................................................................................................................................................................ 24
Figure 13. CNC shield ........................................................................................................................................................... 25
Figure 14. stepper driver.................................................................................................................................................... 26
Figure 15. power supply ..................................................................................................................................................... 26
Figure 16. servo ...................................................................................................................................................................... 27
Figure 17. limit switch ......................................................................................................................................................... 27
Figure 18. electrical circuit ................................................................................................................................................ 28
Figure 19. wiring.................................................................................................................................................................... 28
Figure 20. simple design ..................................................................................................................................................... 40
Figure 21. simscape model ............................................................................................................................................... 41
Figure 22. Matlab simulation ............................................................................................................................................ 41
3|Page
Figure 23. trajectory ............................................................................................................................................................. 42
Figure 24. inverse .................................................................................................................................................................. 43
Figure 25. forward ................................................................................................................................................................ 44
Figure 26. Mtalab full Model ............................................................................................................................................. 45
Figure 27. desired trajectory ............................................................................................................................................ 46
Figure 28. Actual result ....................................................................................................................................................... 46
Figure 29. ROS......................................................................................................................................................................... 47
Figure 30. URDF ..................................................................................................................................................................... 56
Figure 31. URDF editting .................................................................................................................................................... 57
Figure 32. Moveit ................................................................................................................................................................... 58
Figure 33. UI ............................................................................................................................................................................ 63
Figure 34. Rviz ........................................................................................................................................................................ 64
4|Page
CHAPTER1
Introduction
5|Page
1.1 Over View
Robotic arms are highly versatile, and can be designed and utilized for a number of different
purposes. As already noted, the primary purpose of a robotic arm is to automate what we
generally consider to be repetitive tasks, ensuring that they’re a popular mechanical addition to
production lines and manufacturing robots processes. Industrial robotic arms are also incredibly
precise, so they’re perfectly suited for tasks that also require a high degree of accuracy and
consistency.
Industrial robotic arms can be kitted out with a number of different tools and pieces of
mechanical equipment and, as such, they can be used across many different industries. They can
also be involved in different stages of production, from the design stage of products through to
the manufacturing, testing, packing and inspection stages.
Their purpose is never limited to one single function, and they can be reused, re-equipped,
redesigned and recycled to meet different demands throughout their lifespan.
• Agriculture
• Aerospace
• Automobile
• Design
• Manufacturing
• Pharmaceuticals
• Tech and computing
6|Page
1.1.2 Specific tasks of robotic arm
Industrial robotic arms have a range of different functions, with their primary purpose being to
automate tasks that would otherwise need to be performed manually, by humans. As well as the
above purposes, industrial robotic arms have the capacity to complete many more industrial tasks
that require or benefit from efficiency, accuracy, and automation. As technology continually
improves, the potential scope and number of uses for robotic arms is continually growing too.
There are a variety of different types of industrial robotic arms produced by manufacturers
worldwide. While they're all highly customizable, different designs generally follow four
primary concepts, each of which is best suited to particular functions. These four primary types
of industrial robotic arms are:
7|Page
1.2.2 Cylindrical Robotic Arms
Figure 2.
Cylindrical Robotic
Arms
SCARA robotic arms are commonly used for assembly tasks, as they are incredibly precise when
it comes to picking and selecting components and parts. SCARA stands for Selective
Compliance Assembly Robot Arm, and they work on a number of different axes, allowing for
greater flexibility of movement.
Figure 4 SCARA
8|Page
CHAPTER 2
9|Page
2.1 Problem statement
2.2 Objectives
• Design and Develop: To design and construct a SCARA robot arm using four stepper
motors that can perform precise pick-and-place operations.
• Accuracy and Precision: To ensure the robot arm can pick and place objects with high
accuracy and repeatability.
• Control System: To develop a robust control system for managing the movements of the
robot arm.
• User Interface: To create a user-friendly interface for easy control and programming of
the robot arm.
• Testing and Validation: To rigorously test the robot arm in various scenarios to validate
its performance and reliability.
2.3 Spics
• Reach: Maximum horizontal reach =432 mm & Maximum vertical reach =400 mm
• Payload Capacity:
• Speed: Maximum speed of the arm’s movements, both linear and rotational.
10 | P a g e
• Work Envelope: x=y=510mm z=470mm
2.4 Needs
6. Performance Metrics: Define metrics for evaluating the performance of the open-loop
control system, such as positional accuracy, repeatability, and response time.
11 | P a g e
2.5 Methodology
2. Design:
• Mechanical Design: Create CAD models and drawings of the robot arm structure.
• Electrical Design: Develop wiring diagrams for the motors, drivers, and microcontroller.
• Software Design: Plan the control algorithms and user interface layout.
3. Development:
• Mechanical Assembly: Construct the physical components of the robot arm.
• Electronics Integration: Wire the motors, drivers, sensors, and microcontroller.
• Software Programming: Write the control software and user interface.
5. Evaluation:
• Analysing the test results to verify that the objectives are met.
• Identification and troubleshoot any issues that arise during testing.
6. Documentation:
• Documenting the design process, development steps, and testing results.
• Preparing the final report with all findings and conclusions.
12 | P a g e
Figure 5. Methodology
13 | P a g e
2.5 Software tools
2.5.1 CAD
Use Computer-Aided Design (CAD) software (e.g., SolidWorks, Autodesk Inventor) for
designing and modeling the robot's mechanical components.
2.5.2 Simulation
Employ simulation tools (e.g., MATLAB, Simulink, ROS) to model and simulate the robot's
movements before physical implementation.
Choose a programming language (e.g., C++, Python) to develop the control software for the
robot.
14 | P a g e
2.4 Expected outcomes
1. Proof of Concept: Demonstrate the feasibility of open-loop control for a SCARA robot by
accurately executing predefined movements and tasks.
2. Optimized Motor Commands: Achieve efficient and optimized motor commands that
result in accurate and repeatable robot movements.
4. Trajectory Accuracy: Showcase the ability of the SCARA robot to follow predefined
trajectories with minimal deviation, emphasizing the accuracy of open-loop control.
15 | P a g e
CHAPTER 3
Mechanical design
16 | P a g e
3.1 Overview
The robot has 4 degrees of freedom and it’s driven by 4 NEMA 17 stepper motors. Additionally, it
has a small servo motor for controlling the end effector or the robot gripper in this case. The brain
of this SCARA robot is an Arduino UNO board which is paired with a CNC shield and four A4988
stepper drivers for controlling the stepper motors.
17 | P a g e
3.2 First Joint
Figure 7. joint1
For the first joint, we have 20:1 reduction ratio, achieved in two stages with these custom
designed pulleys. The two GT2 belts I use here are closed loop with 200mm and 300mm length.
The robot joints are composed of two thrust bearings and one radial bearing.
18 | P a g e
3.3 Second joint
Figure 8. joint2
For the second joint, we have 16:1 reduction ratio, achieved in the same way, and the third joint
has 4:1 reduction ratio with just a single stage reduction. The joints are hollow, so we can use
that to passthrough the wires from the motors and the micro switches. For each of the belts, there
are slots on which we can attach idler pulleys for tensioning them.
3.5 Joint 3
Figure 9. joint3
19 | P a g e
3.6 The End Effector
20 | P a g e
3.4 Robot Integration
21 | P a g e
22 | P a g e
CHAPTER 4
Electrical design
23 | P a g e
4.1 Electronic components
Using an Arduino UNO for controlling and coordinating the movements of the robot, the CNC
shield is plugged onto the Arduino and on top of it is the A4988n drivers and is used as a driver
expansion board.
The NEMA 17 stepper motor is a popular type of stepper motor commonly used in various
applications, including 3D printers, CNC machines, robotics, and other precision motion control
systems. NEMA stands for the National Electrical Manufacturers Association, and "17" refers to
the size of the motor faceplate (42mm x 42mm).
24 | P a g e
4.1.3 CNC Shield
A CNC shield is commonly used in the context of controlling stepper motors for CNC machines,
3D printers, and robotic arms. When applied to a Degree of Freedom (DOF) SCARA (Selective
Compliance Assembly Robot Arm), the CNC shield can serve as an integral part of the control
system.
25 | P a g e
4.1.4 A4988 Stepper Driver
The A4988 is a complete micro stepping motor driver with built-in translator for easy operation.
It is designed to operate bipolar stepper motors in full-, half-, quarter-, eighth-, and sixteenth-step
modes, with an output drive capacity of up to 35 V and ±2 A.
The DC power supply plays a crucial role in powering and controlling different elements of the
robot
26 | P a g e
4.1.6 Servo Motor
Limit switches are commonly used to provide position feedback and implement safety features.
27 | P a g e
4.2 Electrical circuit
4.3 Wiring
28 | P a g e
CHAPTER 5
Kinematics
29 | P a g e
5.1 Forward Kinematics
Assign coordinate frames: Assign a coordinate frame to each joint. Typically, this is done using
the Denavit-Hartenberg parameters (a, alpha, d, theta).
• a: Distance along the common normal between the Oi−1 and Oi axes.
• α: Angle about the xi−1 axis from zi−1 to zi.
• d: Distance along zi−1 to the common normal.
• θ: Angle about zi−1 from xi−1 to xi.
i i di ai αi
1 1 L1 0 0
2 90 D2 0 90
3 3 L3 0 0
H 4 L4 0 0
30 | P a g e
𝐶𝑖 −𝐶ᾳ𝑖 𝑆𝑖 𝑆ᾳ𝑖 𝑆𝑖 𝑎𝑖 𝐶𝑖
𝑆𝑖 𝐶ᾳ𝑖 𝐶𝑖 −𝑆ᾳ𝑖 𝐶𝑖 𝑎𝑖 𝑆𝑖
𝑜𝐴4 =[ ]
0 𝑆ᾳ𝑖 𝐶ᾳ𝑖 𝑑𝑖
0 0 0 1
𝐶1 − 𝑆1 0 0 0 0 1 0
𝑆1 𝐶1 0 0 1 0 0 0
𝑜𝐴1 =[ ] 1𝐴2 =[ ]
0 0 1 𝑑1 0 1 0 𝑑1/2
0 0 0 1 0 0 0 1
𝑛 𝑜 𝑎 𝑝
𝑜𝑇4=𝐴1∗𝐴2∗𝐴3∗𝐴4 0𝑇4 = [
0 0 0 1
]
31 | P a g e
5.2 Inverse Kinematics
𝑨−𝟏
𝟏 ∗ 𝒐𝑻𝟒 = 𝑨𝟐 ∗ 𝑨𝟑 ∗ 𝑨𝟒
𝐶1 𝑆1 0 0 𝑛𝑥 𝑜𝑥 𝑎𝑥 𝑝𝑥
=[−𝑆1 𝐶1 0 0 𝑛 𝑜𝑦 𝑎𝑦 𝑝𝑦
][ 𝑦 ]
0 0 1 −𝑑1 𝑛𝑧 𝑜𝑧 𝑎𝑧 𝑝𝑧
0 0 0 1 0 0 0 1
32 | P a g e
𝑨−𝟏 −𝟏
𝟐 ∗ 𝑨𝟏 ∗ 𝒐𝑻𝟒 = 𝑨𝟑 ∗ 𝑨𝟒
0 1 0 0 𝐶 1 𝑆1 0 0 𝑛𝑥 𝑜𝑥 𝑎𝑥 𝑝𝑥
0 0 1 −𝑑/2 −𝑆1 𝐶1 0 0 𝑛𝑦 𝑜𝑦 𝑎𝑦 𝑝𝑦
[ ][ ][ ]
1 0 0 0 0 0 1 −𝑑1 𝑛𝑧 𝑜𝑧 𝑎𝑧 𝑝𝑧
0 0 0 1 0 0 0 1 0 0 0 1
−𝑆1 𝐶1 0 0 𝑛𝑥 𝑜𝑥 𝑎𝑥 𝑝𝑥
0 0 1 −𝑑/2 − 𝑑1 𝑛𝑦 𝑜𝑦 𝑎𝑦 𝑝𝑦
[ ][ ]
𝐶1 0 𝑆1 0 𝑛𝑧 𝑜𝑧 𝑎𝑧 𝑝𝑧
0 0 0 1 0 0 0 1
33 | P a g e
𝑨−𝟏 −𝟏 −𝟏
𝟑 ∗ 𝑨𝟐 ∗ 𝑨𝟏 ∗ 𝒐𝑻𝟒 = 𝑨𝟒
𝐶4 − 𝑆4 0 0
𝑆4 𝐶4 0 0
=[ ]
0 0 1 𝐿3
0 0 0 1
−𝐶3𝑆1 𝐶3𝐶1 −𝑆3 𝑆3(𝑑/2 + 𝑑1) 𝑛𝑥 𝑜𝑥 𝑎𝑥 𝑝𝑥
−𝑆3𝑆1 𝑆3𝐶1 𝐶3 𝐶3(−𝑑/2 − 𝑑1) 𝑛𝑦 𝑜𝑦 𝑎𝑦 𝑝𝑦
[ ][ ]
𝐶1 0 𝑆1 𝐿3 𝑛𝑧 𝑜𝑧 𝑎𝑧 𝑝𝑧
0 0 0 1 0 0 0 1
𝐶4 − 𝑆4 0 0
𝑆4 𝐶4 0 0
=[ ]
0 0 1 𝐿3
0 0 0 1
𝐶1𝑎𝑌 − 𝑆1𝑎𝑥
𝑞3 = tan−1 ( ),
𝑎𝑍
So we get that the four equations describing the sacra robot inverse kinematics can
be written as:
𝑎𝑦 𝐶1𝑎𝑌 −𝑆1𝑎𝑥
𝑞1 = tan−1 ( 𝑎 ) 𝑞3 = tan−1 ( )
𝑥 𝑎𝑍
𝑝𝑦
𝑑2 = − 𝐿1 𝑞4 = cos −1 ( 𝐶3𝐶1𝑛𝑦 − 𝐶3𝑆1𝑛𝑥 − 𝑆3𝑛𝑧 )
𝑝𝑧
34 | P a g e
CHAPTER 6
35 | P a g e
6.1 Overview
The objectives of simulating the SACRA robot are multifaceted, focusing on both educational and
practical outcomes.
• Learning Control Algorithms: It provides a platform to implement and test various control
algorithms such as PID, MPC, and robust control, facilitating a deeper understanding of
control theory.
• Developing Simulation Skills: Students and researchers can develop and refine their skills
in using MATLAB and Simulink for modeling and simulation purposes.
• Design Validation: Simulations allow for the validation of robot designs before physical
prototypes are built, saving time and resources.
• Performance Analysis: They enable detailed analysis of robot performance under different
scenarios, helping in optimizing design parameters and control strategies.
• Safety Testing: Simulations provide a safe environment to test robot behaviors in various
situations, including failure modes, without risking damage to actual hardware or human
injury.
• Algorithm Development and Testing: New control algorithms and strategies can be
developed and tested in a simulated environment before being implemented in real robots.
36 | P a g e
6.1.2 Simulation Benefits
Simulating offers numerous benefits, enhancing both the design and operational phases of robotic
systems.
1. Cost Efficiency
• Reduced Development Costs: By identifying and resolving design issues early in the
development process, simulations can significantly reduce the cost of building and testing
physical prototypes.
• Resource Optimization: Simulations allow for efficient use of resources by minimizing the
need for physical testing and reducing material waste.
2. Risk Mitigation
• Safe Testing Environment: Simulations provide a risk-free environment for testing robot
behaviors and control algorithms, preventing potential damage to expensive equipment and
avoiding safety hazards.
• Failure Mode Analysis: They enable thorough analysis of different failure modes and the
development of strategies to mitigate these risks.
3. Time Savings
• Design Iteration: Simulations allow for easy modifications and iterations of the robot
design, facilitating exploration of various configurations and their impacts on performance.
• Customization: They enable the customization of robot models and control strategies to
meet specific application requirements.
• Optimization: Simulations allow for the optimization of robot parameters and control
strategies, leading to improved performance and efficiency in real-world applications.
37 | P a g e
6.2 MATLAB Simulation
• MATLAB and Simulink provide extensive tools for modeling the kinematics and
dynamics of the SCARA robot arm.
• Users can create detailed models of the robot's mechanical structure, actuators,
sensors, and control systems.
• MATLAB offers a rich set of toolboxes for developing advanced algorithms, including
control algorithms, machine learning, and optimization.
• Simulink supports the design and simulation of various control systems, such as PID,
adaptive, and model predictive controllers.
• Control System Toolbox in MATLAB provides tools for designing, analyzing, and
tuning control systems, ensuring precise control of the SCARA robot.
38 | P a g e
• MATLAB’s Robotics System Toolbox provides functions for kinematic and dynamic
analysis, including forward and inverse kinematics, dynamics, and trajectory
generation.
• Simulink can simulate the robot’s response to different inputs and control strategies,
helping in understanding its behavior under various conditions.
• MATLAB and Simulink support real-time simulation and testing, allowing integration
with hardware-in-the-loop (HIL) systems.
• MATLAB provides powerful visualization tools for plotting and animating the robot’s
motion, trajectories, and sensor data.
• Simulink 3D Animation allows for the creation of virtual reality models and
animations, providing a clear view of the robot’s operation in a simulated
environment.
• MATLAB’s data analysis capabilities enable the processing and analysis of simulation
data, helping in identifying performance issues and optimizing the robot’s operation.
• Optimization Toolbox and Global Optimization Toolbox provide tools for parameter
tuning and optimizing the robot’s performance.
• MATLAB and Simulink come with extensive documentation, examples, and a large
user community, offering valuable resources for troubleshooting and development.
• MathWorks provides technical support and training, helping users to leverage the
full potential of MATLAB and Simulink.
• MATLAB and Simulink can co-simulate with other software, such as ROS and Gazebo,
enabling the integration of MATLAB’s advanced algorithms with ROS-based robotic
systems.
39 | P a g e
6.2.2 Simulation Steps
When designing a simulation, it's essential to start with a simplified model of the robot that
includes the key components and joints. This initial design helps in understanding the basic
movements and control strategies.
• Robot Configuration: Describe the basic configuration of the robot, including the number
of joints, types of joints (rotational or prismatic), and the degrees of freedom.
• Kinematic Chain: Explain the concept of the kinematic chain and how the links and joints
are connected to form the robot structure.
40 | P a g e
6.2.2.2 Import the CAD using simscape multiple body link
Importing the CAD model involves converting the CAD files into a format compatible with MATLAB
and Simscape Multibody. This process allows for accurate representation of the robot's geometry
and physical properties.
• CAD File Preparation: Steps to export the CAD model from software like SolidWorks or
Autodesk Inventor.
• Import Process: Detailed instructions on importing the CAD model into MATLAB using
Simscape Multibody Link.
41 | P a g e
6.2.2.3 Define the Desired Trajectory Function
A desired trajectory function specifies the path the robot's end-effector should follow. This can be
defined using various mathematical functions or by specifying waypoints.
• Waypoint Trajectories: Defining a series of waypoints that the end-effector must pass
through.
42 | P a g e
6.2.2.4 Define the Inverse Kinematics Function
Inverse kinematics (IK) calculates the required joint angles to achieve a specific end-effector
position. MATLAB provides several tools and functions to solve IK problems.
• Analytical IK: Using geometric methods to derive closed-form solutions for simple robots.
• Numerical IK: Using optimization techniques to solve IK for more complex robots.
43 | P a g e
6.2.2.5 Define the Forward Kinematics Function
Forward kinematics (FK) calculates the end-effector position based on given joint angles. This
function is crucial for validating the robot's movements and ensuring the accuracy of the IK
function.
• FK Calculation: Using the robot's kinematic chain to compute the position and orientation
of the end-effector.
44 | P a g e
6.2.2.6 Control Algorithm
Implementing a control algorithm, such as a PID controller, ensures that the robot's joints follow
the desired trajectories accurately.
• PID Controller Design: Design and tune PID controllers for each joint to achieve stable and
accurate motion.
• PID controllers is defined for each joint. Typically, each joint in the robot will have its own
controller.
• Set up a simulation loop to apply the PID control and visualize the robot’s response.
6.2.2.7 Calibration
Calibration involves comparing the desired trajectory with the actual output and adjusting the
control parameters to minimize errors.
• Trajectory Comparison: Visualize and compare the desired and actual trajectories.
• PID Tuning: Adjust the PID gains to achieve the best fit between the desired and actual
movements.
45 | P a g e
6.2.2.8 Simulation Results
46 | P a g e
6.3 ROS Simulation
ROS stands for robot operating system but it's not a standalone operating system as it goes on top
of ubuntu linux. ROS has simplified the process of creating and writing robot software.
Using ROS (Robot Operating System) for simulating the robot has several advantages, making it a
valuable tool in the development and testing of robotic systems.
• ROS provides a modular framework that allows for the integration of different
packages and tools, facilitating a flexible development environment.
• It supports various simulation tools such as Gazebo, which can be used to create and
test complex robotic models and environments.
47 | P a g e
• ROS has a large and active community, offering extensive documentation, tutorials,
and support forums, making it easier to troubleshoot and find resources.
• A wealth of pre-built packages and libraries are available for common robotic
functions, reducing development time.
3. Realistic Simulation
• ROS can easily integrate with other simulation and development tools, such as
MATLAB and Simulink, allowing for comprehensive analysis and control system
development.
• ROS offers a wide range of ready-to-use control and planning algorithms, which can
be directly applied to the SCARA robot for tasks such as motion planning, trajectory
generation, and inverse kinematics.
• It allows for the customization and optimization of these algorithms to meet specific
project requirements.
6. Visualization
• ROS provides powerful visualization tools like RViz, which help in monitoring and
debugging the robot’s state, sensor data, and planned trajectories in real-time.
• These tools enhance understanding of the robot's behavior and facilitate rapid
iteration and improvement of the control strategies.
7. Scalability
• ROS is designed to scale from single robot systems to large multi-robot setups,
making it suitable for both small projects and large-scale industrial applications.
• This scalability ensures that the same simulation framework can be used as the
project grows in complexity.
48 | P a g e
6.3.3 The key features of the ROS
• The ability to reuse the code and modify its parameters if needed to be used over another
robots
• ROS provide a wide range of libraries and tools that helps in monitoring and debugging the
robot like gazebo and Rviz for simulation
• ROS community: ROS has wide and active community that contributes with different a vast
array of modules and packages that extend and widen the functionality of the ROS and
might help in accelerating the operations
• Multi language support: ROS has the ability to support multiple powerful languages like
python and C++ and has the ability to communicate with codes that are written in other
languages
• Scalability as the ROS can work on a wide range of projects no matter it`s scale
6.3.4 Rviz
RVIZ is a short for ROS visualization and it`s 3d visualization software that is used to visualize the
robot and its sensors in a 3d dimensional space, it helps in visualizing the sensor data such as lidars,
ultrasonic, cameras and more. It renders a real time 3d graphical presentation of the robot showing
its current pose and orientation and more.
• Real-Time Visualization
49 | P a g e
• RViz allows for real-time visualization of a robot's state, including its position, orientation,
and sensor data. This helps developers understand the current status and behavior of the
robot.
• It can display data from various sensors such as LiDAR, cameras, depth sensors, and IMUs,
providing a comprehensive view of the robot's perception of its environment.
• Sensor data visualization aids in debugging and calibrating sensors, ensuring accurate data
collection and processing.
• RViz can visualize the robot model, including its joints and links, in a 3D space. This is useful
for verifying the correctness of the robot's kinematic model and motion.
• It also displays joint states, helping in monitoring and adjusting the robot's movement and
configuration.
• RViz supports the visualization of planned paths and trajectories. Developers can see the
intended movement of the robot and verify if the paths are collision-free and feasible.
• It helps in fine-tuning path planning algorithms and ensuring smooth and efficient robot
motion.
• Interactive Markers
• Interactive markers in RViz allow users to manipulate objects and set goals in the
environment. This is particularly useful for testing and debugging manipulation and
navigation tasks.
• It enables intuitive interaction with the simulation environment, making it easier to test
different scenarios.
• Visualization of Transformations
• RViz can visualize the transformations (tf) between different coordinate frames of the robot
and the environment. This is crucial for understanding the spatial relationships and
ensuring correct data transformations.
• RViz is highly customizable, allowing users to create custom displays and plugins to suit
their specific needs. This flexibility makes it adaptable to various robotic applications.
50 | P a g e
• It supports adding custom markers and visualizations, enhancing the tool's functionality.
• Environment Visualization
• RViz can display the robot's environment, including obstacles and maps, providing context
for the robot's operation. This is essential for tasks such as navigation and SLAM
(Simultaneous Localization and Mapping).
• It allows for the visualization of static and dynamic objects, aiding in the development and
testing of environment-aware algorithms.
6.3.5 MoveIt
1. Motion Planning
• MoveIt provides advanced motion planning algorithms that allow the SCARA robot to
compute collision-free paths. This is crucial for ensuring safe and efficient operation in
dynamic environments.
• It supports various planning algorithms like RRT (Rapidly-exploring Random Trees) and
PRM (Probabilistic Roadmap), which can be chosen based on the specific requirements of
the task.
2. Inverse Kinematics
• MoveIt includes robust inverse kinematics solvers, enabling the SCARA robot to calculate
the necessary joint angles to reach a desired end-effector position and orientation.
• This simplifies the process of controlling the robot and executing precise movements.
51 | P a g e
3. Collision Detection
• MoveIt continuously monitors for potential collisions between the robot and its
environment, ensuring that planned motions are safe.
• This is particularly useful in environments with obstacles, preventing damage to the robot
and its surroundings.
4. Path Optimization
• MoveIt optimizes planned paths to minimize execution time, energy consumption, or other
criteria, leading to more efficient operations.
• Optimization helps in achieving smoother and faster robot movements, enhancing overall
performance.
5. 3D Perception Integration
• MoveIt can integrate with 3D perception sensors (e.g., depth cameras, LiDAR) to perceive
and interact with the environment.
• This capability allows the SCARA robot to adapt to changes in its surroundings, enabling
tasks like object detection and manipulation.
• MoveIt provides tools for grasping and manipulation, making it easier to develop
applications where the SCARA robot needs to pick up, move, and place objects.
• It includes libraries for generating grasps and handling different types of objects.
• MoveIt integrates with RViz for visualization, allowing users to simulate and visualize the
robot’s planned motions and interactions with the environment.
• This aids in debugging and refining motion plans before deploying them on the physical
robot.
• MoveIt seamlessly integrates with other ROS packages and tools, facilitating communication
and data exchange within the robotic system.
• It supports easy integration with controllers, sensors, and other components, streamlining
the development process.
52 | P a g e
53 | P a g e
6.3.6 Gazebo
• Gazebo provides accurate physics simulations, including dynamics, collisions, and sensor
data, allowing for realistic testing of the SCARA robot's movements and interactions.
• It uses advanced physics engines like ODE, Bullet, and DART to simulate the robot's
behavior under various conditions.
2. 3D Environment Modeling
• Users can create and simulate detailed 3D environments, which is essential for testing the
SCARA robot in scenarios that closely resemble real-world applications.
• Gazebo supports complex environments with various obstacles and objects, facilitating
comprehensive testing.
3. Sensor Simulation
• Gazebo can simulate a wide range of sensors, including cameras, LiDAR, IMUs, and more,
providing the SCARA robot with realistic sensory inputs.
• This helps in developing and testing sensor-based algorithms such as object detection and
localization.
4. Robot Modeling
54 | P a g e
• Users can model the SCARA robot with precise joint configurations, link dimensions, and
physical properties. This ensures that the simulated robot closely matches its real
counterpart.
• URDF (Unified Robot Description Format) files are used to define the robot's structure,
which can be imported into Gazebo for simulation.
• Gazebo integrates seamlessly with ROS, allowing for the use of ROS packages and tools
within the simulation. This includes ROS control, MoveIt, and other ROS-based algorithms.
• ROS topics, services, and actions can be used to interact with the robot and the simulation
environment.
6. Plugin Support
• Gazebo supports custom plugins for extending functionality, enabling users to add specific
behaviors, sensors, and controllers to the SCARA robot.
• These plugins allow for the simulation of custom scenarios and advanced features not
available out-of-the-box.
• Gazebo provides a safe environment for testing and debugging robotic algorithms without
the risk of damaging physical hardware.
• Users can iterate quickly, testing different configurations and control strategies to optimize
the robot's performance.
• Gazebo offers real-time visualization of the simulation, including the robot's movements,
sensor outputs, and environmental interactions.
• This visual feedback aids in understanding the robot's behavior and in debugging issues
effectively.
• Numerous example simulations and models are available, which can serve as a starting
point for new projects.
55 | P a g e
6.3.7 Simulation Steps
6.3.7.1 Step1
Creating a workspace with suitable name for the Scara robot and Creating the required packages in
order to help facilitating the organization of the scripts and launch files then building and sourcing
the workspace in order to compile the source code and handling the dependencies
6.3.7.2 step2
Creating the URDF of the robot and simplifying it in order to facilitate the importing of the URDF
in the simulation softwares like Moveit, Rviz and Gazebo then exporting the URDF so we can import
it into these softwares.
56 | P a g e
6.3.7.3 Step3
We have edited the URDF file manually in order to change the limits according to the real robot as
modifying and editing these limits will help in simulating the robot correctly
• Type: joint type whether it`s revolute or prismatic or fixed like the base
• Child: The child link that will be connected right after this link
Limit: the joint constraints that will be used to adjust the upper and lower limit of the real robot
6.3.7.4 Step4
We have ran the launch file that launches the setup assistant for move it
57 | P a g e
Then we have imported the urdf file into moveit after finishing it
58 | P a g e
Then we have optimized the self collision inside moveit
And we have defined the groups for the moving arm of the robot and the end effector
59 | P a g e
And we have defined the groups for the moving arm of the robot and the end effector then we have
defined suitable poses by rotating each joint with suitable rotation for the task for both groups
which are :
60 | P a g e
• Pickup pose: the position in which the robot will move in order to pick a certain object from
a certain place
• Placing pose: the position in which the robot will move in order to place a certain object in a
certain place
Writing Implementing Python code for the Ui using Tkinter library so the UI will be used to send
commands through the serial port in which arduino is connected and to take the joints angles from
Rviz through listener node in order to execute the RVIZ pick pose and Place pose that is configured
using moveit setup.
Listener Node
This node will be used to publish the joint angles in RVIZ to the UI so the UI can send them after
calibrating them and converting the angle to steps using the following conversions with Python
math library.
61 | P a g e
The UI sends commands through the serial port and the arduino code receives these commands and
compare it wit the predefined commands in the c++ arduino code in order to execute the proper
execution
Gazebo
62 | P a g e
6.3.7.7 UI
Figure 33. UI
• zero position(homing): the robot moves toward the limit switch, when limit switch is
triggered, the arm moves to the opposite direction.
• Set pick up & set Place: take angels from Rvis turn it into steps by conversion equations
• Open grip & Close grip: controls the end effector
63 | P a g e
Figure 34. Rviz
64 | P a g e
6.3.8 Conclusion
• Picking up pose
• Placing pose
• Open gripper
5- logic in order to differentiate between zero positioning and normal operating mode using limit
switches
65 | P a g e
CHAPTER 7
66 | P a g e
67 | P a g e
68 | P a g e
CHAPTER 8
Cost Sheet
69 | P a g e
Item Source Picture Cost
A4988 Stepper
Flux 65
Drivers
70 | P a g e
NEMA17 Stepper
Flux 2400
Motors (x4)
Mg996r Servo
Free Electronics 220
Motor
71 | P a g e
CHAPTER 9
72 | P a g e
9.1 Conclusion
• Successfully designed, modelled, and implemented a SCARA robotic arm.
• Integrated mechanical and electrical components effectively, including Arduino UNO
and CNC shield for control.
• Developed accurate forward and inverse kinematic models for precise movement and
positioning.
• Utilized MATLAB and ROS simulations for system performance analysis and PID
controller fine-tuning.
• Validated the robot's performance through testing, confirming the design and control
strategies.
• Highlighted the potential of SCARA robots in various industrial applications.
• Provided a comprehensive guide for future developments in robotic systems.
9.2 Limitations
• Precision is dependent on the quality and accuracy of 3D printed parts, which can vary.
• Use of standard components like NEMA17 stepper motors and Mg996r servo motor may
limit speed and payload capacity.
• algorithms such as adaptive or model predictive control.
• Simulations conducted under ideal conditions may not fully replicate real-world
scenarios, affecting practical performance.
• Project constraints included budget and time, limiting the extent of testing and
refinement.
• Future work should explore higher precision manufacturing methods, advanced control
strategies, and extensive real-world testing to enhance capabilities and reliability.
73 | P a g e
CHAPTER 10
74 | P a g e
After completing all the design process and reviewing, the final test is on its place. The robotic
arm is assembled as shown and reaches all of the specifications
75 | P a g e
CHAPTER 11
References
76 | P a g e
• https://robodk.com/blog/what-is-a-scara-robot/
• https://www.academia.edu/28681822/Kinematics_of_SCARA_Robos
• Mechatronics ASU. (2022). Industrial Robotics Lectures [YouTube Playlist]
• Age Of Robotics. (2024). [YouTube Playlist]
77 | P a g e
CHAPTER 12
Appendices
78 | P a g e
9.1 Drawings
79 | P a g e
80 | P a g e
81 | P a g e
82 | P a g e
83 | P a g e
84 | P a g e
85 | P a g e
86 | P a g e
87 | P a g e
88 | P a g e
9.2 Codes
89 | P a g e
9..2.3 Arduino Code
90 | P a g e