Doubt In Simulink Commands
3 次查看(过去 30 天)
显示 更早的评论
Hello.
I'm building a model in Simulink for having a vehicle going around a certain trajectory, described below:
- 20m straight line;
- Left-hand turn of 9.125m radius (2 laps);
- Right-hand turn of 9.125m radius (2 laps);
- 20m straight line.
If you picture the path correctly, it should look line an 8 with a straight like in between. This is the trajectory that I want to make the car execute, but the trick is, I can't build it as a time function, but as a function of the travelled distance. I already know the equations that must be implemented in order for the car to execute it, but the way I'm trying to implement them in Simulink is what is giving me headache. Let me try to explain.
Inside a subsystem, I had built the logic for the parametric equations that describe this trajectory. These equations are accounting for a certain angle of the vehicle, the yaw angle, or attitude angle. In other words, the angle that the longitudinal direction of the vehicle assumes with respect to the line of the track. Analyzing the path it takes, this angle should start from zero, then increase linearly until 720°, then decrease linearly until zero again, until the end of the simulation. But, as it starts to decrease from 720° (it actually overshoots a little), it reaches again the value of 720°, and reclicking the Switch blocks. This makes the vehicle reimpose the steering wheel angle at the left-hand turn value, which tries again to decrease to the right-hand turn one, causing the same thing over and over again, until the simulation ends. So, the trajectory becomes a 20m straight line, a 9.125m left turn, and a tiny sinusoidal "straight" line.
It could be simply solved if Simulink had a one-time only Switch command. I had already tried implementing the logic on an embedded MATLAB command block, but I believe my version of MATLAB doesn't allow me to use that resource (R2009b). What can I do to fix this problem? I need help!
0 个评论
回答(2 个)
Kaustubha Govind
2012-8-16
I think that simply using a Switch block for this won't do - there might be several ways of solving this problem (one of which might be a Stateflow chart if you have access to a Stateflow license). For example, an alternate way might be to use some combination of Conditionally Executed Subsystems. For example a triggered subsystem that is executed on the rising edge of (yaw-720) which produces a right-turn when yaw hits 720° in the rising direction only.
0 个评论
Jobin Geevarghese Thampi
2022-4-16
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/966625/image.jpeg)
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!