LOADING

加载过慢请开启缓存 浏览器默认开启

嘉心糖大本营

airsim物理

2023/7/16

模拟方法

原始论文 https://microsoft.github.io/AirSim/paper/main.pdf

在airsim中四旋翼无人机根据各桨转速计算力矩,但被当做质点看待,计算整体的速度,加速度。

具体实现

物理参数设置

可在 AirLib\include\vehicles\multirotor\RotorParams.hpp 中设置螺旋桨各参数

可在 AirLib\include\vehicles\multirotor\MultiRotorParams.hpp\setupFrameGenericQuad 中设置无人机参数。

在simplefight下默认加载这个模型,就算换了模型还是按照这个函数中的参数加载,仿真中的参数与虚幻蓝图中参数设置没有任何关联,计算中的参数都按这个来。

更新无人机状态 :

1.假设不发生碰撞

// https://github.com/microsoft/AirSim/blob/main/AirLib/include/physics/FastPhysicsEngine.hpp#L315
avg_linear = current.twist.linear + current.accelerations.linear * (0.5f * dt_real);
avg_angular = current.twist.angular + current.accelerations.angular * (0.5f * dt_real);
const Wrench drag_wrench = getDragWrench(body, current.pose.orientation, avg_linear, avg_angular, wind);
next_wrench = body_wrench + drag_wrench;

// https://github.com/microsoft/AirSim/blob/main/AirLib/include/physics/FastPhysicsEngine.hpp#L412
next.pose.position = current_pose.position + avg_linear * dt_real;

2.检测碰撞

//if there is collision, see if we need collision response
const CollisionInfo collision_info = body.getCollisionInfo();
CollisionResponse& collision_response = body.getCollisionResponseInfo();
if (body.isGrounded() || (collision_info.has_collided && collision_response.collision_time_stamp != collision_info.time_stamp)) {
    bool is_collision_response = getNextKinematicsOnCollision(dt, collision_info, body, current, next, next_wrench, enable_ground_lock_);
     updateCollisionResponseInfo(collision_info, next, is_collision_response, collision_response);
}

3.碰撞处理

较复杂,见
https://github.com/microsoft/AirSim/blob/main/AirLib/include/physics/FastPhysicsEngine.hpp#L129
https://gafferongames.com/post/collision_response_and_coulomb_friction/

AirSim 中的 wind 模型

airsim中的wind模型与UE中的 winddirectionSOurce类关系不大,而是通过直接设置仿真物理引擎中的wind vector模拟。

//https://github.com/microsoft/AirSim/blob/main/AirLib/include/physics/FastPhysicsEngine.hpp#L325
    const real_T air_density = body.getEnvironment().getState().air_density;
    // Use relative velocity of the body wrt wind
    const Vector3r relative_vel = linear_vel - wind_world;
    const Vector3r linear_vel_body = VectorMath::transformToBodyFrame(relative_vel, orientation);
阅读全文

AirSim更换无人机模型

2023/7/5

实现效果

简单替换无人机模型,质量惯性等由虚幻计算得出,无法进一步改善飞控。

具体步骤

1.模型下载

可在
https://www.turbosquid.com/zh_cn/3d-models/3d-model-inspire-1-2088818
下载到免费4轴飞行器模型,本文也以此模型资源替换内置飞行器。

2.模型处理

使用blender导入模型,首先将无人机前方对准X轴,隐藏在body处找到4个螺旋桨。其次进入物体模式,全选剩下机身部分 Ctrl+J 合并成一个单独的模型如下。

导出成.fbx格式,导出时仅导出骨架和网格,变换选择x向前,z向上。

导出机身后删除机身整体,取消隐藏螺旋桨并将位置偏移量设置为0,0,0。再导出为一个单独的螺旋桨文件。结果如下图

3.导入UE

新建任意文件夹,分别导入第2步中建好的机身和螺旋桨文件。取消勾选骨骼网络体和合并网格体即可。

复制蓝图 AirSim内容/Blueprints/BP_FlyingPawn(此为原始模型)(若内容浏览器中无AirSim内容则在视图选项中勾选“显示插件内容”)到你新建的文件夹中。在组件栏中将bodymesh,prop 0-3 的静态网格体替换成导入的机身和螺旋桨,在视口界面调整各螺旋桨与摄像头相对机身的位置(若被遮挡可在渲染界面取消可视)。
结果如下:

4.修改 settings.json

在settings.json中添加pawnpath项,格式为 “PawnPaths”: {
“inspire”(无人机模型名): {“PawnBP”: “Class’/Game/Quadrotor/inspire.inspire_C’”(类地址,inspire即为第三步中修改的蓝图名称)}
},随后新建载具,在其Pawnpath属性中选择 inspire即完成模型替换。

欢迎留言讨论

参考链接

阅读全文

Hello World

2023/7/4

折腾了一段时间总算把个人主页搭起来了,就当做一个学习记录好啦。

本站主题来源 hexo-theme-particlex,改了一下素材变成嘉心糖补给站hh。🤣🤣

添加live2d

最大的问题是添加然然的live2d模型,模型来自木果阿木果,是moc3格式的。而hexo较为常用的hexo-helper-live2d只适配了moc模型,根据叶小兽添加嘉然Live2D看板娘并消除对JsdelivrCDN的依赖的教程折腾了一晚都不能把然然召唤出来.😡😡

最后发现了这个Live2dLoader,在particlex的footer.ejs中添加js代码,终于加载成功了。然然我的然然嘻嘻。💕

欢迎大家收藏关注 🧡

阅读全文
1
avatar
Jay-LJH

Description
哈工大深圳自动化大三在读