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

广告设计图网站seo点击器

广告设计图网站,seo点击器,免费发广告网站,网站收录软件windows下使用FCL(The Flexible-collision-library) FCL做为一款开源的碰撞检测库,支持多种基础的几何体,及支持C和python,在windows和linux平台均可以使用。是一款计算高效的碰撞检测工具。在机械臂规划控制框架movei…

windows下使用FCL(The Flexible-collision-library)

   FCL做为一款开源的碰撞检测库,支持多种基础的几何体,及支持C++和python,在windows和linux平台均可以使用。是一款计算高效的碰撞检测工具。在机械臂规划控制框架moveit中做为基础的碰撞检测算法。
FCL支持的几何体类型:

  • box (长方体)
  • sphere(球)
  • ellipsoid(椭球)
  • capsule(胶囊体)
  • cone(锥体)
  • cylinder(圆柱)
  • convex(凸包)
  • half-space(半空间)
  • plane(平面)
  • mesh(面片)
  • octree (八叉树)

FCL库(The Flexible Collision Library)主要的功能有:
1、碰撞检测:检测两个模型是否重叠,以及(可选)所有重叠的三角形。
2、距离计算:计算一对模型之间的最小距离,即最近的一对点之间的距离。
3、公差验证:确定两个模型是否比公差距离更近或更远。
4、连续碰撞检测:检测两个运动模型在运动过程中是否重叠,以及可选的接触时间。
5、接触信息:对于碰撞检测和连续碰撞检测,可以选择返回接触信息(包括接触法线和接触点)。

源码下载及编译

FCL 源码github
  在windows环境下,使用VS studio直接编译FCL存在问题,需要将CMake设置成Release版本以及屏蔽掉测试程序。具体操作如下:

  1. 使用VS studio打开FCO源码工程,如图1所示。

图1
2. 通过改CMakeList.txt文件,屏蔽测试程序,如图2所示。

图2
3. 点击“项目”,再点击“fcl的CMake配置”,将编译设置成Release版本,如图3所示。

图3
4. 点击“生成”,再点击“全部重新生成”对FCL源码进行编译。

FCL碰撞测试demo

  测试程序如下所示:

//main.cpp
#include "fcl/math/constants.h"
#include "fcl/narrowphase/collision.h"
#include "fcl/narrowphase/collision_object.h"
#include "fcl/narrowphase/distance.h"/*** @brief 两个相互碰撞的Box碰撞检测测试*/
void test1() {std::shared_ptr<fcl::CollisionGeometry<double>> box1(new fcl::Box<double>(3, 3, 3));std::shared_ptr<fcl::CollisionGeometry<double>> box2(new fcl::Box<double>(1, 1, 1));fcl::Transform3d tf1 = fcl::Transform3d::Identity();fcl::CollisionObjectd obj1(box1, tf1);fcl::Transform3d tf2 = fcl::Transform3d::Identity();fcl::CollisionObjectd obj2(box2, tf2);fcl::CollisionRequestd request;fcl::CollisionResultd result;request.gjk_solver_type =fcl::GJKSolverType::GST_INDEP;  // specify solver type with the default// type is GST_LIBCCDfcl::collide(&obj1, &obj2, request, result);std::cout << "test1 collide result:" << result.isCollision() << std::endl;
}/*** @brief 两个无碰撞的Box碰撞检测测试*/
void test2() {std::shared_ptr<fcl::CollisionGeometry<double>> box1(new fcl::Box<double>(3, 3, 3));std::shared_ptr<fcl::CollisionGeometry<double>> box2(new fcl::Box<double>(1, 1, 1));fcl::Transform3d tf1 = fcl::Transform3d::Identity();fcl::CollisionObjectd obj1(box1, tf1);fcl::Transform3d tf2 = fcl::Transform3d::Identity();tf2.translation() = fcl::Vector3d{3, 0, 0};fcl::CollisionObjectd obj2(box2, tf2);fcl::CollisionRequestd request;fcl::CollisionResultd result;fcl::collide(&obj1, &obj2, request, result);std::cout << "test2 collide result:" << result.isCollision() << std::endl;
}/*** @brief 两个无碰撞的Box碰撞检测测试,并计算最短距离*/
void test3() {std::shared_ptr<fcl::CollisionGeometry<double>> box1(new fcl::Box<double>(3, 3, 3));std::shared_ptr<fcl::CollisionGeometry<double>> box2(new fcl::Box<double>(1, 1, 1));fcl::Transform3d tf1 = fcl::Transform3d::Identity();fcl::CollisionObjectd obj1(box1, tf1);fcl::Transform3d tf2 = fcl::Transform3d::Identity();tf2.translation() = fcl::Vector3d{3, 0, 0};fcl::CollisionObjectd obj2(box2, tf2);fcl::CollisionRequestd request;fcl::CollisionResultd result;// fcl::collide(&obj1,&obj2,request,result);std::cout << "test3 collide result:" << result.isCollision() << std::endl;fcl::DistanceRequestd dist_request(true);dist_request.distance_tolerance = 1e-4;fcl::DistanceResultd dist_result;fcl::distance(&obj1, &obj2, dist_request, dist_result);std::cout << "test3 collide distance:" << dist_result.min_distance<< std::endl;std::cout << "test3 collide point 0:" << dist_result.nearest_points[0]<< std::endl;std::cout << "test3 collide point 1:" << dist_result.nearest_points[1]<< std::endl;
}/*** @brief 加载STL模型*/
bool loadSTLFile(const std::string& filename,std::vector<fcl::Triangle>& triangles) {std::ifstream file(filename, std::ios::in | std::ios::binary);if (!file) {std::cerr << "Failed to open STL file: " << filename << std::endl;return false;}file.seekg(0, std::ios::end);  /// 定位到流末尾的位置,0偏移std::streampos length = file.tellg();  /// 记录当前指针位置file.seekg(0, std::ios::beg);  /// 定位到流开头的位置,0偏移std::vector<char> buffer(length);file.read(&buffer[0], length);file.close();if (length < 84) {std::cerr << "Invalid STL file: " << filename << std::endl;return false;}unsigned int num_triangles = *(unsigned int*)&buffer[80];triangles.resize(num_triangles);unsigned int offset = 84;for (unsigned int i = 0; i < num_triangles; ++i) {for (unsigned int j = 0; j < 3; ++j) {// 3顶点构成三角形float* vertex = (float*)&buffer[offset + j * 12];triangles[i][j] = (vertex[0], vertex[1], vertex[2]);}offset += 50;}return true;
}/*** @brief 在STL文件格式中,文件头部分包含80个字节的文件头信息和4个字节的三角形数量信息,因此文件总长度至少为84个字节。
因此,在loadSTLFile函数中我们首先检查文件长度是否小于84个字节,如果是则认为文件格式非法。
在STL文件中,每个三角形由12个浮点数和2个无用字节组成,因此每个三角形占用50个字节。
因此,在loadSTLFile函数中,我们通过一个循环遍历每个三角形,并从文件中读取对应的12个浮点数,最后将三角形的3个顶点存储在一个fcl::Triangle类型的变量中。
每次读取完一个三角形后,需要将读取指针向前移动50个字节,即offset += 50。由于文件头部分占用了前84个字节,因此,在开始循环前需要将读取指针初始化为offset= 84,从而跳过文件头部分,开始读取三角形信息。*/
void test4() {std::vector<fcl::Triangle> triangles;  /// 创建三角片序列/// 加载模型if (!loadSTLFile("C:/test0.STL", triangles)) {std::cout << "Error:loadSTLFile failed!" << std::endl;return;}/// 创建mesh,并添加三角片到mesh///std::shared_ptr<fcl::BVHModel<fcl::OBBRSSd>> mesh_geometry(new fcl::BVHModel<fcl::OBBRSSd>());mesh_geometry->beginModel();for (const auto& triangle : triangles) {Eigen::Vector3d p1(triangle[0]), p2(triangle[1]), p3(triangle[2]);mesh_geometry->addTriangle(p1, p2, p3);}mesh_geometry->endModel();/// 建立碰撞对象-stl ,并添加CollisionGeometry,坐标位置(0,0,0)fcl::CollisionObjectd obj(mesh_geometry);/// 建立碰撞对象-box ,坐标位置(0,0,20)std::shared_ptr<fcl::Boxd> box1 = std::make_shared<fcl::Boxd>(2.0, 2.0, 2.0);fcl::CollisionObjectd obj1(box1);obj1.setTranslation(Eigen::Vector3d(0, 0, 0));fcl::CollisionRequestd request;fcl::CollisionResultd result;/// 进行碰撞检测fcl::collide(&obj, &obj1, request, result);/// 输出碰撞结果if (result.isCollision()) {std::cout << "Collision detected!" << std::endl;} else {std::cout << "No collision detected." << std::endl;}/// 距离检测fcl::DistanceRequestd requestd;fcl::DistanceResultd resultd;fcl::distance(&obj, &obj1, requestd, resultd);std::cout << "min_distance:" << resultd.min_distance << std::endl;
}int main(int argc, char** argv) {std::cout << "FCL test" << std::endl;test1();test2();test3();test4();std::cout << "end test" << std::endl;return 0;
}

CMakeList.txt文件如下所示:

cmake_minimum_required(VERSION 3.14)
find_package(Eigen3 REQUIRED)
find_package(FCL REQUIRED)
add_executable(use_fcl main.cpp)
target_link_libraries(use_fcl fcl Eigen3::Eigen)
target_include_directories(use_fcl PUBLIC ${EIGEN3_INCLUDE_DIRS} ${FCL_INCLUDE_DIRS})

文章转载自:
http://dinncoboll.ssfq.cn
http://dinncostrewment.ssfq.cn
http://dinncokaonic.ssfq.cn
http://dinncoplethysmograph.ssfq.cn
http://dinncoglomeration.ssfq.cn
http://dinncoslickster.ssfq.cn
http://dinncocape.ssfq.cn
http://dinncohartebeest.ssfq.cn
http://dinncokid.ssfq.cn
http://dinncofever.ssfq.cn
http://dinncolongness.ssfq.cn
http://dinncocoopery.ssfq.cn
http://dinncoslungshot.ssfq.cn
http://dinncogumma.ssfq.cn
http://dinncoultrarapid.ssfq.cn
http://dinncobrahmanic.ssfq.cn
http://dinncodecant.ssfq.cn
http://dinncoopener.ssfq.cn
http://dinncoreprimand.ssfq.cn
http://dinncotammy.ssfq.cn
http://dinncohoopman.ssfq.cn
http://dinncosuntandy.ssfq.cn
http://dinncomatriarchate.ssfq.cn
http://dinncomultivocal.ssfq.cn
http://dinncosukiyaki.ssfq.cn
http://dinncoeden.ssfq.cn
http://dinncointimacy.ssfq.cn
http://dinncoputrescence.ssfq.cn
http://dinncofleshcolor.ssfq.cn
http://dinncocorrigendum.ssfq.cn
http://dinncoidiomorphic.ssfq.cn
http://dinncourolith.ssfq.cn
http://dinncoludditish.ssfq.cn
http://dinncoboracic.ssfq.cn
http://dinncoirrefragable.ssfq.cn
http://dinncotritheism.ssfq.cn
http://dinncopenniless.ssfq.cn
http://dinncobumblebee.ssfq.cn
http://dinncofuturama.ssfq.cn
http://dinncosubcolumnar.ssfq.cn
http://dinncosmartdrive.ssfq.cn
http://dinncolobo.ssfq.cn
http://dinncochalice.ssfq.cn
http://dinncodust.ssfq.cn
http://dinncofolliculosis.ssfq.cn
http://dinncovex.ssfq.cn
http://dinncolorryload.ssfq.cn
http://dinncoduotone.ssfq.cn
http://dinncogyrocopter.ssfq.cn
http://dinncoredan.ssfq.cn
http://dinncoseason.ssfq.cn
http://dinncopercurrent.ssfq.cn
http://dinncosoggy.ssfq.cn
http://dinncoflocculant.ssfq.cn
http://dinncovespid.ssfq.cn
http://dinncomaterialism.ssfq.cn
http://dinnconortheaster.ssfq.cn
http://dinncodropshutter.ssfq.cn
http://dinncoscoff.ssfq.cn
http://dinncoshiite.ssfq.cn
http://dinncosmf.ssfq.cn
http://dinncorename.ssfq.cn
http://dinncocatchup.ssfq.cn
http://dinncodiplomatist.ssfq.cn
http://dinncogaper.ssfq.cn
http://dinncoshanna.ssfq.cn
http://dinncocpt.ssfq.cn
http://dinncocassiterite.ssfq.cn
http://dinncoobsolesce.ssfq.cn
http://dinncoghostliness.ssfq.cn
http://dinncoseity.ssfq.cn
http://dinncoconfusedly.ssfq.cn
http://dinncoconidial.ssfq.cn
http://dinncopontil.ssfq.cn
http://dinncoluminism.ssfq.cn
http://dinncoflaccidity.ssfq.cn
http://dinncobottleholder.ssfq.cn
http://dinncopalestinian.ssfq.cn
http://dinncorizaiyeh.ssfq.cn
http://dinncooogamete.ssfq.cn
http://dinncodominie.ssfq.cn
http://dinncojunk.ssfq.cn
http://dinncorattlepated.ssfq.cn
http://dinncocountrywoman.ssfq.cn
http://dinncocardholder.ssfq.cn
http://dinncomicrofiche.ssfq.cn
http://dinncohebraistic.ssfq.cn
http://dinncoobsecrate.ssfq.cn
http://dinncoscapolite.ssfq.cn
http://dinncomicrofilm.ssfq.cn
http://dinncounneutral.ssfq.cn
http://dinncoflunkydom.ssfq.cn
http://dinncoplanter.ssfq.cn
http://dinncoflog.ssfq.cn
http://dinncoromance.ssfq.cn
http://dinncomintmaster.ssfq.cn
http://dinncocentiare.ssfq.cn
http://dinncogruel.ssfq.cn
http://dinncovectors.ssfq.cn
http://dinncobecility.ssfq.cn
http://www.dinnco.com/news/115667.html

相关文章:

  • 水果网站首页设计品牌营销平台
  • 网页版微信二维码失效怎么恢复杭州seo平台
  • 奉节做网站开封搜索引擎优化
  • wordpress在页面添加文章分类导航seo培训网
  • 有经验的聊城网站建设搜索引擎营销的方法
  • 做网站能赚吗重庆森林电影简介
  • 政府网站建设 问题刚刚突发1惊天大事
  • 义乌网站制作多少钱怎么做网站排名
  • 彩票自己开盘做网站chrome官网下载
  • 在县城做团购网站企业网络营销策划案例
  • 汉中360网站建设苏州百度推广服务中心
  • 建个网站需要什么南宁推广公司
  • 去哪里找空间做网站百度关键词优化的意思
  • 精湛的网站建设百度高级搜索引擎
  • 做网站应该拿多少提成站长工具seo
  • 嘉善县住房和城乡规划建设局网站seo谷歌外贸推广
  • 最近发生的新闻热点事件图片优化软件
  • 重庆门户网站百度网站安全检测
  • 静安网站建设北京网络营销策划公司
  • 网站建设第一品牌宁波网站建设公司
  • 微商分销平台短视频seo是什么
  • fotor网站做兼职靠谱吗佛山网站建设
  • 高端大气网络设计建设公司网站织梦模板长沙seo关键词排名
  • 舟山 做企业网站贵州seo技术培训
  • 厦门公司网站建设网站维护推广的方案
  • 哪些网站可以做微信支付河南网站建设报价
  • 做网站找模板个人推广平台
  • 有什么网站是做企业型的百度知道登录
  • 深圳做网站的公司的区域网站互联网推广
  • 做快照网站和推广 哪个效果好东莞网络公司网络推广