Make this in a step by step format # tactiq.io free youtube transcript
# How to design Robots using MATLAB 2021 | SimScape Toolbox | Robotics System Toolbox
# https://www.youtube.com/watch/_8YCc3pJDPI

00:00:00.320 assalamualaikum dear learners i hope you
00:00:02.879 are doing great and are ready to dive
00:00:05.279 into the world of robotics with me
00:00:07.919 this series of video lectures is aimed
00:00:10.160 at introducing some very important tools
00:00:13.280 which robotics or related field
00:00:15.120 engineers are going to need extensively
00:00:18.000 especially during research work
00:00:20.400 though the contents of this broad field
00:00:23.039 may be widened quite a lot however we
00:00:25.840 will limit our focus to matlab's robotic
00:00:28.640 system toolbox and simscape toolbox
00:00:31.920 these two toolboxes are approximately
00:00:34.640 everything you need to learn about
00:00:36.719 various algorithms test them in
00:00:39.200 simulated environments make your own
00:00:41.520 simulated robots and test their
00:00:43.680 performance under various conditions
00:00:46.320 to understand things more concretely
00:00:48.640 i'll follow an example in which we are
00:00:50.800 going to build a simple 2 degree of
00:00:53.280 freedom planar robotic manipulator and
00:00:55.760 then we are going to simulate it using
00:00:57.840 required robotics algorithms
00:01:00.239 along the way i'll explain each
00:01:02.320 component i'll be using so let me first
00:01:05.280 explain what example i am going to use
00:01:07.920 and how i am going to simulate the 2
00:01:09.840 degree of freedom planar robot arm
00:01:12.479 for the introductory video we are going
00:01:14.479 to keep things simple therefore the
00:01:16.799 robot arm that we are going to design
00:01:19.040 and implement will look like this
00:01:21.680 it will have two joints placed over here
00:01:24.880 and over here the links joining the
00:01:27.520 joints will have shown length and as we
00:01:30.880 wanted a planar robot the end effector
00:01:33.520 shown by this block will remain in the
00:01:36.079 same plane which is parallel to the
00:01:38.560 ground and 0.1 meters above it
00:01:42.320 the shown figure over here is the front
00:01:44.560 view of the robot which we are going to
00:01:46.479 make
00:01:47.280 however if we see from the top view then
00:01:49.840 the workspace of this manipulator would
00:01:52.240 be a circle of radius 0.35 meters
00:01:56.719 moreover if we apply rotation
00:01:58.719 restriction on the second joint so that
00:02:01.280 the second link and the end effector
00:02:03.759 might not collide with the first link
00:02:06.159 then the workspace will become a disk as
00:02:09.038 shown over here
00:02:10.318 anyhow to implement this robot in the
00:02:12.800 simulated environment we need some cad
00:02:15.680 tool that will build the required cad
00:02:18.080 model and insert the joints in the
00:02:20.640 correct locations and orientations
00:02:23.360 this will be achieved by the simscape
00:02:25.360 toolbox after that we need to drive this
00:02:28.319 robot in its workspace so some kind of
00:02:31.760 algorithm should tell the joints of the
00:02:33.920 robot to rotate by a certain angle if we
00:02:36.879 want to reach a specific point in the
00:02:39.200 workspace
00:02:40.319 at the very basic level there are two
00:02:42.640 ways to achieve this
00:02:44.319 first we can command the joints to
00:02:46.560 rotate to a certain angle which is
00:02:49.120 within the rotational limit of the joint
00:02:51.599 and when the joints have rotated to
00:02:53.599 those certain angles the end effector
00:02:56.160 would have reached a corresponding point
00:02:58.319 in the workspace this is what we call
00:03:00.879 the forward kinematics algorithm
00:03:03.440 however in reality we know that where in
00:03:06.319 the workspace the end effector should
00:03:08.400 reach but we don't know the angles
00:03:10.879 through which each joint must rotate so
00:03:13.360 that the end effector may reach the
00:03:15.040 desired location
00:03:16.640 moreover sometimes there are multiple
00:03:19.440 joint angles that will take the robot to
00:03:22.000 the same point in the workspace
00:03:24.319 therefore it is a difficult task to
00:03:26.799 provide joint angles directly hoping
00:03:29.519 that a robot will reach the intended
00:03:31.760 location
00:03:32.799 to cater this we need some other kind of
00:03:35.280 algorithm that will take in the point in
00:03:38.080 the workspace and generate the joint
00:03:40.480 angles for the joints which when
00:03:42.879 traversed by the joints the end effector
00:03:45.519 will reach the desired location
00:03:47.920 this algorithm is what we call the
00:03:50.560 inverse kinematics algorithm
00:03:52.879 in this introductory video i'll showcase
00:03:55.599 forward kinematics algorithm using
00:03:58.000 robotic system toolbox only
00:04:00.799 firstly we will use simscape toolbox to
00:04:03.680 create a cad model of our robotic arm
00:04:06.879 this cad model can then be used to
00:04:09.040 generate a rigid body tree
00:04:10.959 representation
00:04:12.400 which the robotic system toolbox
00:04:14.400 requires for its working
00:04:16.399 alternatively you may generate rigid
00:04:18.639 body tree representation directly but
00:04:21.120 that will be a difficult task at the
00:04:23.040 moment because for that you should be
00:04:25.520 well versed with the coding techniques
00:04:28.320 therefore for starters we will use a cad
00:04:31.360 model to generate the rigid body tree of
00:04:33.680 our robot
00:04:34.880 which in my perspective is an easier
00:04:37.680 approach
00:04:38.639 there are other advantages to this
00:04:40.479 approach as well however i won't discuss
00:04:43.280 those over here
00:04:44.560 so let's get started and i'll explain
00:04:47.360 several basics along the way
00:04:50.240 so this is the simulink environment on
00:04:52.800 which we are going to work over here you
00:04:54.960 can see that i have opened the simulink
00:04:57.360 library browser
00:04:59.040 whereas over here i have opened a blank
00:05:01.600 simulink model
00:05:03.280 so first i am going to use simscape
00:05:05.759 toolbox to design the cad model of the
00:05:08.320 robot and then i am going to use robotic
00:05:11.120 system toolbox to drive that robot
00:05:13.600 through forward kinematics algorithm
00:05:16.080 if you scroll down a bit you can see
00:05:18.320 simscape toolbox right over here make
00:05:21.120 sure you have installed it under the
00:05:23.600 simscape toolbox there are multiple
00:05:26.320 subdivisions from which we are going to
00:05:28.720 work in multibody division inside the
00:05:31.680 multibody portion we can find all the
00:05:34.880 kind of elements that can be used to
00:05:37.360 generate robotic systems or mechanical
00:05:39.919 systems
00:05:40.960 before creating anything in multibody
00:05:43.120 system there are three blocks that are
00:05:45.440 must for every kind of model
00:05:48.400 so let me place those three blocks and
00:05:50.960 tell you that why they are needed
00:05:53.199 in the utility section under the
00:05:55.120 simscape you can find solver
00:05:57.440 configuration block
00:05:59.039 this will be used to define that what
00:06:01.360 kind of ode solver this mechanism is
00:06:04.880 going to use so we need this block over
00:06:07.520 here but right now in this example we
00:06:10.080 don't need to adjust any of the settings
00:06:13.360 then we will move on to the frames and
00:06:16.160 transforms under the multi-body section
00:06:19.039 and over here we need to define a world
00:06:22.319 reference frame so we will need a world
00:06:24.880 frame block
00:06:26.319 this frame will define the coordinate
00:06:28.560 system of all the mechanisms which we
00:06:30.800 are going to build
00:06:32.160 and at the end in the utilities section
00:06:34.800 under multibody we will find mechanism
00:06:37.520 configuration that will define the
00:06:39.759 gravities or any other forces that are
00:06:42.880 acting on all the mechanisms which are
00:06:45.280 present in this model
00:06:47.120 so by default if you double click the
00:06:49.039 mechanism configuration you will find
00:06:51.360 that the gravity has been defined as
00:06:53.599 minus
00:06:55.400 9.80665 in the z-axis so we are not
00:06:58.880 going to change this thing
00:07:00.800 so these three blocks are the basic
00:07:02.720 blocks which are required for any kind
00:07:05.120 of multi-body element or multi-body
00:07:07.840 mechanisms which we are going to use or
00:07:10.319 make using simscape multi-body toolbox
00:07:14.400 now we are going to build the robot from
00:07:16.880 base up to the end effector so the first
00:07:19.280 thing we need to build is the base
00:07:22.080 if you remember the base was a simple
00:07:24.880 cylindrical object so i am going to need
00:07:28.000 a body element which can be found over
00:07:30.400 here
00:07:31.440 and you can see that there is a
00:07:33.199 cylindrical solid present over here i
00:07:35.840 can drag it over here
00:07:37.840 and by going into its settings i can
00:07:41.120 change its properties its mass its
00:07:43.919 inertia its size and everything related
00:07:46.639 to it so for the time being i am going
00:07:48.800 to enter 0.05 as its radius
00:07:52.080 and its length as
00:07:54.240 0.1
00:07:55.520 and in the graphics portion as i've
00:07:57.840 shown that its color was blue so i am
00:08:00.160 going to use a blue color over here
00:08:06.080 so that's it i have generated the base
00:08:09.039 now the thing over here is that whenever
00:08:11.280 you create any solid or any body in this
00:08:14.400 multi-body environment the frame of this
00:08:17.360 body will be exactly at its center so if
00:08:21.520 i attach the cylindrical solid with the
00:08:24.000 world frame then the world frame and the
00:08:26.400 frame of this cylindrical solid will be
00:08:29.199 at the center of this body
00:08:31.599 but i want the world frame to be at the
00:08:34.159 base of the body
00:08:35.760 so i need some kind of frame
00:08:37.919 transformation between them for that
00:08:40.399 i'll go to the frames and transforms and
00:08:43.440 i can use a rigid transform over here
00:08:46.640 this rigid transform will transform the
00:08:49.279 world frame to the frame of the solid
00:08:52.320 cylinder over here so i can connect the
00:08:55.360 world frame to the base portion and the
00:08:57.920 follower portion will be connected to
00:08:59.600 the cylindrical object but before that
00:09:02.560 let me rotate it so that i can easily
00:09:04.720 connect it
00:09:10.160 the transformation over here should move
00:09:12.160 the world frame at the center of the
00:09:14.399 object and as the height of the object
00:09:16.640 was 0.1 meter so i need to move 0.05
00:09:20.880 meter in z axis
00:09:23.279 so inside the rigid transform i'll go
00:09:25.920 into the translation and then in methods
00:09:28.720 i'm going to select cartesian and in the
00:09:31.279 z axis i'm going to add
00:09:33.920 0.05
00:09:38.080 and that's it now at this point my
00:09:40.959 object should be lying so therefore i
00:09:43.440 have attached a cylindrical solid over
00:09:45.519 here
00:09:46.320 i'm going to attach the solver
00:09:48.080 configuration block and the mechanism
00:09:50.399 configuration block with this mechanism
00:09:53.360 as well like this let me rename this
00:09:55.920 transformation block as
00:09:58.240 world
00:09:59.839 to base
00:10:01.760 because it is transforming the world
00:10:03.600 coordinate system to base coordinate
00:10:05.519 system and this block is representing
00:10:08.480 the base of the robot
00:10:10.399 now the next thing is on the base i want
00:10:13.360 to attach the first joint but that joint
00:10:16.560 should be at the top of the base
00:10:20.079 so i need to transform the
00:10:22.880 frame of reference of this base
00:10:25.600 from the center of it or from the middle
00:10:28.079 of it to the top side for that once
00:10:31.040 again i'm going to use a rigid transform
00:10:36.399 so this rigid transform is going to
00:10:39.120 transform
00:10:40.560 from base
00:10:42.160 to joint 1. so i'm labeling joint 1 as
00:10:45.920 j1
00:10:47.360 and i know that
00:10:49.040 joint 1 should be present right at the
00:10:51.519 top of the base
00:10:52.880 so it should be moved upwards or in z
00:10:56.640 direction by
00:10:58.839 0.05 but to cater the height of the link
00:11:02.160 as well
00:11:03.279 the first joint should be at the middle
00:11:05.279 of first link as well so first link if i
00:11:09.040 am going to use its height as
00:11:11.800 0.02 meter then the middle of 0.02 meter
00:11:16.320 would be 0.01 so that is the height i
00:11:19.200 should add over here as well so i'm
00:11:21.600 going to use 0.06 instead of 0.05 so now
00:11:26.640 the base frame will be translated to a
00:11:30.079 point where i can join joint one
00:11:34.000 so to add the first joint i will go into
00:11:36.880 the joints section under multibody and
00:11:39.680 over here i can find different type of
00:11:42.160 joints from these joints i need revolute
00:11:45.279 joint because we are going to use two
00:11:47.440 revolute joints only so
00:11:50.320 i can drag this revolute joint and place
00:11:52.880 it over here
00:11:54.240 i am going to label this joint as j1
00:11:57.760 and now after this joint i need to add
00:12:01.040 link one or that is the first link
00:12:04.079 the first link if you remember was a
00:12:06.720 long cuboid so once again i'm going to
00:12:09.600 go into the body elements and from here
00:12:12.639 i'm going to select brick solid this
00:12:14.639 time
00:12:18.560 but before attaching this solid with the
00:12:21.600 joint i need to move the frame of the
00:12:24.560 joint to the center of this brick solid
00:12:27.839 because the frame of the brick solid
00:12:30.000 will be at its center so i need once
00:12:33.040 again a transformation block
00:12:36.240 for that i'm going to use another rigid
00:12:38.240 transform
00:12:40.720 i'll connect the base
00:12:43.279 of this transform to the follower of the
00:12:45.360 joint one
00:12:46.639 now i need to move in x direction
00:12:52.320 and it would be half of the length of
00:12:54.959 the length that i am going to use so the
00:12:56.959 total link length was 0.2 meters i am
00:12:59.920 going to move by 0.1
00:13:03.040 now i can attach the solid or the link
00:13:05.680 over here
00:13:06.880 so before that let me adjust its
00:13:09.040 properties first of all let me rotate it
00:13:12.959 and now adjust other properties like
00:13:15.760 size and colors etc
00:13:18.079 so the size of this link will be 0.2 in
00:13:22.160 x direction
00:13:23.600 0.02 in y and 0.02 in z that is the
00:13:27.600 width and the height
00:13:29.360 and for graphics i'm going to use a
00:13:32.720 light green color for example i can use
00:13:35.600 this color so that's it now i have
00:13:38.079 attached the first link as well
00:13:41.440 now in the way if you want to see that
00:13:43.600 what you are building
00:13:45.199 you can always run this file and see
00:13:48.560 what you have built so if you have gone
00:13:51.120 wrong anywhere you can adjust right over
00:13:53.360 here so let me run it and see what we
00:13:56.000 have built till now
00:13:58.160 so this is something that we have built
00:14:00.320 this is the front view of the robot
00:14:02.079 which we have built we have a blue base
00:14:04.800 and a first link which is attached over
00:14:07.279 here on this side you can see that we
00:14:09.920 have a world frame
00:14:11.600 which is at the lower center of the blue
00:14:14.160 base
00:14:15.279 then there is a base which has a frame
00:14:18.399 right at the middle of it
00:14:20.240 then after that base we have joint one
00:14:23.920 which has frame over here which is just
00:14:27.440 above the base
00:14:28.959 and then after joint one we have a solid
00:14:32.880 which is link one and this link one has
00:14:36.160 its frame right at its middle
00:14:38.800 you can change the camera view by right
00:14:40.959 clicking over here and go to standard
00:14:43.199 views and you can choose any of these
00:14:45.519 views
00:14:46.720 let me use the isometric view so this is
00:14:49.600 the robotic arm which we have made
00:14:52.399 right now it has only one joint and one
00:14:55.040 link so so far so good let us complete
00:14:58.079 the robot by adding the join 2 and the
00:15:00.720 link 2 as well
00:15:02.320 so after link 1 we need to add joint 2.
00:15:06.480 once again join 2 will be added right at
00:15:09.920 the end of link one so we need some kind
00:15:12.880 of frame transform that will transform
00:15:15.839 the frame right from the center of link
00:15:18.560 one to the extreme edge of link one
00:15:21.680 once again i'm going to use a rigid
00:15:23.600 transform
00:15:25.440 and i'm going to attach it over here
00:15:28.160 and i know that link 1 was of length 0.2
00:15:32.800 and i need to move
00:15:35.120 in x axis by 0.1 more so that i'll reach
00:15:38.639 the end of the link one
00:15:40.880 so i'm going to write point one over
00:15:42.880 here
00:15:43.920 now this rigid transform will take me
00:15:46.880 from the center of link one to the
00:15:49.839 position where i can attach joint to
00:15:53.519 let me rename these transforms
00:15:56.079 for clarity
00:15:57.440 so this transform is taking me from
00:15:59.600 joint one to link one
00:16:02.480 whereas this transform is taking me from
00:16:06.160 link one
00:16:07.600 to join two
00:16:09.199 so now i can attach join two over here
00:16:11.759 once again i'm going to use a revolute
00:16:13.839 join so i can copy it
00:16:17.120 and place it over here
00:16:19.360 this is the join two and after join two
00:16:21.920 i need to add link two
00:16:24.399 and for link two i need to once again
00:16:27.360 move the frame of join two to the center
00:16:31.120 of the link too
00:16:33.120 so once again i'm going to use this kind
00:16:35.600 of frame transformation
00:16:37.839 i'm going to copy it
00:16:39.920 use it over here and adjust its length
00:16:43.600 i know that the second link is of
00:16:46.199 0.15 length in total so i'm going to use
00:16:50.279 0.075 in x direction so that i can move
00:16:54.240 to the
00:16:55.360 position where link 2 can be attached so
00:16:58.399 this transformation will take me from
00:17:01.040 joint 2 to link 2. over here now i can
00:17:05.520 attach link 2
00:17:07.839 like this
00:17:09.199 let me adjust the properties of this
00:17:11.439 link
00:17:12.240 so i will add
00:17:13.799 0.15 over here
00:17:16.160 and let me change the graphic so that
00:17:18.559 link two will look a bit different from
00:17:20.640 link one
00:17:22.720 i can use any other color
00:17:25.199 let me use this purple magenta color
00:17:29.520 and that's it
00:17:30.960 so now i have added link two as well
00:17:34.400 so after link two i need to add a joint
00:17:38.160 that will be a fixed joint and with that
00:17:40.880 joint i'll need to attach the end
00:17:43.360 effector
00:17:44.960 so i can once again go to the joints i
00:17:47.760 can use a fixed joint like a weld joint
00:17:51.039 i can find it over here
00:17:56.880 this felt joint should be attached right
00:17:59.360 at the end of the link too so i need
00:18:02.160 some kind of transform to transform me
00:18:05.120 from the center of the link to to the
00:18:07.520 end of the link too
00:18:09.440 so i'm going to need
00:18:11.440 this kind of transform
00:18:13.600 this transform is going to take me from
00:18:16.799 link 2
00:18:18.559 to joint of end factor
00:18:22.240 and i will modify the length
00:18:25.039 as
00:18:26.240