Tuesday, 31 May 2011

Platform : Physic representation & Real Time

Today, I'm going to speak about the physic representation I chose to model movements in the 2D world, and which I spoke with John last meeting, and, following this, issues I met and choices I made about "Real Time" implementation.


Physic representation

On the platform, each element (including World elements like balls and robots) has different parameters to model its evolution in the world :
  • Position : Two coordinates to place the element in the world.
  • Direction angle : When moving, the element itself knows in which direction it is going to move. So, you only have to change this parameter to turn aside an element.
  • Direction : An element not necessarily move forward. Currently, "1" is the default value for forward and "-1" the one for backward. But using this, you could model for example crab robots which would move on the side.
  • Speed : Based on reality, this parameter enables movements when different from 0. ( I"ll explain after how it does works ).
  • Rotation Speed : Similar to the speed, this parameter is for rotation of elements. Mainly used by robots, this could be used by spinning top or balls.
  • Acceleration : For the moment, speed is enough to model constant speed movements. However, acceleration may be used later to vary speed automatically.
Using this, the ElementManager class refreshes the world regularly by using a Timer, with a specified value of refreshTime.
Each time, the system calls the updatePosition() method for each element.
This method checks the speed of the element, and, if it's not 0, moves it from its position to another calculated using a simple formula with direction, speed, and direction angle (combined with trigonometric functions). ( It works even more simple with rotationSpeed. )


So, commands like Move or Rotate only act on those speeds, this is actually the element which moves itself.

More explainations will be given it the following part.

Real Time

The code here is a bit more complex than the other parts, that's why I would like to develop it.

First solution - Issue

As I said before, the software refreshes regularly the world, using a specified interval. The first solution, suggested by some pool software, is to simply divide a movement by the number of intervals needed, to have a movement in real time.
However, this method involves approximations.
Let's suppose the refresh time is 1 second, and let's add an element which covers 5 meters in 6 seconds.
The movement will be divided into 6 parts, as the figure shows.
In this case, this would be correct using floats, but if you use non integer refreshTime, added to approximations using cosinus/sinus, and more complex divisons, this creates a lot of imperfection :
So, while testing, a slow rotation of 10° led to an actual rotation of 9°.

For the platform, which requires precise movements, this wasn't good, that's why I used a more complex solution.

Second solution 


Instead of dividing the movement, the choice I made was to recalculate the whole movement each refreshTime :

On the last example, this leads, at least, to the exact position.

So, to model this, elements have to know a few values: the distance they have to cover, but also the total number of updates needed (6 here), and the current update.
Moreover, the elements must stock their initial position to recalculate it each time.
Here are the new parameters :
  • distanceToCover
  • updatesMoveRequired
  • currentMoveUpdate
  • TmpPosition : Initial value, updated when the movement ends or is diverted.
Another version of these parameters is needed for rotation.

Can't we calculate these values apart from Element class ?
I searched a more simple way to code this. However, with this representation, the system only calls updateElement() method each refresh time without any parameters, so this is impossible to specify each time a value for each element.


-----
I'm stopping here for today. The collision part I'm working on will probably need some explanations as well.

    Tuesday, 24 May 2011

    24/05/2011 Updates

    Following the meeting with John on Friday, 20th, May :
    • Vocabulary corrections : 
      • Basic robot operations :   "Tasks" are know called "Commands"
      • Complex sequences of commands : "Simulations" are know called "Tasks"
    • AI implementation into the MVC structure has been reviewed into the Class Diagram ( the diagram isn't updated for methods and attributes in order to be less complicated )
    • The Planning has also been reviewed to work on the platform and on the LeJOS API at the same time.
    On Google docs, PDF files have been replaced by editable formats so that you can know directly edit them.

    About the code, on John request, I'll write regularly main issues I met, and solutions I found / choices I made if there are. Here are the first :
    • How quickly accessing to a specific Robot/Element/Command ?
      • Solution : Lists of robots and elements are represented in Board class as two Hashtables which contain Strings (names) as keys. Same thing for commands in Robot class.
    • How modeling direction vectors ?
      • Choice : There are two solutions : using two integers for the Vector, or one for the angle. I chose the angle. Using degrees angles is the easiest for a user. However, as compensation, angles involve the use of trigonometric functions, more complex than simple operations.
    •  About element holding, where shall I stock the elements ?
      • Choice : After hesitating on stocking it on Hold Command (not really logic) or on robot (contradict the OOP), I finally made a sub class HolderRobot. However, Drop and Hold commands are now specific to Holder Robots, which contradict the OOP as well...
    About the software, there is currently a basic visual interface with control panel that enable user to choose robot, configured command ( move, rotate, hold nearest element, drop it), and do it. 

    Wednesday, 18 May 2011

    Report : Meeting with François

    18/05/2011 Update 
    At the conclusion of this meeting about corrections to do, some documents have been modified :
    • Expression corrections on Planning, Project Scope Statement.
    • Titles in the List of Features were reduced, and explicit descriptions of the features were added to the Project Scope Statement.
    • A new section about skills was added to Project Scope Statement.
    • Work Break Structure was remade and inserted to Project Scope Statement as imbricated enumeration lists.

    Monday, 16 May 2011

    Documents for project

    16/05/2011 Update
    First, some documents updated in Croquet Project Management collection :
    • List of Features : I assigned the tasks I'm planning to do for the project during the intership (either because the software can't work without these ones, or because these are ones I would like to do). The working time for these features is evaluated with the WBS.  
    • WBS, updated for the first features to be done.
    • Planning : the first version I made for the internship work.
    I also added new diagrams specific in  Croquet Project Software Engineering, using UML language, that must be validated and modified if necessary before starting (if you don't have the time to read them, I can present you later). Anyway, I may write some explications about it for following project students :

    • Use Case Diagram, whose aim is to present all interactions the software will implement with users.
    • Class Diagram, that presents classes I plan making, and how they interact in the software.

    Thursday, 12 May 2011

    Project management documents

    12/05/2011 Update
    Here is the list of documents added in my Google documents, in Croquet Project Mangament collection :
    • PDF : Project Scope Statement, including the list of requirements for the project.
    • PDF : Croquet Robot Building, a document François talked me about, in order to have a follow-up of the croquet robot building versions with photos and probably videos in the future (hoping you'll like the temporary name I gave to it !).
    • PDF : WBS, a really succinct version of the WBS, while waiting the features I'll handle.
    • Spreadsheet : List of Features, list based on the brainstorming and first meetings discussions, which I add some ideas.

    First news

    Welcome to my blog about the Croquet Robot Project.
    The aim of this blog is to centralize all the project updates and meeting contents during all the project.
    All the linked documents will be available in my Google documents (for those who are permitted to access).

    The blog is currently not open to the public, so feel free to leave comments, or even to publish news, to avoid sending too much mails.