This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision |
documentation:skiros:primitive_skills [2023/03/23 17:59] – pontusr | documentation:skiros:primitive_skills [2023/03/24 06:50] (current) – pontusr |
---|
====== Primitive Skills ====== | ====== Primitive Skills ====== |
| |
This page will refer to example skill from [[https://git.cs.lth.se/robotlab/skill_examples/-/tree/master/|this]] repository written by Pontus Rosqvist. | 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: |
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 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 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 ===== |