带球走位
- 在 \Config\WaklKicks 目录下有一些cfg文件,记录了动作的信息。foward中为机器人小碎步向前踢球; turnOut为机器人向旁边踢球,以便于能够绕开挡在前面的敌方机器人。
- 在 \Src\Modules\BehaviorControl\BehaviorControl\Options\Output\MotionRequest目录下有一个文件InWalkKick.h ,提供了机器人使用那些cfg文件的动作的接口。调用示例如下:
#表示机器人走到球的后方160mm,左方55mm处,朝着angleToOpponentKeeperLeft方向,使用右脚以forward的方式踢球。
InWalkKick(WalkKickVariant(WalkKicks::forward, Legs::right), Pose2f(theLibCodeRelease.angleToOpponentKeeperLeft, theBallModel.estimate.position.x() - 160.f, theBallModel.estimate.position.y() + 55.f))
- 我们打开InWalkKick.h文件,发现里面使用了theMotionRequest和WalkKickVariant。
打开 \Src\Representations\MotionControl\MotionRequest.h,在使用InWalkKick时,Motion设置为walk。
上面有一个include WalkRequest.h和KickRequest.h。同样打开此目录下的WalkRequest.h文件。我们可以看到WalkKickVariant和include部分
根据include的提示,可以找到WalkKicks.h文件。里面可以找到:
- 在此处可以添加一些其他的动作,并在第一步的目录下添加对应的cfg文件。
大力射门
在上面的MotionRequest.h文件中有一个名为kick的Motion。
同样在**\Src\Modules\BehaviorControl\BehaviorControl\Options**目录下并未找到关于Kick Motion的API。因此我们需要自己编写。
- 在**\Src\Modules\BehaviorControl\BehaviorControl\Options\Output\MotionRequest**目录下创建一个文件,例如KickBigFoot.h
- 在**\Src\Modules\BehaviorControl\BehaviorControl**下的Option.h文件中添加
#include "Options/Output/MotionRequest/KickBigFoot.h"
- 打开上面的MotionRequest.h中提到的KickRequest.h,有一个名为KickRequest的STREAMABLE对象。里面有一些成员,其中有个ENUM对象,其中包含kickForward。
这个kickForward对应着 \Config\KickEngine 下面的kickForward.kmc文件。 - 根据以上说明,我们可以模仿 \Src\Modules\BehaviorControl\BehaviorControl\Options\Output\MotionRequest 中的SpecialAction.h编写KickBigFoot.h文件,让机器人踢得更远。代码如下:
#ifndef KICKBIGFOOT_H
#define KICKBIGFOOT_H
/**
* The option executes a kick generated by the KickEngine.
*/
option(KickBigFoot, ((KickRequest)KickMotionID)id, (bool)(false) mirror)
{
/** Set the motion request / kickType. */
initial_state(setRequest)
{
transition
{
if(theMotionInfo.motion == MotionRequest::kick && theMotionInfo.kickRequest.kickMotionType == id && theMotionInfo.kickRequest.mirror == mirror)
goto requestIsExecuted;
}
action
{
theMotionRequest.motion = MotionRequest::kick;
theMotionRequest.kickRequest.kickMotionType = id;
theMotionRequest.kickRequest.mirror = mirror;
}
}
/** Executes the kick */
state(requestIsExecuted)
{
transition
{
if(theMotionInfo.motion == MotionRequest::kick || theMotionInfo.kickRequest.kickMotionType == id || theMotionInfo.kickRequest.mirror == mirror)
goto setRequest;
}
action
{
theMotionRequest.motion = MotionRequest::kick;
theMotionRequest.kickRequest.kickMotionType = id;
theMotionRequest.kickRequest.mirror = mirror;
}
}
}
#endif /* KICKBIGFOOT_H */
- 调用时,格式如下:
KickBigFoot(KickRequest::kickForward)
其中kmc文件是记录踢球时动作的关键帧文件,在更早的Bhuman版本(比如2016)中,提供了一个制作kmc文件的模块。在此版本中可能需要手动调哪个文件了。