栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

2022-4-25 qt realtime 2d planning debug

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2022-4-25 qt realtime 2d planning debug

改bug资料:

c++出现double free or corruption (fasttop)

Linux 下 segmentation fault(段错误) 总结
在LIinux 下C/C++中,出现段错误很多都是有指针造成的,指针声明后没有内容的存储空间,当你不指向指定的内存空间时,就会出现segmentation fault(段错误),这种情况往往能编译通过的,但是运行时就会出现在段错误。

段错误segmentation fault,信号SIGSEGV,是由于访问内存管理单元MMU异常所致,通常由于无效内存引用,如指针引用了一个不属于当前进程地址空间中的地址,操作系统便会进行干涉引发SIGSEGV信号产生段错误。

C++中try、catch 异常处理机制

int divide(int x, int y )           // 抛异常
{
	if (y ==0)
	{
		throw x;
	}
	return x/y;
}
 
void main41()
{
	Try                接异常
	{
		cout << "8/2 = " << divide(8, 2) << endl;
		cout << "10/0 =" << divide(10, 0) << endl;
	}
	catch (int e)
	{
		cout << "e" << " is divided by zero!" << endl;
	}
	catch(...)
	{
		cout << "未知异常" << endl;
	}
	
	cout << "ok" << endl;
 	system("pause");
	return ;
}

C++ 异常处理

问题 1. 线程同步


线程一改变路径点索引,线程二未更新对应状态到新的索引值,而是直接应用了旧的状态来匹配新索引,造成序列总长度不符合限制。assert 保证数据序列长度还是很有用的。

改:
索引更新和状态更新都放到一个线程里,另一个线程使用状态,不更新状态。
互斥锁未测试。
更新:还是用了互斥锁把两大块都括起来了,保证数据同步

2. ompl path keepbefore 和Keepafter:

保留从 距离最近的状态开始,但是当前状态不是最近??

 void ompl::geometric::PathGeometric::keepBefore(const base::State *state)
 {
     int index = getClosestIndex(state);
     if (index >= 0)
     {
         if (index > 0 && (std::size_t)(index + 1) < states_.size())
         {
             double b = si_->distance(state, states_[index - 1]);
             double a = si_->distance(state, states_[index + 1]);
             if (b < a)
                 --index;
         }
         if ((std::size_t)(index + 1) < states_.size())
         {
             for (std::size_t i = index + 1; i < states_.size(); ++i)
                 si_->freeState(states_[i]);
             states_.resize(index + 1);
         }
     }
 }
  
 int ompl::geometric::PathGeometric::getClosestIndex(const base::State *state) const
 {
     if (states_.empty())
         return -1;
  
     int index = 0;
     double min_d = si_->distance(states_[0], state);
     for (std::size_t i = 1; i < states_.size(); ++i)
     {
         double d = si_->distance(states_[i], state);
         if (d < min_d)
         {
             min_d = d;
             index = i;
         }
     }
     return index;
 }
  
 void ompl::geometric::PathGeometric::clear()
 {
     freeMemory();
     states_.clear();
 }

根据保留之后的长度判断当前状态是否被保留,否则再append进来。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/835726.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号