用户您好,请详细描述您所遇到的问题:
- 系统软件版本: (通过 cat /etc/version 获得)
- 问题涉及的技术领域: (硬件、操作系统、驱动、其他)
- 问题描述:(尽可能详细的描述在进行什么功能的开发或者测试,发现了什么问题,问题现象,并且提供预期的结果)
- 复现概率:(必现、高、中、低,并描述大致的概率数值) 已进行的排查措施、分析及结果:
- 硬件问题先排查供电和时钟
- 驱动问题先排查外设的供电、复位和时钟
- 功能异常,先排查一下是不是运行的代码和demo存在差异,修改不多的情况下直接用对比软件先对比
- 提供必要的问题日志:
- 软件上是否有做自定义修改:
串口读写会导致mipi异常
环境:古月居x3派小车(视觉版,导航版均有问题)
版本:[BPU_PLAT]BPU Platform Version(1.3.1)!
[HBRT] set log level as 0. version = 3.14.5
[DNN] Runtime version = 1.9.7_(3.14.5 HBRT)
是否可复现:100%可复现
校验验证:将串口线拔掉或者将写串口代码屏蔽后,mipi不会异常
复现步骤:
1、开启一个定时器,每200毫米向串口写一条信息,我写的是两边轮子的转速;
2、开启系统自带的 python3 /app/ai_inference/03_mipi_camera_sample/mipi_camera.py 测试pkg
异常信息:
potted plant is in the picture with confidence:0.5851, bbox:[ 79 787 531 1080]
potted plant is in the picture with confidence:0.6110, bbox:[ 79 789 524 1079]
person is in the picture with confidence:0.7406, bbox:[ 977 498 1868 1079]
person is in the picture with confidence:0.6900, bbox:[ 977 496 1889 1080]
potted plant is in the picture with confidence:0.6208, bbox:[ 79 791 524 1080]
person is in the picture with confidence:0.7341, bbox:[ 967 498 1868 1079]
potted plant is in the picture with confidence:0.6017, bbox:[ 79 787 524 1080]
person is in the picture with confidence:0.6947, bbox:[ 967 498 1878 1080]
potted plant is in the picture with confidence:0.6240, bbox:[ 86 792 531 1078]
person is in the picture with confidence:0.6841, bbox:[ 967 490 1868 1080]
potted plant is in the picture with confidence:0.5883, bbox:[ 83 791 529 1080]
person is in the picture with confidence:0.6722, bbox:[ 977 496 1889 1080]
potted plant is in the picture with confidence:0.5759, bbox:[ 83 791 529 1080]
person is in the picture with confidence:0.6752, bbox:[ 967 502 1878 1080]
[ERROR]["vps"][vps/hb_vps_api.c:2438] [2383.679993]HB_VPS_GetChnFrame[2438]: G0 VPS error get chn3 frame timeout
[ERROR]["vio_bufmgr"][utils/hb_vio_buffer_mgr.c:2011] [2383.680073]buf_mgr_print_qcount[2011]: Mgr(3)state:Total(5)Avail(2)Process(3)Done(0)Repro(0)User(0).
HB_VPS_GetChnFrame Failed. ret = -268696588
Traceback (most recent call last):
File "mipi_camera.py", line 345, in <module>
img = np.frombuffer(img, dtype=np.uint8)
TypeError: a bytes-like object is required, not 'NoneType'
【INFO】: Offload model "fcos_512x512_nv12" Successfully.
root@ubuntu:/app/ai_inference/03_mipi_camera_sample#
定时写串口:
{
auto timer_callback =
[this]() -> void{
//写串口定时器
UpdateSerialParamsOut();
//正式项目函数
//UpdateMoveParamsOut();
};
update_params_out_timer_ = this->create_wall_timer(std::chrono::milliseconds(200), timer_callback, nullptr);
}
///
///正常写串口测试
///会导致mipi异常
///
void ParamsSubscriber::UpdateSerialParamsOut(){
RobotParamsOut robot_params_out;
robot_params_out.x = (float)(rand()%10)/(10.f); //一个0-0.99的随机数
robot_params_out.y = 0.01 ;
robot_params_out.action = RobotAction::ACTION_GO;
std::cout << "Serial test : " << TTY_S_NAME << "UpdateSerialParamsOut...x =" <<robot_params_out.x << std::endl;
EPetStatusMachine::Instance()->ProcessParamsOut(&robot_params_out);
}
///
///写串口
///
void EPetProtocolProcess::WriteCommand(const RobotParamsOut robot_params_out){
DataFrame cmdFrame;
float leftSpeed = 0.0, rightSpeed = 0.0;
float x_linear = robot_params_out.x;
float y_angular = robot_params_out.y;
//差分轮运动学模型求解
if(x_linear ==0){
leftSpeed = -y_angular / 2.0;
rightSpeed = y_angular / 2.0;
}else{
leftSpeed = x_linear - y_angular * ORIGINBOT_WHEEL_TRACK / 2.0;
rightSpeed = x_linear + y_angular * ORIGINBOT_WHEEL_TRACK / 2.0;
}
if(SPEED_DIRECTION_REVERT){
leftSpeed = -leftSpeed;
rightSpeed = -rightSpeed;
}
if(DEBUG_OPEN){
RCLCPP_INFO(rclcpp::get_logger("ePet protocol process"),"WriteCommand...leftSpeed = '%f' rightSpeed = '%f'", leftSpeed * 100, rightSpeed * 100);
}
if (leftSpeed < 0)
cmdFrame.data[0] = 0x00; //速度为负;
else
cmdFrame.data[0] = 0xff; //速度为正
cmdFrame.data[1] = int(abs(leftSpeed) * 1000) & 0xff; //速度值从m/s变为mm/s
cmdFrame.data[2] = (int(abs(leftSpeed) * 1000) >> 8) & 0xff;
if (rightSpeed < 0)
cmdFrame.data[3] = 0x00;
else
cmdFrame.data[3] = 0xff;
cmdFrame.data[4] = int(abs(rightSpeed) * 1000) & 0xff; //速度值从m/s变为mm/s
cmdFrame.data[5] = (int(abs(rightSpeed) * 1000) >> 8) & 0xff;
cmdFrame.check = (cmdFrame.data[0] + cmdFrame.data[1] + cmdFrame.data[2] +
cmdFrame.data[3] + cmdFrame.data[4] + cmdFrame.data[5]) & 0xff;
// 封装速度命令的数据帧
cmdFrame.header = 0x55;
cmdFrame.id = 0x01;
cmdFrame.length = 0x06;
cmdFrame.tail = 0xbb;
try
{
serial_.write(&cmdFrame.header, sizeof(cmdFrame)); //向串口发数据
}
catch (serial::IOException &e)
{
RCLCPP_INFO(rclcpp::get_logger("ePet params process"), "Unable to send data through serial port"); //如果发送数据失败,打印错误信息
}
// 考虑平稳停车的计数值
if((fabs(x_linear) > 0.0001) || (fabs(y_angular) > 0.0001)){
//auto_stop_count_ = 0;
}
if(DEBUG_CLOSE){
RCLCPP_INFO(rclcpp::get_logger("ePet protocol process"),"Send to controller frame raw data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x \n", cmdFrame.header, cmdFrame.id, cmdFrame.length, cmdFrame.data[0], cmdFrame.data[1], cmdFrame.data[2], cmdFrame.data[3], cmdFrame.data[4], cmdFrame.data[5], cmdFrame.check, cmdFrame.tail);
}
}