欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Apollo 中添加Radar

程序员文章站 2022-07-12 11:47:16
...

装好雷达后

1.在modules/canbus/vehicle/lincoln/protocol 下创建radar的解析类。

/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

#include "modules/canbus/vehicle/lincoln/protocol/radar_302.h"

#include "modules/canbus/common/byte.h"

namespace apollo {
namespace canbus {
namespace lincoln {

const int32_t Radar302::ID = 0x302;

void Radar302::Parse(const std::uint8_t* bytes, int32_t length,
                       ChassisDetail* car_status) const {

  Byte frame_0(bytes + 0);
  int32_t b0 = frame_0.get_byte(0, 8);
  Byte frame_1(bytes + 1);
  int32_t b1 = frame_1.get_byte(0, 8);
  Byte frame_2(bytes + 2);
  int32_t b2 = frame_2.get_byte(0, 8);
  Byte frame_3(bytes + 3);
  int32_t b3 = frame_3.get_byte(0, 8);
  Byte frame_4(bytes + 4);
  int32_t b4 = frame_4.get_byte(0, 8);
  car_status->mutable_rtest()->set_rtest_flag(0); 
  car_status->mutable_rtest()->set_b0(b0);
  car_status->mutable_rtest()->set_b1(b1*2);
  car_status->mutable_rtest()->set_b2(b2*2);
  car_status->mutable_rtest()->set_b3(b3*2);
  car_status->mutable_rtest()->set_b4(b4*2);
  if (b0==0x40){
     if (b1<= 0x19 || b2<=0x64 || b3<=0x64 || b4<=0x19)
      {//2m
        car_status->mutable_rtest()->set_rtest_flag(1); 
      }
    }
    else{
        car_status->mutable_rtest()->set_rtest_flag(2); 
    }
}


}  // namespace lincoln
}  // namespace canbus
}  // namespace apollo

这里的逻辑是2m检测。

2.在build中注册

3.在message-manager中注册

4.之后在chassis.proto和chassis_detail.proto中添加标识值

5.在Lincoln_controller 中转换message

 

待补充……

相关标签: Apollo