1 / 17

IN.1010, IN.0111, IN.0114, IN.1910, IN.0300 Robotics Project Autumn Semester 2013

IN.1010, IN.0111, IN.0114, IN.1910, IN.0300 Robotics Project Autumn Semester 2013 Lecture 3 : Energy Management Prof. B. Hirsbrunner (beat.hirsbrunner@unifr.ch) Thomas Rouvinez (thomas.rouvinez@unifr.ch). Today. Quick review Goals Debugging Conditional statements Boolean values

roxy
Télécharger la présentation

IN.1010, IN.0111, IN.0114, IN.1910, IN.0300 Robotics Project Autumn Semester 2013

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IN.1010, IN.0111, IN.0114, IN.1910, IN.0300 Robotics ProjectAutumn Semester 2013 Lecture 3: Energy Management Prof. B. Hirsbrunner (beat.hirsbrunner@unifr.ch) Thomas Rouvinez (thomas.rouvinez@unifr.ch)

  2. Today • Quick review • Goals • Debugging • Conditional statements • Boolean values • Events with several arguments • Energy pool • Exercise

  3. Quick Review (1)

  4. Quick Review (2) • How can we store integers in ASEBA? • Will this code run? demo_table[5] demo_table = 1, 2, 3, 4, 5 • Which operators do we have? • Why are arguments useful for events?

  5. Goals of Today's Course • Debugging in Aseba • Programming language basics: • Conditional statements • Events with several arguments • Using native functions • Using and managing an energy pool with the e-pucks

  6. Debugging • Debugto find errors in implementedalgorithms • Controltheexecutionoftheprogram • In ASEBA • Stoptheprogramduringexecutionwith break points • Observethecontentof different variables duringexecution • Emitcontroleventsatcertainpoints • Controlexecutionofprogramcode

  7. Debugging 1. break points 2. observe variables 3. control events 4. execution

  8. Conditional Statements (1) • Only execute a portion of the instructions depending on a condition: var limit = 20 var demo_variable = 10 if demo_variable < limit then demo_variable = demo_variable + 1 end

  9. Conditional Statements (2) • Choose a different setofinstructionsdepending on 'if' condition : trueorfalse varlimit = 20 vardemo_variable = 10 ifdemo_variable < limitthen demo_variable = demo_variable + 1 else demo_variable = limit end

  10. Comparison Operators if demo_variable == limit then # equals if demo_variable != limit then # is different from if demo_variable > limit then # is larger than if demo_variable < limit then # is smaller than if demo_variable >= limit then # is larger or equal if demo_variable <= limit then # is smaller or equal

  11. Combined Conditionals • Both conditions have to be met: if (demo_variable >= lower_limit) and (demo_variable <= upper_limit) then ... • At least one condition has to be met: if (demo_variable == lower_limit) or (demo_variable == upper_limit) then ... • Negative condition: if not (demo_variable >= upper_limit) then

  12. Boolean Values • Boolean valuescanonlybetrueorfalse • Manyprogramminglanguageshavesupportforbooleans, but ASEBA doesn't • In ASEBA, youcanuseconstants varis_changed = FALSE varis_blue = TRUE

  13. Event Arguments • A robot can send an event to other robots with 0 to 32 arguments: var one_arg = 1 var multi_args[2] = 10, 20 emit create_no_arg emit create_one_arg one_arg emit create_multi_args multi_args Number of arguments

  14. Energy Pool (1) • Use of native functions: • Predefined functions and functions written in C • Native functions are called with the keyword ‘call’ • Native functions take their arguments by reference, i.e. their value can be changed in the function • No return value Note: C supports only argument passing by value, i.e. their value cannot be changed in the function. Call-by-reference is simulated in C by passing an address.

  15. Energy Pool (2) • Native energy functions: • send: send energy into the pool (can only be called if energy in the e-puck > 9) • receive: receive energy from pool • amount: get the amount of energy available in pool var pool_amount = 0 call energy.send(5) call energy.receive(5) call energy.amount(pool_amount)

  16. Exercise Session 3 • Complete the exercise series 3 and hand in your solution by next Monday at 2 pm.

  17. Thank you for your attention

More Related