5.0

5.0 | 2 ratings Rate this file 75 Downloads (last 30 days) File Size: 399.84 KB File ID: #28196
image thumbnail

Robot Soccer: An Exercise in Learning the Key Features of Simulink

by Saurabh Mahapatra

 

13 Jul 2010 (Updated 21 Oct 2010)

Demo files to accompany the Introduction to Simulink webinar

| Watch this File

File Information
Description

This demo helps you apply the key features of Simulink that are discussed in the "Introduction to Simulink" webinar:

http://www.mathworks.com/company/events/webinars/wbnr37271.html

The demo was specifically built using the features and concepts that are shown in the webinar; modeling a simple continuous system, adding nonlinearities, including documentation, using subsystems, masking, model reference, buses etc.

If you are new to Simulink, it is recommended that you watch the webinar before you try out the exercises and look to implement new strategies for the game.

Additional notes accompanying the demo. These notes have been intentionally kept fuzzy and listed in random order as it is expected that you will explore the model to understand all the components and their interaction with each other.

1. The demo simulates a 2 vs. 2 robot soccer match. The robots are assumed to be heavier than the football. Thus, any collision between the ball and the robots is perfectly elastic. The robot’s motion is not impacted by the collision.

2. Collision among robots is not implemented as they are considered as point masses.

3. Collision modeling in all cases is assumed to be as a spring contact model. When the object colliding with a boundary comes close to that boundary, a force proportional to the negative of the "penetration distance" is computed.

4. The strategy subsystems are implemented as referenced models. This was done intentionally so that competing teams could protect their strategies and run the simulation against each other. You can use the model reference protected mode to generate a mdlp file instead of mdl file (introduced in R2009b):

>> Simulink.ModelReference.protect('Team_1_Strategy')

and

>> Simulink.ModelReference.protect('Team_2_Strategy')

5. Robot dynamics are simple dynamics of a point mass. However, the mass is inversely proportional to the battery power or "stamina" of the robot. Some damping is also put into the system to avoid too much overshoot. Also, each time the robot actuates itself or brakes, it incurs a small power loss thereby lowering its endurance in the game.

6. Positional coordinates in the system are 2D i.e. (x,y). The signal dimensions have been set explicitly. Click on any of the output ports->signal attributes of the masked subsystems to see the dimensions.

7. Ball dynamics has a simple implementation- same "spring-based" contact dynamics. From the ball's point of view, there are five contact forces to be accounted for: contacts with the 4 robots and those of the boundaries.

8. Observe that the solver has been changed to ode15s which is a stiff solver. The reason for this is that there is stiffness present in the system because of the contact/collision modeling with high spring constants. This can give rise to modes with relatively different dynamics. With a ode45 solver, the faster modes will force the adaptive solver to take smaller steps slowing the simulation down. ode15s ignores some of these fast dynamics.

9. All the icon drawing commands on the robot dynamics subsystems were implemented using the MATLAB patch commands. These were taken from the flags demo by Mike Woodward:

http://www.mathworks.com/matlabcentral/fileexchange/8856-flags

Use other flags to customize this.

10. 2D animation was done using Simulink 3D Animation. The field was textured with a grass image and a viewpoint was so selected so that it looked as 2D. The "GOAL" text was kept behind the field. The moment, a goal is scored, this text is translated to the front giving a TV effect. Texturing was also used to paint the bodies of the robots with the flags. You will have to change the images in order to change these.

11. Play around with the strategy subsystems to see if you can come up with efficient strategies to score goals early. Note that each of the teams has full knowledge of the others' positions and those of the ball. They also have knowledge of the remaining power in their team's batteries. There is no velocity information available.

12. You need Simulink 3D Animation installed to view animation.

Exercises for you to try out:
1. How can you use Stateflow to implement a finite state machine that uses a mix of attack and defensive strategies based on ball location?

2. What block in Simulink should you use to input a new signal into these strategy subsystems so that time elapsed since the start of the game can be measured and hence be used as part of the strategy?

3. Identify the contents inside the MAT file used in the demo. What is the "type" of the contents of the data inside the file? Identify the function that loads this MAT file. Why did we need these data objects in our model?

4. Explore the possibility of using control strategies, like PID, to improve robot tracking

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Flags

Required Products Simulink 3D Animation
MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
13 Jul 2010 Saurabh Mahapatra

The author would like to acknowledge help and support from Parasar Kodati in improving and debugging this demo:

http://www.mathworks.co.kr/matlabcentral/fileexchange/authors/31762

14 Jul 2010 Saurabh Mahapatra

A variety of videos on robot soccer that show similar games:

http://www.youtube.com/watch?v=awWDPoKwZIY&feature=related

http://www.youtube.com/watch?v=0xiX3Fdo-AM&feature=related

20 Sep 2010 Saurabh Mahapatra

Design Talk: Enhancing Simulation Studies with 3D Animation Article

http://www.ecnmag.com/Articles/2010/09/Design-Talk/Enhancing-Simulation-Studies-with-3D-Animation/

10 Oct 2010 Saurabh Mahapatra

You can now follow me on Twitter:

http://twitter.com/simulinkdude

21 Oct 2010 Saurabh Mahapatra

Please look for the r2010b folder for the version to use with r2010b.

21 Oct 2010 Saurabh Mahapatra

Starting in R2010b, the Bus object specification is unified into Datatype specification. This and a stricter interface requirement for Embedded MATLAB can lead to errors when running the demo in R2010b. We updated the bus type specification of input ports in the Strategy reference models and added a Bus to vector before Embedded MATLAB processing. Also note that the Bus Power signals from team subsystems to the strategy ref. models are currently unused. Someone can use this for advanced strategies.

21 Apr 2011 yuli zhang

Thanks for such one good code.

31 Jul 2011 rajat bajpai  
28 Sep 2011 Mr Smart  
29 Sep 2011 Mr Smart

I have error when I ran RoboSoccer.mdl
>>Error evaluating parameter 'OutDataTypeStr' in 'Team_1_Strategy/Power': Undefined function or variable 'Bus_Power'.
>>Error evaluating parameter 'OutDataTypeStr' in 'Team_1_Strategy/Robot Position': Undefined function or variable 'Bus_Robot_Positions'.

Please login to add a comment or rating.
Updates
13 Jul 2010

Fixed minor coding bug.

13 Jul 2010

Minor bug fix.

03 Aug 2010

Added the link to the recorded version of the live webinar.

21 Oct 2010

Starting in R2010b, the Bus object specification is unified into Datatype specification. This strict interface requirement for Embedded MATLAB can lead to errors when running the demo in R2010b.

Tag Activity for this File
Tag Applied By Date/Time
simulink Saurabh Mahapatra 13 Jul 2010 15:48:03
introduction Saurabh Mahapatra 13 Jul 2010 15:48:03
webinar Saurabh Mahapatra 13 Jul 2010 15:48:03
robot Saurabh Mahapatra 13 Jul 2010 15:48:03
soccer Saurabh Mahapatra 13 Jul 2010 15:48:03
football Saurabh Mahapatra 13 Jul 2010 15:48:03
ice Saurabh Mahapatra 13 Jul 2010 15:48:03
hockey Saurabh Mahapatra 13 Jul 2010 15:48:03
multagent Saurabh Mahapatra 13 Jul 2010 15:48:03
multiple Saurabh Mahapatra 13 Jul 2010 15:48:03
collaborative Saurabh Mahapatra 13 Jul 2010 15:48:03
control Saurabh Mahapatra 13 Jul 2010 15:48:03
fine Saurabh Mahapatra 13 Jul 2010 15:48:03
theory Saurabh Mahapatra 13 Jul 2010 15:48:03
machine Saurabh Mahapatra 13 Jul 2010 15:48:03
visualization Saurabh Mahapatra 13 Jul 2010 15:48:03
animation Saurabh Mahapatra 13 Jul 2010 15:48:03
3d Saurabh Mahapatra 13 Jul 2010 15:48:03
ball Saurabh Mahapatra 13 Jul 2010 15:48:03
competition Saurabh Mahapatra 13 Jul 2010 15:48:03
game Saurabh Mahapatra 13 Jul 2010 15:48:03
state Saurabh Mahapatra 13 Jul 2010 15:48:03
simulator Saurabh Mahapatra 18 Jul 2010 10:42:37
robocup Saurabh Mahapatra 18 Jul 2010 10:42:37
robotics Saurabh Mahapatra 18 Jul 2010 10:42:37
robot soccer yuli zhang 21 Apr 2011 20:47:37
football navaneethakannan ganesan 28 Apr 2012 05:55:51

Contact us at files@mathworks.com