Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add a new vehicle to Apollo

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

这篇文章主要介绍了怎么在Apollo中添加新的车辆,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

简介

我们通过本文将向开发者阐述如何向Apollo中添加新的车辆。

注意: Apollo控制算法将林肯MKZ配置为默认车辆

添加新的车辆时,如果您的车辆需要不同于Apollo控制算法提供的属性,请参考:

使用适合您的车辆的其它控制算法。

修改现有算法的参数以获得更好的结果。

添加新车辆的步骤

按照以下步骤以实现新车辆的添加:

实现新的车辆控制器

实现新的消息管理器

实现新的车辆工厂

注册新的车辆

更新配置文件

一、实现新的车辆控制器

新的车辆控制器是从 VehicleController类继承的。 下面提供了一个头文件示例:

/** * @class NewVehicleController * * @brief this class implements the vehicle controller for a new vehicle. */class NewVehicleController final : public VehicleController { public: /** * @brief initialize the new vehicle controller. * @return init error_code */ ::apollo::common::ErrorCode Init( const VehicleParameter& params, CanSender* const can_sender, MessageManager* const message_manager) override; /** * @brief start the new vehicle controller. * @return true if successfully started. */ bool Start() override; /** * @brief stop the new vehicle controller. */ void Stop() override; /** * @brief calculate and return the chassis. * @returns a copy of chassis. Use copy here to avoid multi-thread issues. */ Chassis chassis() override; // more functions implemented here ...};

二、实现新的消息管理器

新的消息管理器是从 MessageManager 类继承的。 下面提供了一个头文件示例。

/** * @class NewVehicleMessageManager * * @brief implementation of MessageManager for the new vehicle */class NewVehicleMessageManager : public MessageManager { public: /** * @brief construct a lincoln message manager. protocol data for send and * receive are added in the construction. */ NewVehicleMessageManager(); virtual ~NewVehicleMessageManager(); // define more functions here. ...};

三、实施新的车辆工厂

新的车辆工厂是从 AbstractVehicleFactory 类继承的。下面提供了一个头文件示例。

/** * @class NewVehicleFactory * * @brief this class is inherited from AbstractVehicleFactory. It can be used to * create controller and message manager for lincoln vehicle. */class NewVehicleFactory : public AbstractVehicleFactory { public: /** * @brief destructor */ virtual ~NewVehicleFactory() = default; /** * @brief create lincoln vehicle controller * @returns a unique_ptr that points to the created controller */ std::unique_ptr CreateVehicleController() override; /** * @brief create lincoln message manager * @returns a unique_ptr that points to the created message manager */ std::unique_ptr CreateMessageManager() override;};

一个.cc示例文件如下:

std::unique_ptrNewVehicleFactory::CreateVehicleController() { return std::unique_ptr(new lincoln::LincolnController());}std::unique_ptr NewVehicleFactory::CreateMessageManager() { return std::unique_ptr(new lincoln::LincolnMessageManager());}

Apollo提供可以用于实现新车辆协议的基类 ProtocolData。

四、注册新的车辆

在modules/canbus/vehicle/vehicle_factory.cc里注册新的车辆。 下面提供了一个头文件示例。

void VehicleFactory::RegisterVehicleFactory() { Register(VehicleParameter::LINCOLN_MKZ, []() -> AbstractVehicleFactory* { return new LincolnVehicleFactory(); }); // register the new vehicle here. Register(VehicleParameter::NEW_VEHICLE_BRAND, []() -> AbstractVehicleFactory* { return new NewVehicleFactory(); });}

五、更新配置文件

在 modules/canbus/conf/canbus_conf.pb.txt 中更新配置,在Apollo系统中激活车辆。

vehicle_parameter { brand: NEW_VEHICLE_BRAND // put other parameters below ...}感谢你能够认真阅读完这篇文章,希望小编分享的"怎么在Apollo中添加新的车辆"这篇文章对大家有帮助,同时也希望大家多多支持,关注行业资讯频道,更多相关知识等着你来学习!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report