solve the bug in the stop API

This commit is contained in:
gfuse
2021-07-15 16:02:11 +02:00
parent 3b17b7c0f9
commit 7a355486b3
4 changed files with 18 additions and 8 deletions
@@ -53,7 +53,7 @@ public:
const vector<cv::Point2f>& initFeatureTrackCurPx() const { return klt_homography_init_->px_cur_; }
/// Access the depth filter.
DepthFilter* depthFilter() const { return depth_filter_; }
DepthFilter* depthFilter() const{ return depth_filter_; }
/// An external place recognition module may know where to relocalize.
bool relocalizeFrameAtPose(
+2 -2
View File
@@ -1,6 +1,6 @@
<launch>
<!-- node pkg="vio" type="vio" name="vio" clear_params="true" output="screen"/ -->
<node pkg="vio" type="vio" name="vio" clear_params="true" output="screen"/>
<!-- Camera topic to subscribe to -->
<param name="vio/cam_topic" value="/CoreNode/grey_img" type="str" />
@@ -8,7 +8,7 @@
<param name="vio/cmd_topic" value="/cmd_vel" type="str" />
<param name="vio/start" value="/vio/start" type="str" />
<param name="vio/stop" value="/vio/stop" type="str" />
<param name="vio/getOdom" value="/vio/set_odom" type="str" />
<param name="vio/odom" value="/vio/odom" type="str" />
<!-- Camera calibration file -->
<rosparam file="$(find vio)/param/px30.yaml" />
+1
View File
@@ -74,6 +74,7 @@ void DepthFilter::stopThread()
SVO_INFO_STREAM("DepthFilter interrupt and join thread... ");
seeds_updating_halt_ = true;
thread_->interrupt();
usleep(5000);
thread_->join();
thread_ = NULL;
}
+13 -4
View File
@@ -32,6 +32,7 @@
#include <vio/getOdom.h>
#include <vio/start.h>
#include <vio/stop.h>
#include <gpu_svo/depth_filter.h>
#if VIO_DEBUG
#include <gpu_svo/visualizer.h>
#endif
@@ -55,8 +56,11 @@ public:
start_=true;
if(vo_->stage()!=svo::FrameHandlerBase::STAGE_DEFAULT_FRAME)
vo_->start();
else
else{
vo_->depthFilter()->startThread();
vo_->reset();
}
imu_the_=new boost::thread(&VioNode::imu_th,this);
++trace_id_;
res.ret=0;
@@ -67,10 +71,15 @@ public:
};
bool stop(vio::stop::Request& req, vio::stop::Response& res){
if(req.off==1){
if(req.off==1 && imu_the_!=NULL){
start_=false;
usleep(5000);
vo_->depthFilter()->stopThread();
imu_the_->interrupt();
if(imu_the_->get_id()==boost::this_thread::get_id())
imu_the_->detach();
else
imu_the_->join();
imu_the_=NULL;
res.ret=0;
}else{
res.ret=100;
@@ -155,7 +164,7 @@ void VioNode::imu_th(){
ros::NodeHandle nh;
ros::Subscriber imu_sub=nh.subscribe(vk::getParam<std::string>("vio/imu_topic", "imu/raw"),10,&VioNode::imuCb, this);
ros::Subscriber cmd_sub=nh.subscribe(vk::getParam<std::string>("vio/cmd_topic", "cmd/raw"),10,&VioNode::cmdCb, this);
while(start_)
while(start_ && !boost::this_thread::interruption_requested())
{
ros::spinOnce();
usleep(1000);