BEST Robotics Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
esmith

Junior Member
Registered:
Posts: 3
Reply with quote  #1 
Hello, I am a teacher who is working toward learning programming so I can pass that knowledge to my students. Please forgive me if my question is elementary, but I just started working with Simulink during last year's BEST competition. Before that, I'd never been exposed to coding with Simulink.

I have recently been trying to learn to write autonomous programs with state flow. The first state flow chart I wrote will work through several states, then stop for no reason that is apparent to me. I will attach images of the chart along with the image of the simulation. state flow.PNG 

state flow2.PNG 

The simulation shows that all of the states work up to the last travel state. The way the chart is written, I am trying to move in a square shape beginning at the top left corner, then travel diagonally to the lower right corner. I guess my question is: Why will all of the states work except the last "diagonal_travel" state? I've looked at syntax and can come up with nothing.

I'd appreciate any help with this.
Espy Smith
Early County High School

0
shiremath

Moderator
Registered:
Posts: 78
Reply with quote  #2 
Espy,

That's a great question. In fact, there was an example that I shared of a similar model in a Simulink webinar (recording is here) last year. Wondering if you followed that to get to this example.

In any case, based on the image of the Stateflow chart that you have above, I put together something similar that seems to work for me. Not sure exactly why in your case the state for diagonal travel is not executed. I cannot see any possible reason for it to fail execution, it most possibly is being executed but its output may not be visible in the XY plot window?

Could you try the model attached (Zip file) and let me know if this works for you? I have optimized the repetitive forward and turn motions to achieve the square with just 2 states. Then, the right side set of states achieve the diagonal turn and travel. Note 2 things here-
1) I use a diagonal turn value of 1.7/2 and that gives me half the turn angle of 90 degrees 
2) I use 2*sqrt(2) to get the travel to be equal to the diagonal length of the square...basic math


This should get me to the lower right corner of the square. See the simulation results in the GIF below:
96F999FC-1BED-4C39-9019-06B74DE6A824.GIF 

You may have to adjust these values a little bit to make it work in your case but it should work after that. 
Let me know if this particular model works for you or not.

If you send me your particular model (.slx file) at bestrobotics@mathworks.com, I can look at it in detail and get back to you.

Thanks
Sandeep 


Simulink model screenshots:

SF_PolygonBot_DiagonalParent.PNG 
SF_PolygonBot_Diagonal.PNG

 
Attached Files
zip polygonBot_GoDiagonal.zip (28.94 KB, 1 views)

0
esmith

Junior Member
Registered:
Posts: 3
Reply with quote  #3 
Sandeep, your program did work correctly for me. I really appreciate the help.

Currently, I am not at the point of writing programs that involve working with counts and am just trying to feel my way through simple programs that I can teach my students. I'd rather have them learn the basics before moving on to more complex functions.

With state flow, we are working to learn the different commands (i.e. entry;during;etc) before moving on to more advanced logic. In learning these more advanced functions, though, I plan to dissect your program to learn how the commands you used affect the function of the robot.

Thanks again,
Espy Smith
0
shiremath

Moderator
Registered:
Posts: 78
Reply with quote  #4 
I understand the need to start with the basics for your team. Yes, feel free to use the model as you see fit. If you need help with designing more examples in the future, please post here. 

Good luck!
Sandeep 
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.