视频效果地址:多无人机编队飞行使用CoppeliaSim+Python实现

CoppliaSim控制无人车和无人机实现编队控制

function sysCall_init() particlesAreVisible=truesimulateParticles=truefakeShadow=trueparticleCountPerSecond=430particleSize=0.005particleDensity=8500particleScatteringAngle=30particleLifeTime=0.5maxParticleCount=50-- Detatch the manipulation sphere:targetObj=sim.getObjectHandle('Quadcopter_target')sim.setObjectParent(targetObj,-1,true)-- This control algo was quickly written and is dirty and not optimal. It just serves as a SIMPLE exampled=sim.getObjectHandle('Quadcopter_base')propellerHandles={}jointHandles={}particleObjects={-1,-1,-1,-1}local ttype=sim.particle_roughspheres+sim.particle_cyclic+sim.particle_respondable1to4+sim.particle_respondable5to8+sim.particle_ignoresgravityif not particlesAreVisible thenttype=ttype+sim.particle_invisibleendfor i=1,4,1 dopropellerHandles[i]=sim.getObjectHandle('Quadcopter_propeller_respondable'..i)jointHandles[i]=sim.getObjectHandle('Quadcopter_propeller_joint'..i)if simulateParticles thenparticleObjects[i]=sim.addParticleObject(ttype,particleSize,particleDensity,{2,1,0.2,3,0.4},particleLifeTime,maxParticleCount,{0.3,0.7,1})endendheli=sim.getObjectHandle(sim.handle_self)pParam=2iParam=0dParam=0vParam=-2cumul=0lastE=0pAlphaE=0pBetaE=0psp2=0psp1=0prevEuler=0if (fakeShadow) thenshadowCont=sim.addDrawingObject(sim.drawing_discpoints+sim.drawing_cyclic+sim.drawing_25percenttransparency+sim.drawing_50percenttransparency+sim.drawing_itemsizes,0.2,0,-1,1)end
endfunction sysCall_cleanup() sim.removeDrawingObject(shadowCont)for i=1,#particleObjects,1 dosim.removeParticleObject(particleObjects[i])end
end function sysCall_actuation() pos=sim.getObjectPosition(d,-1)if (fakeShadow) thenitemData={pos[1],pos[2],0.002,0,0,1,0.2}sim.addDrawingObjectItem(shadowCont,itemData)end-- Vertical control:targetPos=sim.getObjectPosition(targetObj,-1)pos=sim.getObjectPosition(d,-1)l=sim.getVelocity(heli)e=(targetPos[3]-pos[3])cumul=cumul+epv=pParam*ethrust=5.45+pv+iParam*cumul+dParam*(e-lastE)+l[3]*vParamlastE=e-- Horizontal control: sp=sim.getObjectPosition(targetObj,d)m=sim.getObjectMatrix(d,-1)vx={1,0,0}vx=sim.multiplyVector(m,vx)vy={0,1,0}vy=sim.multiplyVector(m,vy)alphaE=(vy[3]-m[12])alphaCorr=0.25*alphaE+2.1*(alphaE-pAlphaE)betaE=(vx[3]-m[12])betaCorr=-0.25*betaE-2.1*(betaE-pBetaE)pAlphaE=alphaEpBetaE=betaEalphaCorr=alphaCorr+sp[2]*0.005+1*(sp[2]-psp2)betaCorr=betaCorr-sp[1]*0.005-1*(sp[1]-psp1)psp2=sp[2]psp1=sp[1]-- Rotational control:euler=sim.getObjectOrientation(d,targetObj)rotCorr=euler[3]*0.1+2*(euler[3]-prevEuler)prevEuler=euler[3]-- Decide of the motor velocities:handlePropeller(1,thrust*(1-alphaCorr+betaCorr+rotCorr))handlePropeller(2,thrust*(1-alphaCorr-betaCorr-rotCorr))handlePropeller(3,thrust*(1+alphaCorr-betaCorr+rotCorr))handlePropeller(4,thrust*(1+alphaCorr+betaCorr-rotCorr))
end function handlePropeller(index,particleVelocity)propellerRespondable=propellerHandles[index]propellerJoint=jointHandles[index]propeller=sim.getObjectParent(propellerRespondable)particleObject=particleObjects[index]maxParticleDeviation=math.tan(particleScatteringAngle*0.5*math.pi/180)*particleVelocitynotFullParticles=0local t=sim.getSimulationTime()sim.setJointPosition(propellerJoint,t*10)ts=sim.getSimulationTimeStep()m=sim.getObjectMatrix(propeller,-1)particleCnt=0pos={0,0,0}dir={0,0,1}requiredParticleCnt=particleCountPerSecond*ts+notFullParticlesnotFullParticles=requiredParticleCnt % 1requiredParticleCnt=math.floor(requiredParticleCnt)while (particleCnt<requiredParticleCnt) do-- we want a uniform distribution:x=(math.random()-0.5)*2y=(math.random()-0.5)*2if (x*x+y*y<=1) thenif (simulateParticles) thenpos[1]=x*0.08pos[2]=y*0.08pos[3]=-particleSize*0.6dir[1]=pos[1]+(math.random()-0.5)*maxParticleDeviation*2dir[2]=pos[2]+(math.random()-0.5)*maxParticleDeviation*2dir[3]=pos[3]-particleVelocity*(1+0.2*(math.random()-0.5))pos=sim.multiplyVector(m,pos)dir=sim.multiplyVector(m,dir)itemData={pos[1],pos[2],pos[3],dir[1],dir[2],dir[3]}sim.addParticleObjectItem(particleObject,itemData)endparticleCnt=particleCnt+1endend-- Apply a reactive force onto the body:totalExertedForce=particleCnt*particleDensity*particleVelocity*math.pi*particleSize*particleSize*particleSize/(6*ts)force={0,0,totalExertedForce}m[4]=0m[8]=0m[12]=0force=sim.multiplyVector(m,force)local rotDir=1-math.mod(index,2)*2torque={0,0,rotDir*0.002*particleVelocity}torque=sim.multiplyVector(m,torque)sim.addForceAndTorque(propellerRespondable,force,torque)
end

【CoppeliaSim】使用 Lua 语言控制四旋翼无人机运行相关推荐

  1. Backstepping反步法控制四旋翼无人机(一)

    目录 四旋翼基本参数 基本假设 转换矩阵 基本方程 线性化 综合 四旋翼基本参数 四旋翼作为一种可以在空间中自由飞行的无人飞行器,具有6个自由度和4个螺旋桨.其中,4个螺旋桨提供动力,作为四旋翼的动力 ...

  2. Backstepping反步法控制四旋翼无人机(2)

    目录 跟踪误差 坐标变换 考虑以下非线性系统 {x˙1=x2+f1(x1)x˙2=u+f2(x1,x2)y=x1\begin{cases} \begin{aligned} \dot{x}_1& ...

  3. 四旋翼无人机建模与实现(一)

    四旋翼无人机建模与实现(一) 本文是对GitHub上的一个开源的四旋翼无人机建模与编程实现的学习笔记,因为原作者的文档使用英文写的,花了很长的时间才看懂,因此,我觉得用自己的语言将这个开源项目分享出来 ...

  4. 四旋翼无人机Matlab建模

    本文主要分享一下四旋翼无人机的建模过程,然后在Matlab的simulink模块搭建起四旋翼无人机的模型,本篇文章主要参考了康日晖的<四旋翼无人机建模>与南京邮电大学周帆同学的硕士毕业论文 ...

  5. 【控制】四旋翼无人机姿态角分析

    搞起来,从建模到控制,再到仿真 Link: [控制]<多无人机协同控制技术>周伟老师-第3章-面向协同控制的无人机单机控制 文章目录 1. 坐标系 2. 角度介绍 航向角 yaw ange ...

  6. 四旋翼无人机动力学模型及控制

    四旋翼无人机动力学模型及控制 I: 欧拉角与旋转矩阵 Overview 欧拉角与旋转矩阵 Body Frame Angular Velocity and [ ϕ ˙ , θ ˙ , ψ ˙ ] T [ ...

  7. 【飞行器】基于matlab四旋翼无人机几何跟踪控制【含Matlab源码 2270期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[飞行器]基于matlab四旋翼无人机几何跟踪控制[含Matlab源码 2270期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式 ...

  8. matlab simulink四旋翼无人机模糊PID控制姿态

    1.内容简介 略 532-可以交流.咨询.答疑 2.内容说明 四旋翼无人机控制灵活.安全性能较高,能够实现空中悬停.翻滚.任意角度横 向飞行,常常替代人们从事高空危险作业,给我们的生活与工作带来了很多 ...

  9. 四旋翼无人机PID控制

    一.建立四旋翼无人机动力学方程 二.确定PID控制律 1.姿态控制回路 2.位置控制回路 3.仿真图

最新文章

  1. windows服务器下部署多台tomcat
  2. virtualbox - 2台虚拟机之间通过ssh互访
  3. 外贸业务员会计算机知识,外贸业务员、电子商务
  4. Linux常用到的命令
  5. BP神经网络模型---第一篇(M-P模型)
  6. 基于DOI码的批量文献下载脚本
  7. NX二次开发-UFUN自定义尺寸导出NX窗口区域图像UF_DISP_create_framed_image
  8. 安装ps2019时出现错误代码146
  9. 第四大主流币XRP说归零就要归零,那么其他主流币还靠得住吗?暴跌来了,你怎么又不敢卖房梭哈了?
  10. mysql中数据表null什么意思_MySQL 中NULL和空值的区别是什么?
  11. java学习体会论文_关于学习java的心得体会
  12. 什么是潜在客户?CRM如何转化潜在客户?
  13. 【过关斩将】2020年互联网公司运维岗位面试题 -技能篇03
  14. 有图有视频:惯犯“京东金融APP”被曝盗取用户手机本地敏感图
  15. OsgEarth —— 笔记5 - 为earth地球鼠标实时经纬度(附源码)
  16. 图片c sa vsacas
  17. armbian n1 桌面_斐讯N1折腾记:运行 Linux 及优化 | 米V米
  18. 解决pda设备快速连扫两次条码造成条码显示重叠报错的问题
  19. 提高外贸网站在谷歌排名的方法与技巧
  20. Jmeter启动报错returned error code 5,解决方法

热门文章

  1. Lua应用——tables应用,查找是否为保留字
  2. Java联网技术之一HTTP
  3. Android 相机,视频录制
  4. Quake3服务器客户端架构参考
  5. 超图数据集管理基本操作和添加删除属性表字段
  6. 在线使用Octave、Matlab画单电荷等位线和电力线、matlab的nonconformant arguments错误
  7. VC++2019 使用wininet下载文件
  8. Telerik for Winform 2010版下载、安装、初次使用
  9. Java程序猿的JavaScript学习笔记(10—— jQuery-在“类”层面扩展)
  10. Android自定义控件:动画类---逐帧动画AnimationDrawable