差分小车模型、单轨模型-matlab画图实现

2023-12-21 07:50

本文主要是介绍差分小车模型、单轨模型-matlab画图实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

记得点赞哈。

一、差分小车模型(非完整运动学约束)

1.1 椭圆外部轮子

 代码1

robot_draw(2,6,1,3.1415926/3,'b')
axis equal;function robot_draw(x,y,r,theta,color)
% x y圆心坐标,r圆半径,theta小车行驶角度,color小车颜色
% 调用示例: robot_draw(4,7,1,3.1415926/5,'b')%     figure('visible','off');rectangle('Position',[x-r,y-r,2*r,2*r],'Curvature',[1,1],'LineWidth',1.5,'EdgeColor',color);hold on;x1 = x+1.2*r*cos(theta);y1 = y+1.2*r*sin(theta);line([x,x1],[y,y1],'Color',color,'LineWidth',1.5)hold on;ecc = axes2ecc(r/2,r/8);wheel_left = [x+9*r/8*cos(theta+3.1415926/2), y+9*r/8*sin(theta+3.1415926/2)];[elat,elon]=ellipse1(wheel_left(1),wheel_left(2),[r/2 ecc],rad2deg(theta));line(elat,elon,'Color',color,'LineWidth',1.2);hold on;wheel_right = [x+9*r/8*cos(theta-3.1415926/2), y+9*r/8*sin(theta-3.1415926/2)];[elat,elon]=ellipse1(wheel_right(1),wheel_right(2),[r/2 ecc],rad2deg(theta));line(elat,elon,'Color',color,'LineWidth',1.2);
end

 1.2 长方形内部轮子

 代码2

robot_draw(2,6,1,3.1415926/3,'b')
axis equal;function robot_draw(x,y,r,theta,color)
% x y圆心坐标,r圆半径,theta小车行驶角度,color小车颜色
% 调用示例: robot_draw(4,7,1,3.1415926/5,'b')rectangle('Position',[x-r,y-r,2*r,2*r],'Curvature',[1,1],'LineWidth',1.5,'EdgeColor',color);hold on;x1 = x+1.2*r*cos(theta);y1 = y+1.2*r*sin(theta);line([x,x1],[y,y1],'Color','m','LineWidth',1.5)hold on;L_num = 3*r/5;W_num = r/6;L_wheel = r-2*W_num;%左轮angle_left = theta-3.1415926/2;rot_mat_left = [cos(-angle_left), sin(-angle_left); -sin(-angle_left), cos(-angle_left)];left_up  = rot_mat_left*[-W_num/2-L_wheel;L_num*0.5] + [x;y];left_dw  = rot_mat_left*[-W_num/2-L_wheel;-L_num*0.5] + [x;y];right_up = rot_mat_left*[W_num/2-L_wheel;L_num*0.5] + [x;y];right_dw = rot_mat_left*[W_num/2-L_wheel;-L_num*0.5] + [x;y];hold on;line([left_up(1),right_up(1),right_dw(1),left_dw(1),left_up(1)],[left_up(2),right_up(2),right_dw(2),left_dw(2),left_up(2)],'Color',color,'LineWidth',1.5);hold on;%右轮angle_righ = theta+3.1415926/2;rot_mat_righ = [cos(-angle_righ), sin(-angle_righ); -sin(-angle_righ), cos(-angle_righ)];left_up  = rot_mat_righ*[-W_num/2-L_wheel;L_num*0.5] + [x;y];left_dw  = rot_mat_righ*[-W_num/2-L_wheel;-L_num*0.5] + [x;y];right_up = rot_mat_righ*[W_num/2-L_wheel;L_num*0.5] + [x;y];right_dw = rot_mat_righ*[W_num/2-L_wheel;-L_num*0.5] + [x;y];hold on;line([left_up(1),right_up(1),right_dw(1),left_dw(1),left_up(1)],[left_up(2),right_up(2),right_dw(2),left_dw(2),left_up(2)],'Color',color,'LineWidth',1.5);
end

 二、单轨运动学模型

 代码

robot_draw(4,7,1,3.1415926/6,-3.1415926/5,'b')
axis equal;function h=robot_draw(x,y,r,theta,w,color)
% x y圆心坐标,r圆半径,theta小车行驶角度,w方向盘角度,color小车颜色
% 调用示例: robot_draw(4,7,1,3.1415926/5,'b')theta_n = theta+w;l_car = 0.8*r;rot_mat1 = [cos(-theta), sin(-theta); -sin(-theta), cos(-theta)];p1 = rot_mat1*[l_car; 0] + [x;y];p2 = rot_mat1*[-l_car;0] + [x;y];hold on;h1 = line([p1(1),p2(1)],[p1(2),p2(2)],'Color',color,'LineWidth',1.5);%车前把手angle = theta_n-3.1415926/2;w_car = 3*r/8;rot_mat2 = [cos(-angle), sin(-angle); -sin(-angle), cos(-angle)];p3 = rot_mat2*[-w_car; 0] + p1;p4 = rot_mat2*[ w_car; 0] + p1;hold on;h2 = line([p3(1),p4(1)],[p3(2),p4(2)],'Color',color,'LineWidth',1.5);%后轮L_num = 3*r/5;W_num = r/6;L_wheel = r-2*W_num;angle_left = theta-3.1415926/2;rot_mat_left = [cos(-angle_left), sin(-angle_left); -sin(-angle_left), cos(-angle_left)];left_up  = rot_mat_left*[-W_num/2; L_num*0.5-L_wheel] + [x;y];left_dw  = rot_mat_left*[-W_num/2;-L_num*0.5-L_wheel] + [x;y];right_up = rot_mat_left*[ W_num/2; L_num*0.5-L_wheel] + [x;y];right_dw = rot_mat_left*[ W_num/2;-L_num*0.5-L_wheel] + [x;y];hold on;h3 = line([left_up(1),right_up(1),right_dw(1),left_dw(1),left_up(1)],[left_up(2),right_up(2),right_dw(2),left_dw(2),left_up(2)],'Color',color,'LineWidth',1.5);%前轮L_num = 2*r/5;angle_righ = theta_n+3.1415926/2;rot_mat_righ = [cos(-angle_righ), sin(-angle_righ); -sin(-angle_righ), cos(-angle_righ)];left_up  = rot_mat_righ*[-W_num/2; L_num*0.5] + p1;left_dw  = rot_mat_righ*[-W_num/2;-L_num*0.5] + p1;right_up = rot_mat_righ*[ W_num/2; L_num*0.5] + p1;right_dw = rot_mat_righ*[ W_num/2;-L_num*0.5] + p1;hold on;h4 = line([left_up(1),right_up(1),right_dw(1),left_dw(1),left_up(1)],[left_up(2),right_up(2),right_dw(2),left_dw(2),left_up(2)],'Color',color,'LineWidth',1.5);h = [h1,h2,h3,h4];
end

 理论学习参考 【汽车】【控制】01.01 车辆运动学模型到动力学模型_哔哩哔哩_bilibili

这篇关于差分小车模型、单轨模型-matlab画图实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/519156

相关文章

Python实现终端清屏的几种方式详解

《Python实现终端清屏的几种方式详解》在使用Python进行终端交互式编程时,我们经常需要清空当前终端屏幕的内容,本文为大家整理了几种常见的实现方法,有需要的小伙伴可以参考下... 目录方法一:使用 `os` 模块调用系统命令方法二:使用 `subprocess` 模块执行命令方法三:打印多个换行符模拟

SpringBoot+EasyPOI轻松实现Excel和Word导出PDF

《SpringBoot+EasyPOI轻松实现Excel和Word导出PDF》在企业级开发中,将Excel和Word文档导出为PDF是常见需求,本文将结合​​EasyPOI和​​Aspose系列工具实... 目录一、环境准备与依赖配置1.1 方案选型1.2 依赖配置(商业库方案)二、Excel 导出 PDF

Python实现MQTT通信的示例代码

《Python实现MQTT通信的示例代码》本文主要介绍了Python实现MQTT通信的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1. 安装paho-mqtt库‌2. 搭建MQTT代理服务器(Broker)‌‌3. pytho

使用zip4j实现Java中的ZIP文件加密压缩的操作方法

《使用zip4j实现Java中的ZIP文件加密压缩的操作方法》本文介绍如何通过Maven集成zip4j1.3.2库创建带密码保护的ZIP文件,涵盖依赖配置、代码示例及加密原理,确保数据安全性,感兴趣的... 目录1. zip4j库介绍和版本1.1 zip4j库概述1.2 zip4j的版本演变1.3 zip4

python生成随机唯一id的几种实现方法

《python生成随机唯一id的几种实现方法》在Python中生成随机唯一ID有多种方法,根据不同的需求场景可以选择最适合的方案,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来一起学习学习... 目录方法 1:使用 UUID 模块(推荐)方法 2:使用 Secrets 模块(安全敏感场景)方法

Spring StateMachine实现状态机使用示例详解

《SpringStateMachine实现状态机使用示例详解》本文介绍SpringStateMachine实现状态机的步骤,包括依赖导入、枚举定义、状态转移规则配置、上下文管理及服务调用示例,重点解... 目录什么是状态机使用示例什么是状态机状态机是计算机科学中的​​核心建模工具​​,用于描述对象在其生命

Spring Boot 结合 WxJava 实现文章上传微信公众号草稿箱与群发

《SpringBoot结合WxJava实现文章上传微信公众号草稿箱与群发》本文将详细介绍如何使用SpringBoot框架结合WxJava开发工具包,实现文章上传到微信公众号草稿箱以及群发功能,... 目录一、项目环境准备1.1 开发环境1.2 微信公众号准备二、Spring Boot 项目搭建2.1 创建

IntelliJ IDEA2025创建SpringBoot项目的实现步骤

《IntelliJIDEA2025创建SpringBoot项目的实现步骤》本文主要介绍了IntelliJIDEA2025创建SpringBoot项目的实现步骤,文中通过示例代码介绍的非常详细,对大家... 目录一、创建 Spring Boot 项目1. 新建项目2. 基础配置3. 选择依赖4. 生成项目5.

Linux下删除乱码文件和目录的实现方式

《Linux下删除乱码文件和目录的实现方式》:本文主要介绍Linux下删除乱码文件和目录的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux下删除乱码文件和目录方法1方法2总结Linux下删除乱码文件和目录方法1使用ls -i命令找到文件或目录

SpringBoot+EasyExcel实现自定义复杂样式导入导出

《SpringBoot+EasyExcel实现自定义复杂样式导入导出》这篇文章主要为大家详细介绍了SpringBoot如何结果EasyExcel实现自定义复杂样式导入导出功能,文中的示例代码讲解详细,... 目录安装处理自定义导出复杂场景1、列不固定,动态列2、动态下拉3、自定义锁定行/列,添加密码4、合并