当前位置: 首页 > news >正文

《机器人学一(Robotics(1))》_台大林沛群 第 6 周 【轨迹规划_直线转折处抛物线平滑】Quiz 6

步骤:
1、 编程 将PPT 的例子 跑一遍, 确保代码无误
2、根据题目 修改 相关参数

文章目录

        • 求解代码_Python

解决的问题: 线段间转折点 的 速度 不连续
解决方法: 将直线段 两端 修正为 二次方程式
在这里插入图片描述
二次项圆滑
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

求解代码_Python

import numpy as np
np.set_printoptions(precision=2,suppress = True) t0, t1, t2, tf = 0, 2, 4, 9
x0, x1, x2, xf = -4, -5, 2, 5
y0, y1, y2, yf = 0, 5, 3, -3 
θ0, θ1, θ2, θf = 120, 45, 30, 0
tk = 0.5### 1、求 各 DOF(X, Y, θ) 在每段的速度  及 加速度## 中间 线段 计算
def getV_in(x1, x2, t1, t2):return (x2 - x1)/(t2 - t1)## 头尾 线段  计算 
def getV_0f(x1, x2, t1, t2):return (x2 - x1)/(t2 - t1 - tk/2)### 2、 建立 各 DOF(X, Y, θ) 在每段的方程
"""
平滑  t ∈ [0, 0.5]
直线  t ∈ [0.5, 1.75]
平滑  t ∈ [1.75, 2.25]
直线  t ∈ [2.25, 3.75]
平滑  t ∈ [3.75, 4.25]
直线  t ∈ [4,25, 8.5]
平滑  t ∈ [8.5, 9]
"""
## 求解 X(t)
##  平滑化  段  
def getX_parabolic(x, V, a, ti0, ti1, t):return x + V * (t - ti0) + 0.5 * a * (t - ti1)**2## 直线段  
def getX_linear(x, V, ti, t):return x + V * (t - ti)############# 求解 X 部分
print('X:')
V0 = 0
V1 = getV_0f(x0, x1, t0, t1)
V2 = getV_in(x1, x2, t1, t2)
V3 = getV_0f(x2, xf, t2, tf)
Vf = 0
print('V1[0.5 ~ 1.75]:', np.round(V1, 2))
print('V2[2.25 ~ 3.75]:', np.round(V2, 2))
print('V3[4.25 ~ 8.25]:', np.round(V3, 2))  def geta(V1, V2):return (V2 - V1)/tka0 = geta(V0, V1)
a1 = geta(V1, V2)
a2 = geta(V2, V3)
af = geta(V3, Vf)
print('a0:', np.round(a0, 2))
print('a1:', np.round(a1, 2))
print('a2:', np.round(a2, 2))
print('af:', np.round(af, 2))print('t ∈ [3.75, 4.25]  t = 4 , X5 = :', np.round(getX_parabolic(x1, V2, a2, 2, 3.75, 4), 2))############# 求解 Y 部分
print('Y:')
V0 = 0
V1 = getV_0f(y0, y1, t0, t1)
V2 = getV_in(y1, y2, t1, t2)
V3 = getV_0f(y2, yf, t2, tf)
Vf = 0
print('V1:', np.round(V1, 2))
print('V2:', np.round(V2, 2))
print('V3:', np.round(V3, 2))  def geta(V1, V2):return (V2 - V1)/tka0 = geta(V0, V1)
a1 = geta(V1, V2)
a2 = geta(V2, V3)
af = geta(V3, Vf)
print('a0:', np.round(a0, 2))
print('a1:', np.round(a1, 2))
print('a2:', np.round(a2, 2))
print('af:', np.round(af, 2))print('t ∈ [3.75, 4.25]  t = 4 , Y5 = :', np.round(getX_parabolic(y1, V2, a2, 2, 3.75, 4), 2))############# 求解 θ 部分
print('θ:')
V0 = 0
V1 = getV_0f(θ0, θ1, t0, t1)
V2 = getV_in(θ1, θ2, t1, t2)
V3 = getV_0f(θ2, θf, t2, tf)
Vf = 0
print('V1:', np.round(V1, 2))
print('V2:', np.round(V2, 2))
print('V3:', np.round(V3, 2))  def geta(V1, V2):return (V2 - V1)/tka0 = geta(V0, V1)
a1 = geta(V1, V2)
a2 = geta(V2, V3)
af = geta(V3, Vf)
print('a0:', np.round(a0, 2))
print('a1:', np.round(a1, 2))
print('a2:', np.round(a2, 2))
print('af:', np.round(af, 2))print('t ∈ [3.75, 4.25]  t = 4 , θ5 = :', np.round(getX_parabolic(θ1, V2, a2, 2, 3.75, 4), 2))

在这里插入图片描述

第1题答案: -0.57//2.86//-42.86
在这里插入图片描述
第2题答案: 3.5//-1//-7.5
在这里插入图片描述
第3题答案: 0.63//-1.26//-6.32
在这里插入图片描述
第4题答案: -1.14//5.71//-85.71
在这里插入图片描述
第5题答案: 8.14//-7.71//70.71
在这里插入图片描述
第6题答案: -5.74//-0.53//2.37
在这里插入图片描述
第7题答案: -1.26//2.53//12.63
在这里插入图片描述
第8题答案: 1.82//2.98//30.07

http://www.lryc.cn/news/157450.html

相关文章:

  • 关于vscode的GitLens插件里的FILE HISTORY理解
  • 通过idea实现springboot集成mybatys
  • 力扣(LeetCode)算法_C++——移位字符串分组
  • Vue2 与Vue3的区别?面试题
  • java代码:Random和Scanner应用的小例子-猜数字小游戏
  • python调用git出错:ImportError: Failed to initialize: Bad git executable.
  • 【C语言】入门——指针
  • C#_预处理指令
  • 容器命令(docker)
  • Vue3 ElementPlus el-cascader级联选择器动态加载数据
  • leetcode分类刷题:栈(Stack)(一、字符串相邻元素删除类型)
  • 你还在找淘宝商品信息查询的接口吗?
  • dll修复精灵,dll修复工具下载方法分享,mfc140u.dll缺失损坏一键修复
  • [LINUX使用] iptables tcpdump
  • 百度文心一率先言向全社会开放 应用商店搜“文心一言”可直接下载
  • 【100天精通Python】Day56:Python 数据分析_Pandas数据清洗和处理
  • 【vue】使用无障碍工具条(详细)
  • java实现命令模式
  • 【PowerQuery】PowerQuery学习路径
  • JDK7多线程并发环境HashMap死循环infinite loop,CPU拉满100%,Java
  • Linux下的系统编程——认识进程(七)
  • 2023年9月CSPM-3国标项目管理中级认证报名,找弘博创新
  • 使用ChatGLMTokenizer处理json格式数据
  • Redis基础特性及应用练习-php
  • Numpy知识点回顾与学习
  • H.264视频编码推荐的分辨率和码率配置表
  • Greenplum 实用工具-gpaddmirrors
  • 详解 Cent OS JDK 8.0 安装配置
  • 代理IP与网络安全在跨境电商中的关键作用
  • Kafka3.0.0版本——消费者(消费方式)