rosbag相关

rosbag中有4个不同话题的数据,利用

std::vector<ctrl_msg::ctrl_ref> ctrl_msgs_vec = read_bag<ctrl_msg::ctrl_ref>(file_name, topic_name, -1);//读包中的某一个话题的所有数据
write_bag<ctrl_msg::ctrl_ref>(new_file_name, topic_name, cmds);//并将该话题的所有数据写入另一个包中

报错:

terminate called after throwing an instance of ‘rosbag::BagException’
what(): Tried to insert a message with time less than ros::TIME_MIN

利用rqt_plot画出了对应话题的曲线
在这里插入图片描述正确情况的plot:
在这里插入图片描述发现问题:
最后一个控制器指令没有时间戳,默认的时间戳是0,因此把最后一个控制指令的plot输出到了时间曲线的最前面

对应代码:

/*step1*/
void RVOSimulator::pub_dpos_for_ros(){
	ctrl_msg::ctrl_ref ctrl_ref_msg;
	ctrl_ref_msg.header.stamp = ros::Time::now();
	ctrl_ref_msg.ref_mask = 7;
	ctrl_ref_msg.yaw_ref = yawOffset;
	
	ctrl_ref_msg.pos_ref[0] = getAgentPosition(0).x();
	ctrl_ref_msg.pos_ref[1] = -getAgentPosition(0).y();
	ctrl_ref_msg.pos_ref[2] = -take_off_height;

	ctrl_ref_msg.vel_ref[0] = getAgentVelocity(0).x();
	ctrl_ref_msg.vel_ref[1] = -getAgentVelocity(0).y();
	ctrl_ref_msg.vel_ref[2] = 0.0f;

	ctrl_ref_msg.acc_ref[0] = 0.0f;
	ctrl_ref_msg.acc_ref[1] = 0.0f;
	ctrl_ref_msg.acc_ref[2] = 0.0f;

	ctrl_ref_pub.publish(ctrl_ref_msg);
}
/*step2*/
case HOVERING:
{	
	lg_node::agent_exec_state exec_state_;
	exec_state_.STATE = 5;
	exec_state_.id = uav_id;
	broadcast_agent_exec_state_pub.publish(exec_state_);
	if(first_exec_hovering){
		std::cout<<"uav_id: "<<uav_id<<" case HOVERING"<<std::endl;
		ctrl_msg::ctrl_ref hovering_command;
		hovering_command.header.stamp = ros::Time::now();//错误原因是没有写这行代码
		hovering_command.pos_ref[0] = agents_goals_[agents_goals_.size()-1].x();
		hovering_command.pos_ref[1] = -agents_goals_[agents_goals_.size()-1].y();
		hovering_command.pos_ref[2] = -take_off_height;
		hovering_command.yaw_ref = yawOffset;
		hovering_command.ref_mask = ctrl_msg::ctrl_ref::POS_CTRL_VALIED;
		for(int i=0; (i<10 && ros::ok()); i++) {
			ctrl_ref_pub.publish(hovering_command);
			ros::Duration(timeStep_).sleep();
  			}
		flag_exec_hovering = false;
		first_exec_hovering =false;
	}
	break;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值