Motion Framework¶
The motion framework uses the so called MotionPhase
, which implements a few functions and are used in a control cycle of the module MotionEngine
. Different modules implement different versions of the MotionPhase
, which can be created by the so called MotionGenerators
. The overview is seen below.
The MotionEngine
takes the representation MotionRequest
from the behavior and acts accordingly.
For it the MotionEngine
will always first update the currently active MotionPhase
, to let it know a motion frame passed.
Afterwards the isDone
-function is used to determine, if the active MotionPhase
can be stopped and a new one can begin.
If so the MotionGenerators
are used with the MotionRequest
to create a new MotionPhase
.
Additionally the until now active MotionPhase
can also create a new one, which then overwrites the one from the MotionGenerators
.
Afterwards the head and arm joints are determined and last but not least the active MotionPhase
is used to determine the rest of the joints.
This motion cycle is illustrated below.
Adding New Motions¶
The B-Human system supports different motion types like walking, kicking or getting up. One may add more motions, which shall be executable from the behavior. To achieve this the new motion must be added to the following files:
Src/Representations/MotionControl/MotionRequest.h
: add your motion to the enumMotion
and other new parameters to theMotionRequest
Src/Representations/MotionControl/
: add a representation which inherits fromTools/Motion/MotionGenerator.h
Src/Modules/MotionControl/
: add a module, which will provide the added representationSrc/Modules/MotionControl/MotionEngine/MotionEngine
: add the representation asREQUIRES
and add it to thegenerators
listSrc/Representations/BehaviorControl/SkillInterfaces.h
: add a skill that sets theMotionRequest
motion and the other new parametersSrc/Modules/BehaviorControl/SkillBehaviorControl/Skills/Output/MotionRequest/
: add the implementation of your skillConfig/Scenarios/*/threads.cfg
: add the provider for the new representation
Motion Coordinate System¶
All necessary information for Motion
comes from the representation MotionRequest
.
It is generated by Cognition
and is relative to the TorsoMatrix
of the robot at the time the MotionRequest
was last updated.
Therefore the robot can be in different configurations.
To accurately determine the ball position relative to the robot which is compatible to how the WalkingEngine
functions, a transformation is needed to convert the robot relative coordinates (from the MotionRequest
) into walk step relative coordinates.
As a walk step size is always relative to the current support foot, the transformation must calculate how the robot would move IF it would execute the step size of 0 rotation and 0 translation.
This transformation is visually shown below.
A transformation function is provided in Tools/Motion/Transformation.h
.
We assume a support foot switch occurs and the left foot will be the swing foot.
In the state Cognition Coordinatesystem
the ball is relative to the robot and therefore relative to its TorsoMatrix
, which is defined by the middle point between both feet and the average yaw rotation of both.
The state Motion Relative Start
shows where the left foot would be if a step size of 0 would be executed and where its coordinate system lies within the current one.
The state Motion Transformation
transforms the coordinate system in a way, that the would be TorsoMatrix
is now at the coordinate point (0,0) with a straight alignment.
This results in a completely different ball position.
Previously its position was far away to the right side and now it is directly in front of the left foot.
With this transformation we can now correctly plan the walking steps or walk kicks.
Note that at no point a walk step was executed yet.
This is all done just to get the correctly transformations of the world around the robot, like the ball, to correctly calculate the walk steps.
For example to kick the ball a simple walk step of 0 rotation, a few centimeter forward and 0 to the side would be sufficient.
In the real world the robot would directly go from the starting state Cognition Coordinatesystem
to execute the forward step, without first returning the swing foot parallel to the support foot.