Now we have pretty good idea about Simulink project and it's models. state_machine_with_obstacle.slx is even more powerfull and model a controller which receives signals not only from the sensors on the front of the robot, but also from the bumbers and wheels, making robot able to hit obstacles and possibly go around them.The state machine is very simple, yet powerful. All of them are wired as inputs into the state machine which has only two outputs (used to control the robot) and these are speed and radius. state_machine.slx is a controller build using Stateflow package and opposite to all previous models it actually uses all the signals, coming out from the robot sensors.If we run the simulation, robot is able to follow the line. It also possesses Rate Transition ( TODO research deeper) which somehow transfer data between signal sent and plant input port. simple_discrete.slx is a variation of the model mentioned above, but with FixedStepDiscrete solver.If we run the simulation, robot moves few units, passes finish line and stops. There are two simple switches for sending signal of 100 units, -100 units or 0 units into the robot plant. It seems that it can go forward, backwards and stop. Uses 2 signals as a feedback from the plant (medium and right sensor). simple.slx is only simple feedback control.The only command, which is given to the plant of the robot is constant speed 200 units (so the robot will just run forward until it will crash, start burning and evantually explodes). It doesn't use any of the signals from the plant as input. no_control.slx presents a case when the robot is not being controlled.It uses FixedStepDiscrete solver, whatever it is. Still it uses only 1 signal from the plant as input to the controller. It has different discrete time integrator function and there is rate Rate Transition block in addition. controller_discrete.slx is slightly different.This model is of course runnable, we can start a simulation if we specify step size (or we can set it to auto and Simulink will use ode45 solver and sets step size to 0.01). This is done by Simulink basic blocks (constants, sums, integrator, math function, etc.). Uses only one signal from the plant as input (feedback). controller.slx is a definition of a logic, which controls robot plant on the track.Under the folder models is the most interesting stuff: Simulink. It defines it's inputs, outputs and transformation function. In this case flib together forms a plant of a robot. If we would like we can even add pictures and schematics! See this tutorial. Without masking, models are only spagetti net of basic Simulink mathematical blocks and user defined components but masking helps us to wrap logical units (such as DC motor, robot plant, adapter, converter, engine, control unit, etc.) into atomic Simulink blocks. Masking is very useful because it makes model appear more real for other engineers.After you write your S-function and place its name in an S-Function block (available in the User-Defined Functions block library), you can customize the user interface using masking. They are practically blocks of your own funcionalitty which can do whatever you design them to do. By following a set of simple rules, we can implement an algorithm in an S-function and use the S-Function block to add it to a Simulink model. S-functions follow a general form and can accommodate continuous, discrete, and hybrid systems. C, C++, and Fortran S-functions are compiled as MEX files. S-function block An S-function is a computer language description of a Simulink block written in MATLAB®, C, C++, or Fortran.Under utilities folder there are MATLAB scripts which set up and clean the project + test script.įolder track contains data of the particular tracks + their images (images load to the simulation so it seems that the robot is going around the track.įolder flib contains definition of a S-function block. Simply open this file in MATLAB and automatic scripts and MATLAB compilator will do the rest for you.
It is a model of a small robot, that is supposed to follow a line drawn on the floor.Īs can be seen on the following image, the project is divided into several directories, plus there is the LineFollower.prj file which is very important, because is should be used as a key for opening the project. Line follower projectįirst project that I have tested in Simulink was The Line follower project. Downloading and opening Simulink projects in MATLAB R2017b 1.