DWA根据速度生成路径

generateTrajectory 生成路径

输入变量: 当前坐标pos 当前速度 vel 采样出来的目标速度sample_target_vel

  1. 判断速度是否在 sample_target_vel在最大最小值区间内 [min_vel_trans, max_vel_trans]
  2. 计算仿真的步数,num_steps
    1. 根据sim_time_和sample_target_vel计算出 sim_time_distance
    2. num_steps = sim_time_distance / sim_granularity_(每一小段的距离值----颗粒)
  3. 得到每一个细分点的仿真时间 dt = sim_time_ / num_steps
  4. 获取得到轨迹
    1. 将当前坐标点push到路径中
    2. 根据当前坐标 pos, 速度loop_vel及两个点的时间 dt 计算新的点
    3. 通过computeNewPositions计算得到新的点插入路径中

代码实现

computeNewPositions
  Eigen::Vector3f SimpleTrajectoryGenerator::computeNewPositions(const Eigen::Vector3f &pos,
                                                                 const Eigen::Vector3f &vel, double dt)
  {
    Eigen::Vector3f new_pos = Eigen::Vector3f::Zero();
    new_pos[0] = pos[0] + (vel[0] * cos(pos[2]) + vel[1] * cos(M_PI_2 + pos[2])) * dt;
    new_pos[1] = pos[1] + (vel[0] * sin(pos[2]) + vel[1] * sin(M_PI_2 + pos[2])) * dt;
    new_pos[2] = pos[2] + vel[2] * dt;
    return new_pos;
  }

实现示意图

在这里插入图片描述

公式推导

将上图的vx vy映射到全局坐标系下,得到如下公式
x ′ = x + ( v x . c o s ( θ ) ) + v y . c o s ( π / 2 + θ ) ) . d t y ′ = y + ( v x . s i n ( θ ) ) + v y . s i n ( π / 2 + θ ) ) . d t θ ′ = θ + ω . d t x' = x + (v_x.cos(\theta)) + v_y.cos(\pi/2+ \theta)).dt \\ y' = y + (v_x.sin(\theta)) + v_y.sin(\pi/2+ \theta)).dt\\ \theta' = \theta + \omega.dt x=x+(vx.cos(θ))+vy.cos(π/2+θ)).dty=y+(vx.sin(θ))+vy.sin(π/2+θ)).dtθ=θ+ω.dt

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值