self balancing robot | Simulink basics series

Поділитися
Вставка
  • Опубліковано 5 сер 2024
  • in this practical tutorial 🔥 you will learn how to build and control a self-balancing robot in Simulink.
    in this first video from the Simulink basics series we will build and control a 3d model of a two-wheeled self-balancing robot.
    we used a PID controller to achieve an upright pose for the robot and used two approaches for tuning the PID controller which are: manual and auto-tuning.
    🔥 IMPORTANT :
    1. the value of the gain block is : -180 / 3.14
    🔗links :
    1. Get the project files from : ko-fi.com/s/716bba8384
    ⏱️Timestamps:
    0:00 intro
    0:56 what is a self-balancing robot?
    1:56 making the wheels
    5:00 making the upper body
    9:23 the wheel's shaft and some rotations
    11:32 working with joints
    12:45 building the control system
    15:17 tuning the PID controller
    17:48 outro
    🏷️Hashtags:
    #simulink #SelfBalancingRobot #matlab
  • Наука та технологія

КОМЕНТАРІ • 112

  • @marianaurel
    @marianaurel 2 роки тому +8

    2 things for those interested:
    1) It is moving because for some reason of that force applied on the Y+ on the 3rd plate, together with the main step input of the system. This is looping through again and again making a set reference point of let's say "+X degrees" hence it moves in a direction. Tuning it manually I found that if you keep that force on the top plate let's say +1, then you should have a step input with an initial value of +4, and that should make sure that the robot stabilizes using perfect PID values automically tuned and realistic environment. With this logic if you want to let's say simulate your own different setpoint remember that if you want to have a 10 degrees setpoint add +4 to it to make it appropriate and realistic, so put into the step an initial value of +14, and so on.
    In short, that constant movement of the robot is due to that initial force given to the top plate.
    2) for those maniacs out there like myself, if you want to keep Z+ axis as your "UP" then just add a rigid transform right before the prismatic joint and set it as follows: Method: Standard axis > Axis: -Y > Angle:90. then go to the Mechanism Configuration and have gravity as: [0 0 -9.80665] this way gravity is kept as a force towards your relative "DOWN". Click ok, then hit Ctrl+D and enjoy your Z as "UP/Down" and X as "Forward/Backward" and Y as "Sideways".

  • @EdwinFairchild
    @EdwinFairchild 3 роки тому +5

    This is an amazing video I always wondered how this was done. Thank you very much hope to see more videos! Subscribed!!

  • @merondesta3895
    @merondesta3895 3 роки тому +1

    that was so helpful thankyou

  • @li-pingho1441
    @li-pingho1441 2 роки тому +1

    thank u soooo much. this video saves my life

  • @YasirAmirKhanOffcial
    @YasirAmirKhanOffcial 3 роки тому

    Remarkable! Wonderful I am speechless..

  • @Bianchi77
    @Bianchi77 2 роки тому +1

    Nice video, thanks for sharing :)

  • @engineering_design
    @engineering_design 2 роки тому +2

    I love ❤️ and subscribe your channel. Thanks very much bro and continue more deep video

  • @wfpnknw32
    @wfpnknw32 Місяць тому +1

    interesting video although just doing a standard screen cast even if it's longer would be much more useful. I feel like i have to debug this tutorial. You add in blocks and components offscreen and use keyboard short cuts without explaining how to search for components. Also things like at 12:12 where you say it's really crucial to set a value and then cover the actual screen with a blown up screen shot of a properties window (but is it the one you're talking about, is it a bug and which one is it for), below the screenshot you can see the bottom of the actual window you're editing..
    Great topic but honestly just a screen share of the whole process (sped up for bits if needed) would be much more useful. Nothing fancy just what you did is best.

  • @technopeace4077
    @technopeace4077 3 роки тому +1

    Increasing integral gain has steady state error almost zero. But when I autotune it. Increasing integral gain doesnt effect steady state error. Why?

  • @mahmoudmohamed7065
    @mahmoudmohamed7065 2 роки тому +2

    what is a gravity? why the robot is running very quickly when i run it

  • @callmeyourmum
    @callmeyourmum 8 місяців тому +2

    guys can someone help me out? everything has been working until i tried to implement the PID. the robot keeps falling down in the Y axis, has anyone had that issue before?

  • @hamedshamsikhani3345
    @hamedshamsikhani3345 Рік тому

    Thank you. could you explain how to communicate with a real 2 wheel robot and how we apply this tutorial on that?

  • @sreeharib9359
    @sreeharib9359 6 місяців тому +1

    I am having an issue, at the mid of the video, the bot is oscillating while give a +y force at p3, but mine is not oscillating, but moving and rotating at a faster pace(increasing), yes, i set the damping coeff at rotating joint. Anyway its moving but not oscillating.
    Can anyone help me with this?

  • @jonesdella5651
    @jonesdella5651 2 роки тому

    Sir, on which version is math lab simulink is 2013/2017/2020 etc... We can do this as a project

  • @mohameddiab8950
    @mohameddiab8950 2 роки тому

    how can i get the transfer function of the system from this simulation?

  • @SciHeartJourney
    @SciHeartJourney Рік тому

    Thank you, this was excellent. I don't think the student license let's us do the animation though.

  • @ChaitanyaKrishnabodduluri
    @ChaitanyaKrishnabodduluri 3 роки тому

    Nice work
    I'm naive in matlab.
    I'm just wondering what advantages do you see in simulink over ROS+Gazebo for simulation of this robot model..?

    • @hobby_coding
      @hobby_coding  3 роки тому +4

      Simulink is an educational tool and many students use it for their final year projects,so I thought i'd make a mini project in Simulink before the second semester arrives.

  • @YoyoYoyo-gh2dp
    @YoyoYoyo-gh2dp Рік тому

    If l have the mathmatical model ..how to use it in the simulink ..plz answer me

  • @Aakash3101
    @Aakash3101 3 роки тому +2

    Great work!! I was impressed by this and wanted to implement LQR controller instead of PID. Can you implement LQR controller on the body, I am having some issues doing that. I dont know how to apply the state space model to the simscape simulations.

    • @hobby_coding
      @hobby_coding  3 роки тому +1

      sure, great idea.

    • @hobby_coding
      @hobby_coding  3 роки тому +4

      i made the LQR implementation you can check it out

    • @Aakash3101
      @Aakash3101 3 роки тому

      @@hobby_coding Thank you soo much.

    • @hobby_coding
      @hobby_coding  3 роки тому +1

      @@Aakash3101 you'r most welcome

  • @technopeace4077
    @technopeace4077 3 роки тому +1

    How can I keep robot from going?

  • @khiyanatdeori5957
    @khiyanatdeori5957 3 роки тому +1

    Which block or component in the simulation is responsible for giving the force for the robot to move ?

    • @hobby_coding
      @hobby_coding  3 роки тому

      the pid controller gives the control signal which is then fed to the prismatic joint

  • @bosunwo
    @bosunwo 2 роки тому

    Hello, I enjoyed the video.
    We are currently working on a project to produce segway.
    I succeeded in copying the video with my modeling. The question is, is the p,i,d value tuned in this multibody reliable? I mean, does it automatically calculate the transfer function?
    Thank you for the video. Thank you.

    • @muhammadmubashir4682
      @muhammadmubashir4682 2 місяці тому

      did you findout your question answer i'm facing same problem

  • @tutrinhngoc4389
    @tutrinhngoc4389 2 роки тому

    but i can't find cylindrical solid in simscape

  • @erickjoelgutierrezsanchez3625
    @erickjoelgutierrezsanchez3625 3 роки тому

    Could you help me with the programming in simulink?

  • @zahraabedinzadeh9116
    @zahraabedinzadeh9116 Рік тому

    how do you see all components at 8:19?

  • @khiyanatdeori5957
    @khiyanatdeori5957 3 роки тому +1

    What sensor to be used in the actual project ?

  • @hobby_coding
    @hobby_coding  3 роки тому +16

    This simulation is available at : ko-fi.com/s/716bba8384

    • @wenhaoli6218
      @wenhaoli6218 3 роки тому

      thinks

    • @wenhaoli6218
      @wenhaoli6218 3 роки тому

      I was actually the first one to download it. Very

    • @hobby_coding
      @hobby_coding  3 роки тому

      @@wenhaoli6218 I'm glad you liked it

    • @wenhaoli6218
      @wenhaoli6218 3 роки тому

      @@hobby_coding Looking forward to your update, I will always pay attention

    • @josephj5864
      @josephj5864 3 роки тому +1

      How selfless of you. Most people would charge for something like this, but you actually help learners learn-by-project approach by making it available to other users. I subbed. Looking forward to your content.

  • @superdogmeatmeat
    @superdogmeatmeat 3 роки тому +2

    Do you know how you would go about adding two DC motors connected to the frame, which in turn are connected to the wheel? I'm trying to translate this to my real world cart.

    • @hobby_coding
      @hobby_coding  3 роки тому

      1 - other than the appearance the dynamics will remain the same so I dont see the logic behind adding motors to the model behind other than the appearance

    • @hobby_coding
      @hobby_coding  3 роки тому

      2 - if you want to do it then instead of the shaft you will build your motors and connect them together using rigid transform and then you take this model and connect it the same way to the chassis as we did in the video

    • @hobby_coding
      @hobby_coding  3 роки тому

      i think this will work

    • @superdogmeatmeat
      @superdogmeatmeat 3 роки тому

      @@hobby_coding Because I want to model my physical system? I don't have a perfect force input, I have two DC motors with gearboxes I can apply a voltage to; so I get a certain output torque.

    • @hobby_coding
      @hobby_coding  3 роки тому

      @@superdogmeatmeat try setting a maximum output for the pid bloc proportional to your dc motors max delivered force combined and then retune your pid gains

  • @SonNguyen-km6qd
    @SonNguyen-km6qd 2 роки тому +1

    Someone tell me about mathematical equation this video, please ?

  • @khiyanatdeori5957
    @khiyanatdeori5957 3 роки тому

    Can we control the positon of the Robot like you have done in the lqr video in this simulation

    • @hobby_coding
      @hobby_coding  3 роки тому +1

      Do you mean adding another PID controller ? maybe , but you need another sensor which is the motor encoders

  • @ccpjcrew
    @ccpjcrew 3 роки тому +3

    Can you make a video talking about a spherical robot?

  • @thaoton5623
    @thaoton5623 2 роки тому +2

    Can you make a video talking about used PID+Neural Network to control self-balancing robot in Simulink?

    • @hobby_coding
      @hobby_coding  2 роки тому +1

      you mean tuning pid params using a nn ?

    • @thaoton5623
      @thaoton5623 2 роки тому

      @@hobby_coding yep, I hope you will

  • @ilefmghirbi1653
    @ilefmghirbi1653 3 роки тому

    Thanks for the video, I'm facing a problem and I wanted to ask here: the mechanic explorer doesn't show any of the parts that I created it only shows a grey screen. Does anyone know how to solve that?

    • @hobby_coding
      @hobby_coding  3 роки тому

      1 - make sure you connect the model to the world frame
      2 - make sure you update the model using CTRL- D

    • @ilefmghirbi1653
      @ilefmghirbi1653 3 роки тому

      @@hobby_coding did both still no result

    • @gagankabadi299
      @gagankabadi299 3 роки тому

      Hello, facing the same issue.. And if I select auto tuning method. The dialogue box opens and it shows plant cannot be linearized. And also my model is not seen only grey screen is visible. Can you please tell me what to do?

  • @technopeace4077
    @technopeace4077 3 роки тому

    I have own Solidworks design parts and apply PID same way. But increasing integral gain doesnt have steady state error less.

    • @hobby_coding
      @hobby_coding  3 роки тому

      check your COG, it has to be somewhere in the center of the robot and not biased (to the left or the right )

    • @technopeace4077
      @technopeace4077 3 роки тому

      @@hobby_coding Thanks for reply. I understood mostly. But what does it mean as biased?

    • @hobby_coding
      @hobby_coding  3 роки тому +1

      @@technopeace4077 it means that the COG is centered regarding the x and y axis

  • @merondesta3895
    @merondesta3895 3 роки тому +1

    hello and please,in the library i cant find cylindrical solid option why is that

    • @hobby_coding
      @hobby_coding  3 роки тому

      make sure simscape is installed

    • @merondesta3895
      @merondesta3895 3 роки тому

      @@hobby_coding i have gone same steps wt the vedio simscape then multibody elements but there is only 4 options they are variable mass ,inertia ,solid, graphic
      where could i find the cylinderical solid option?please

    • @hobby_coding
      @hobby_coding  3 роки тому +1

      @@merondesta3895 i have matlab 2019b so maybe you have a different version than me

    • @merondesta3895
      @merondesta3895 3 роки тому

      @@hobby_coding yes so do i have to install that one or i can replace by other like from variable mass option lists
      thankyou

  • @muhammadmubashir4682
    @muhammadmubashir4682 2 місяці тому +1

    in this simulation you are just calculation vertical angle?

    • @hobby_coding
      @hobby_coding  2 місяці тому

      i'm calculating the tilt angle with respect to the vertical axis.

  • @ben.langlois121
    @ben.langlois121 8 місяців тому

    why is the force in the y direction when the plane of movement is the xz? Why isn't it the z?

    • @hobby_coding
      @hobby_coding  2 місяці тому

      in this simulation i only consider movement in one axis

  • @HuongHoang-ez9si
    @HuongHoang-ez9si 3 роки тому +1

    what is 12:10

  • @k1s1t7
    @k1s1t7 2 роки тому +1

    Why I can't use outotune?

    • @hobby_coding
      @hobby_coding  2 роки тому +1

      yes you can, just be careful with the output limits.

    • @k1s1t7
      @k1s1t7 2 роки тому +1

      @@hobby_coding Also, do we need to include the weight of battery and microcontroller in the simulation?

    • @hobby_coding
      @hobby_coding  2 роки тому

      @@k1s1t7 yes absolutely

  • @efarhanarif
    @efarhanarif 2 роки тому

    At 14:01 what is value of gain ?
    kindly Answer me

    • @marianaurel
      @marianaurel 2 роки тому

      he put it in the video description -----> gain block is : -180 / 3.14

  • @AbhinavSingh-ji2bg
    @AbhinavSingh-ji2bg 3 роки тому

    I'm facing a problem with my Simuscape model , I've mailed you my .slx file can you please have a look and help me in rectifying the errors

    • @hobby_coding
      @hobby_coding  3 роки тому

      please read the description first .

    • @AbhinavSingh-fq9ek
      @AbhinavSingh-fq9ek 3 роки тому

      @@hobby_coding my model is related to this only , I have made a self balancing robot in simuscape , I didn't get The correct output that's why i asked for help

    • @hobby_coding
      @hobby_coding  3 роки тому

      @@AbhinavSingh-fq9ek ok, i will take a look into it later , I'll send you the answer via mail .
      🔥 IMPORTANT : the value of the gain block is : -180 / 3.14

    • @AbhinavSingh-fq9ek
      @AbhinavSingh-fq9ek 3 роки тому

      @@hobby_coding yes sir I did put the same value of gain

  • @khiyanatdeori5957
    @khiyanatdeori5957 3 роки тому

    Why have you taken positive feedback loop instead of negative feedback loop?

    • @hobby_coding
      @hobby_coding  3 роки тому +1

      it's negative just look at the negative gain , also read the description of the video for more information about this

    • @khiyanatdeori5957
      @khiyanatdeori5957 3 роки тому

      Okay why is the initial perturbation made negative?

    • @hobby_coding
      @hobby_coding  3 роки тому +1

      @@khiyanatdeori5957 well , you can set it to positive if you want it doesn't matter which side you push the robot from, the result should be the same.

    • @khiyanatdeori5957
      @khiyanatdeori5957 3 роки тому

      Thanks a lot ❤️

    • @hobby_coding
      @hobby_coding  3 роки тому

      @@khiyanatdeori5957 you are welcome :)

  • @wenhaoli6218
    @wenhaoli6218 3 роки тому

    Is this video back on the shelves

  • @oktaysaglam2372
    @oktaysaglam2372 3 роки тому

    How can I make a contact definition on the model?

    • @hobby_coding
      @hobby_coding  3 роки тому

      you mean the robot contacting the ground? i believe there is an unofficial library made by one of the Simulink employees, I didn't have the time to implement this idea thou, maybe in the future.

    • @oktaysaglam2372
      @oktaysaglam2372 3 роки тому

      @@hobby_coding "Spatial
      The Contact Force "block creates a contact between two definitions. I'm surprised you don't know :/

    • @hobby_coding
      @hobby_coding  3 роки тому

      @@oktaysaglam2372 i think this block was introduced lately to simscape , however a couple of years ago when you wanted to achieve such a thing you had to download a library from file exchange, anyways I'm grateful to you for telling me about it , I'm definitely gonna explore this further.

    • @hobby_coding
      @hobby_coding  3 роки тому

      @@oktaysaglam2372 this i what i was talking about
      link : ua-cam.com/video/8nDqJ6skk-8/v-deo.html

    • @oktaysaglam2372
      @oktaysaglam2372 3 роки тому

      @@hobby_coding thank you brother success :D