SEU类人机器人代码解释

  1. 流程

整体处理流程

  • main.cpp -->从play.cpp中进入run()-->think()-->play_with_gc/play_without_gc-->fsm:tick()-->run()-->.....

  • 在fsm:tick()中调用传感器的数据WM、WE、VISION...


  1. 宏定义

  1. WM-->WorldModel

世界模型,具体定义在worldmodel.cpp和worldmodel.h文件中;

WM->set_my_pos(temp); //设置当前位置,temp是Vector2d

WM->gc_data(); // 得到比赛状态,有如下信息

char header[4];               // header to identify the structure
  uint16_t version;             // version of the data structure
  uint8_t packetNumber;         // number incremented with each packet sent (with wraparound)
  uint8_t playersPerTeam;       // the number of players on a team
  uint8_t gameType;             // type of the game (GAME_ROUNDROBIN, GAME_PLAYOFF, GAME_DROPIN)
  uint8_t state;                // state of the game (STATE_READY, STATE_PLAYING, etc)
  uint8_t firstHalf;            // 1 = game in first half, 0 otherwise
  uint8_t kickOffTeam;          // the team number of the next team to kick off or DROPBALL
  uint8_t secondaryState;       // extra state information - (STATE2_NORMAL, STATE2_PENALTYSHOOT, etc)
  char secondaryStateInfo[4];   // Extra info on the secondary state
  uint8_t dropInTeam;           // number of team that caused last drop in
  uint16_t dropInTime;          // number of seconds passed since the last drop in. -1 (0xffff) before first dropin
  uint16_t secsRemaining;       // estimate of number of seconds remaining in the half
  uint16_t secondaryTime;       // number of seconds shown as secondary time (remaining ready, until free ball, etc)
  TeamInfo teams[2];

WM->self().dir;// 自身角度float

WM->no_power_;//有无电 bool

WM->fall_data();//是否掉落 bool

WM->ball();//球的信息 float alpha, beta; // alpha:左负右正;beta:上小下大

WM->localization_time_;//本地时间???每600步true一次

WM->opp_post_left; // 左球门位置

WM->opp_post_right; // 右球门位置

WM->self().global; //自身全局位置

WM->self().dir; // 自身角度 float

WM->button_status(2); //按钮2的状态 bool

WM->imu_data(); // imu的数据

float pitch=0.0, roll=0.0, yaw=0.0;
float ax=0.0, ay=0.0, az=0.0;
float wx=0.0, wy=0.0, wz=0.0;
int timestamp=0;

WM->imu_data().timestamp;//IMU未更新时间

WM->posts1();//球门位置 float alpha,beta; // alpha:左负右正;beta:上小下大

WM->set_ball_pos(temp_ball, ball_pos, ball_pix, alpha, beta, true);//对球的位置设定

WM->set_post1_pos(left_alpha, left_beta, true);//对球门设定

  1. SL-->Localization

用于定位

SL->update(player_info(p.global.x(), p.global.y(), p.dir), posts_);//自身x,y,角度,?

  1. VISION-->Vision

摄像头的宏定义,有操作:

VISION->start();//开启摄像头

VISION->can_see_post_ //有无球门

VISION->get_point_dis(x,y); //根据服务器的坐标计算球门角度

  1. OPTS-->Options

    int id_;
    int kick_mode_;//表示机器人的踢球模式。
    bool use_debug_;//表示是否启用调试模式。
    bool use_camera_;//表示是否使用相机。
    bool use_robot_;//表示是否使用机器人。
    bool use_remote_;//表示是否使用遥控器。
    bool use_gc_;//表示是否使用比赛控制器
    bool use_comm_;//表示是否使用通信。
    bool image_record_;//表示是否记录图像。
  1. CONF-->Configuration

在路径"data/config.conf"中配置相关的参数,如机器人id和队号等并放置在config_tree_变量中;

最常用id和team_number_

  1. SOCCERMAP

  1. MADT-->Adapter

缓冲队列的宏定义(不清楚干嘛的)

  1. WE-->WalkEngine

WE->get_walk_state();//walk的状态

WALK_STOP,
WALK_START,
WALK_END,
WALK_TO_ACT,
WALK_NORMAL

WE->set_params(x, y, d, e);//设置运动状态

  1. SE-->ScanEngine

SE->search_ball_end_;//是否停止找球

SE->search_post_end_;// 是否停止找球们

SE->pitch_range_[1];// 头部的仰角

SE->head_init_deg_;//头部初始状态

SE->set_params(yaw, pitch, motion::HEAD_STATE_LOOKAT);//设置头部朝向数据

  1. AE-->ActionEngine

AE->set_params(poses, pos_times);//位置和时间????

  1. LE-->LedEngine

LE->set_state(LED_NORMAL);//设置灯状态

    LED_CUSTOM = 0,
    LED_NORMAL = 1,
    LED_WARN = 2,
    LED_ERROR = 3

LE->set_led(1, true);//开关灯


  1. 传感器的使用

总体介绍

传感器:按钮、摄像机、比赛控制器、头部、IMU、舵机

OPTS中是否使用--><sensor>中是否使用响应传感器

/*
函数介绍:传感器注册
接口模块:
OPTS中是否使用--><sensor>中是否使用传感器:按钮、摄像机、比赛控制器、头部、IMU、舵机
*/
bool Player::regist()

//返回传感器的指针
sensor_ptr Player::get_sensor(const std::string &name)

各种传感器和对应环境的链接

play.cpp中init()调用regist()注册各种传感器,将其附加在相对应的环境中,调用传感器的start()开启传感器,可以使用环境内指针传感器读取数据,下面是链接环境对应关系;

sensors_["camera"] = std::make_shared<Camera>();
sensors_["camera"]->attach(VISION);

sensors_["motor"] = std::make_shared<Motor>();
sensors_["motor"]->attach(WE);

sensors_["imu"] = std::make_shared<Imu>();
sensors_["imu"]->attach(WM);
sensors_["imu"]->attach(VISION);
sensors_["imu"]->attach(WE);

sensors_["button"] = std::make_shared<Button>();
sensors_["button"]->attach(WM);

sensors_["gamectrl"] = std::make_shared<GameCtrl>();
sensors_["gamectrl"]->attach(WM);

sensors_["hear"] = std::make_shared<Hear>();
sensors_["hear"]->attach(WM);

具体传感器

  1. 比赛控制器的调用(总体-->GC)

play.cpp中think()选择使用play_with_gc与比赛控制器链接;

  1. 视觉模块中嵌套位置信息处理(视觉->定位)

vision.cpp中若看到球门则进行定位更新SL->update();


Core

  1. adaper.hpp

缓冲队列,不需要修改。

  1. clock.hpp

定时器,不需要修改。

  1. worldmodel.cpp

这是对机器人全局的统筹控制,不需要修改。

void WorldModel::updata(const pub_ptr &pub, const int &type) //传感器数据更新
void WorldModel::set_my_pos(const Eigen::Vector2d &my) //设置机器人的当前位置,更新世界模型中机器人的位置信息。
void WorldModel::set_ball_pos(const Eigen::Vector2d &global, const Eigen::Vector2d &my, const Eigen::Vector2i &pix,float alpha, float beta,  bool can)//对球的位置设定
void WorldModel::set_post1_pos(float alpha, float beta, bool can) // 球门柱设置
void WorldModel::reset_hear_info() // 该函数的作用是重置机器人的听取信息(hear information),即将其他机器人的可视状态(can_see)全部设为false。


添加任务

走路

// x:纵向步长,y:横向步长,dir:脚的转角,enable:是否执行WE
WalkTask(float x, float y, float dir, bool enable)
tasks.push_back(make_shared<WalkTask>(0.0, 0.0, dir, true));

头部的角度

// yaw:偏航角;pitch:俯仰角(参见欧拉角)
LookTask(float yaw, float pitch);
tasks.push_back(std::make_shared<LookTask>(motion::HEAD_STATE_SEARCH_BALL));
/*
HEAD_STATE_LOOKAT,
HEAD_STATE_SEARCH_BALL,
HEAD_STATE_SEARCH_POST,
HEAD_STATE_TRACK_BALL
可以在scan_engine.cpp文件中修改
*/

踢球方法

//动作名字
ActionTask(const std::string &name)
tasks.push_back(std::make_shared<ActionTask>("left_little_kick"));
/*
动作的定义在acts.conf文件中,例如
"left_kick": {
            "ready_pos": "100",
            "left_kick1": "80",
            "left_kick2": "60",
            "left_kick3": "60",
            "left_kick4": "6",
            "left_kick5": "6",
            "left_kick5": "20",
            "left_kick6": "40",
            "ready_pos": "60"
        }
*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

岂止是狼子野心

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值