documentation:skiros:primitive_skills

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
documentation:skiros:primitive_skills [2023/03/23 17:44] pontusrdocumentation:skiros:primitive_skills [2023/03/24 06:50] (current) pontusr
Line 1: Line 1:
 ====== Primitive Skills ====== ====== Primitive Skills ======
 +
 +This page will refer to example skills from [[https://git.cs.lth.se/robotlab/skill_examples/-/tree/master/|this]] repository written by Pontus Rosqvist.
  
 When it comes to SkiROS primitive skills are skills that perform some kind of computation which cannot call other skills. A primitive skill extends [[https://github.com/RVMI/skiros2/blob/master/skiros2_common/src/skiros2_common/core/primitive.py|PrimitiveBase]] which has the following stages of execution: When it comes to SkiROS primitive skills are skills that perform some kind of computation which cannot call other skills. A primitive skill extends [[https://github.com/RVMI/skiros2/blob/master/skiros2_common/src/skiros2_common/core/primitive.py|PrimitiveBase]] which has the following stages of execution:
Line 10: Line 12:
 | onEnd     | Once when execute has returned a terminal state.      |                                                                 | | onEnd     | Once when execute has returned a terminal state.      |                                                                 |
  
-An example which explains how to make a basic primitive skill can be seen [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/basic_primitive_skill.py|here]] and a minimal example of a primitive skill (which can often be used as a sanity check) can be found [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/minimal_skills/minimal_primitive.py|here]]. A skill can both take objects from the world model as input as well as retrieve objects from the world model directly, examples of how to do this can be found [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/update_world_model.py|here]] and [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/world_model_interface.py|here]].+An example which explains how to make a basic primitive skill can be seen in [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/basic_primitive_skill.py|basic_primitive]] and a minimal example of a primitive skill (which can often be used as a sanity check) can be found in [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/minimal_skills/minimal_primitive.py|minimal_primitive]]. A skill can both take objects from the world model as input as well as retrieve objects from the world model directly, examples of how to do this can be found in [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/update_world_model.py|update_world_model]] and [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/world_model_interface.py|world_model_interface]].
  
 ===== What to Think of ===== ===== What to Think of =====
Line 16: Line 18:
 A primitive skill should be written exactly like one would write a function while programming. It should only have one purpose, there should be good error handling and it should be well documented. A primitive skill should be written exactly like one would write a function while programming. It should only have one purpose, there should be good error handling and it should be well documented.
  
-If a skill executes code which cannot be run in less than 1/25th of a second the execution should be made in a new thread instead of the main one to avoid blocking the SkiROS gui from updating. If you want to write a primtive skill which performs its computations in a separate thread you can use [[https://git.cs.lth.se/robotlab/rvmi/skiros2/-/blob/non_blocking_pontus/skiros2_common/src/skiros2_common/core/primitive_thread.py|PrimitiveThreadBase]]. An example of how a skill could be implemented which uses [[https://git.cs.lth.se/robotlab/rvmi/skiros2/-/blob/non_blocking_pontus/skiros2_common/src/skiros2_common/core/primitive_thread.py|PrimitiveThreadBase]] can be seen [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/non_blocking_skill.py|here]]. [[https://git.cs.lth.se/robotlab/rvmi/skiros2/-/blob/non_blocking_pontus/skiros2_common/src/skiros2_common/core/primitive_thread.py|PrimitiveThreadBase]] has the same stages of execution as PrimitiveBase but onStart has been changed to preStart and instead of implementing the skill in execute you implement the skill in run.+If a skill executes code which cannot be run in less than 1/25th of a second the execution should be made in a new thread instead of the main one to avoid blocking the SkiROS gui from updating. If you want to write a primtive skill which performs its computations in a separate thread you can use [[https://git.cs.lth.se/robotlab/rvmi/skiros2/-/blob/non_blocking_pontus/skiros2_common/src/skiros2_common/core/primitive_thread.py|PrimitiveThreadBase]]. An example of how a skill could be implemented which uses [[https://git.cs.lth.se/robotlab/rvmi/skiros2/-/blob/non_blocking_pontus/skiros2_common/src/skiros2_common/core/primitive_thread.py|PrimitiveThreadBase]] can be seen in [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/non_blocking_skill.py|non_blocking]]. [[https://git.cs.lth.se/robotlab/rvmi/skiros2/-/blob/non_blocking_pontus/skiros2_common/src/skiros2_common/core/primitive_thread.py|PrimitiveThreadBase]] has the same stages of execution as [[https://github.com/RVMI/skiros2/blob/master/skiros2_common/src/skiros2_common/core/primitive.py|PrimitiveBase]] but onStart has been changed to preStart and instead of implementing the skill in execute you implement the skill in run.
  
 ===== Parameters ===== ===== Parameters =====
Line 26: Line 28:
 </cli> </cli>
  
-The keys are the names of the parameters in the skill description while the values are the parameters which were chosen in the SkiROS gui. Example of how to extract the parameters and utilize them can be seen [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/basic_primitive_skill.py|here]] and [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/update_world_model.py|here]].+The keys are the names of the parameters in the skill description while the values are the parameters which were chosen in the SkiROS gui. Example of how to extract the parameters and utilize them can be seen in [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/basic_primitive_skill.py|basic_primitive]] and [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/update_world_model.py|update_world_model]].
  
 ===== Return States ===== ===== Return States =====
Line 47: Line 49:
 </cli> </cli>
  
-An example of a skill which utilizes all of these return statements can be found [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/skill_return_messages.py|here]]. The error code which is sent when a skill fails (the integer after the message in fail and startError) does not need to be -1 but it needs to be a negative integer.+An example of a skill which utilizes all of these return statements can be found in [[https://git.cs.lth.se/robotlab/skill_examples/-/blob/master/src/skill_examples/skill_return_messages.py|return_messages]]. The error code which is sent when a skill fails (the integer after the message in fail and startError) does not need to be -1 but it needs to be a negative integer.
  
  • documentation/skiros/primitive_skills.1679593456.txt.gz
  • Last modified: 2023/03/23 17:44
  • by pontusr