Skip to content

Commit

Permalink
[Core] add nocalibration kick to task params
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-tz committed Apr 14, 2024
1 parent d03de8f commit ef6ee87
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 85 deletions.
3 changes: 0 additions & 3 deletions Core/src/LuaModule/kickstatus.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ class CKickStatus {
CKickStatus();
void setKick(int num, double power);
void setChipKick(int num, double power);
void setBothKick(int num, double kick, double chip);
void setAllKick(int num, double kick, double chip, double pass);
bool needKick(int num) const;
double getKickPower(int num) const;
double getChipKickDist(int num) const;
double getPassDist(int num) const;
int getKiker() const;
void clearAll();
void resetKick2ForceClose(bool forceClose = false, int forceCloseCycle = 0);
Expand Down
20 changes: 6 additions & 14 deletions Core/src/Main/ActionModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,15 @@ bool CActionModule::sendAction() {
}

// 踢:有效的踢控指令
double kickPower = 0.0;
double chipkickDist = 0.0;
double passdist = 0.0;
if (KickStatus::Instance()->needKick(vecNum)) {
// 更新踢相关参数
kickPower = KickStatus::Instance()->getKickPower(vecNum);
chipkickDist = KickStatus::Instance()->getChipKickDist(vecNum);
passdist = KickStatus::Instance()->getPassDist(vecNum);
// 涉及到平/挑射分档,这里只关系相关参数,实际分档请关注 CommandSender
CPlayerKickV2 kickCmd(vecNum, kickPower, chipkickDist, passdist, dribble);
// 机构动作 <kick dribble>
kickCmd.execute(vecNum);
double kickPower = KickStatus::Instance()->getKickPower(vecNum);
double chipkickDist = KickStatus::Instance()->getChipKickDist(vecNum);
bool direct_kick_no_calibration = KickStatus::Instance()->isDirectKickNoCalibration(vecNum);
double direct_kick_power = KickStatus::Instance()->getDirectKickPower(vecNum);
CCommandInterface::instance()->setKick(vecNum, kickPower, chipkickDist, direct_kick_no_calibration, direct_kick_power);
} else {
CPlayerKickV2 kickCmd(vecNum, 0, 0, 0, dribble);
kickCmd.execute(vecNum);
CCommandInterface::instance()->setKick(vecNum, 0, 0);
}

}

/************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions Core/src/Utils/misc_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ struct PlayerStatus{
bool needkick; // 踢球动作执行开关
bool ispass; // 是否进行传球
bool ischipkick; // 挑球还是平射
bool isDirectNoCalibrationKick; // 是否是直接下发踢球时间参数给硬件(一般用于标定)
double directNoCalibrationKickPower; // 直接下发踢球时间参数给硬件的时间
double kickprecision; // 踢球朝向精度
double kickpower; // 踢球力度
double chipkickpower; // 挑球力度
Expand Down
20 changes: 0 additions & 20 deletions Core/src/Wireless/PlayerCommandV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,6 @@ double CPlayerSpeedV2::getAffectedRotateSpeed() const
return rspeed();
}

/************************************************************************/
/* Kick */
/************************************************************************/
void CPlayerKickV2::execute(int realNum){
CCommandInterface::instance()->setKick(realNum, _normal, _chip);
}
void CPlayerKickV2::toStream(std::ostream& os) const
{
os << number();
if( _normal ){
if( _pass ){
os << " pass " << _pass;
}else{
os << " kick " << _normal;
}
}else{
os << " chip kick " << _chip;
}
}

/************************************************************************/
/* Gyro(陀螺仪) */
/************************************************************************/
Expand Down
14 changes: 0 additions & 14 deletions Core/src/Wireless/PlayerCommandV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@ class CPlayerSpeedV2 : public CPlayerCommand{
double _rspeed;
};

/************************************************************************/
/* Kick */
/************************************************************************/
class CPlayerKickV2 : public CPlayerCommand{
public:
CPlayerKickV2(int number, double normal, double chip, double pass, unsigned char dribble)
: CPlayerCommand(number, dribble), _normal(normal), _chip(chip), _pass(pass){ }
virtual void execute(int);
virtual void toStream(std::ostream& os) const;
private:
double _normal; // 普通击球的力度
double _chip; // 挑球的距离
double _pass; // 传球的距离
};
/************************************************************************/
/* Gyro(陀螺仪) */
/************************************************************************/
Expand Down
53 changes: 19 additions & 34 deletions Core/src/WorldModel/KickStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CKickStatus {
/// <param name="num"> Specified vehicle. </param>
/// <param name="power"> Specified kick power. </param>

void setKick(int num, double power) { _normal[num] = power; _chip[num] = _pass[num] = 0; _kicker = num; _needKick[num] = true; }
void setKick(int num, double power) { _normal[num] = power; _chip[num] = 0; _kicker = num; _needKick[num] = true; }

/// <summary> Sets chip kick. </summary>
///
Expand All @@ -48,32 +48,24 @@ class CKickStatus {
/// <param name="power"> Specified kick power. </param>

void setChipKick(int num, double power) {
_normal[num] = _pass[num] = 0;
_normal[num] = 0;
_chip[num] = power;
_kicker = num;
_needKick[num] = true;
}

/// <summary> Sets both kick. </summary>
///
/// <remarks> cliffyin, 2011/7/25. </remarks>
///
/// <param name="num"> Specified vehicle. </param>
/// <param name="kick"> The kick distance. </param>
/// <param name="chip"> The chip distance. </param>

void setBothKick(int num, double kick, double chip) { _normal[num] = kick; _chip[num] = chip; _pass[num] = 0; _kicker = num; _needKick[num] = true; }

/// <summary> Sets all kick. </summary>
///
/// <remarks> cliffyin, 2011/7/25. </remarks>
///
/// <param name="num"> Specified vehicle. </param>
/// <param name="kick"> The kick power. </param>
/// <param name="chip"> The chip distance. </param>
/// <param name="pass"> The pass distance. </param>

void setAllKick(int num, double kick, double chip, double pass) { _normal[num] = kick; _chip[num] = chip; _pass[num] = pass; _kicker = num; _needKick[num] = true; }
// kick_mode: false for flat kick, true for chip kick
void setDirectKick(int num, bool kick_mode, double power, bool no_calibration = false, double direct_kick_power = 0){
_normal[num] = kick_mode ? 0 : power;
_chip[num] = kick_mode ? power : 0;
_kicker = num;
_needKick[num] = true;
// use for kick collect calibration data
_direct_kick_no_calibration[num] = no_calibration;
_direct_kick_power[num] = direct_kick_power;
}
bool isDirectKickNoCalibration(int num) const { return _direct_kick_no_calibration[num]; }
double getDirectKickPower(int num) const { return _direct_kick_power[num]; }

/// <summary> Check If Need kick. </summary>
///
Expand Down Expand Up @@ -101,14 +93,6 @@ class CKickStatus {

double getChipKickDist(int num) const { return _chip[num]; }

/// <summary> Gets the pass distance. </summary>
///
/// <remarks> cliffyin, 2011/7/25. </remarks>
///
/// <returns> The pass distance. </returns>

double getPassDist(int num) const { return _pass[num]; }

/// <summary> Gets the kiker. </summary>
///
/// <remarks> cliffyin, 2011/7/25. </remarks>
Expand All @@ -127,7 +111,8 @@ class CKickStatus {
_needKick[vecNum] = false;
_normal[vecNum] = 0;
_chip[vecNum] = 0;
_pass[vecNum] = 0;
_direct_kick_no_calibration[vecNum] = false;
_direct_kick_power[vecNum] = 0;
}
_forceClose = false;
_forceCloseCycle = 0;
Expand Down Expand Up @@ -159,12 +144,12 @@ class CKickStatus {
/// <summary> The chip kick distance </summary>
double _chip[PARAM::Field::MAX_PLAYER]; // 挑球的距离

/// <summary> The pass kick distance</summary>
double _pass[PARAM::Field::MAX_PLAYER]; // 传球的距离

/// <summary> Need kick flag </summary>
bool _needKick[PARAM::Field::MAX_PLAYER];

bool _direct_kick_no_calibration[PARAM::Field::MAX_PLAYER];
double _direct_kick_power[PARAM::Field::MAX_PLAYER];

bool _forceClose;

int _forceCloseCycle;
Expand Down

0 comments on commit ef6ee87

Please sign in to comment.