Table of Contents
1. Background
2. Architecture design
3.1 Apollo, simulink and Trucksim solutions
3.2 Apollo, rosbridge and Trucksim solutions
3. Function implementation
4. 使用心得
Home Technology peripherals AI Apollo partners with Carsim/TruckSim for joint simulation

Apollo partners with Carsim/TruckSim for joint simulation

Jan 13, 2024 pm 04:51 PM
tool Autopilot

1. Background

Simulation plays an important role in autonomous driving research and development. It can greatly improve research and development efficiency and provide guarantee for the reliability of algorithms. As an excellent open source platform, Baidu Apollo system is very suitable for research by friends who are interested in learning autonomous driving. In addition, Carsim/Trucksim is a highly respected classic vehicle dynamics simulation tool.

This article introduces the method of realizing local real-time simulation through the combination of Apollo and Trucksim. It is suitable for beginners to build a simulation platform and study the Apollo system.

2. Architecture design

The core code of the Apollo project is implemented in C. Common interfaces for Trucksim include simulink, Python and C language. This article will first introduce the architecture of Apollo, simulink and Trucksim joint simulation, and discuss the problems existing in this simulation system. Next, we will focus on the joint simulation of Apollo and Trucksim.

Simulink and Apollo can communicate through ROS. Since Apollo's message data format is protobuf, and Simulink's ROS tool only supports standard ROS messages (ROS msg), a format conversion node can be added to Apollo to achieve compatibility. Regarding the solution of Simulink calling Trucksim, there are many resources on the Internet for reference, so I will not go into details.

Apollo partners with Carsim/TruckSim for joint simulation

simulink solution diagram

2.2 Apollo, rosbridge and Trucksim solutions

Establish websocket communication between the QT project and the Apollo project. In the Apollo project, the mutual conversion between ros messages (or cyber messages) and websockets is realized by adding the rosbridge (or cyber_bridge) module. The QT project is implemented in C as a websocket client and calls Trucksim's dynamic library to realize the function of running Trucksim in real time.

Apollo partners with Carsim/TruckSim for joint simulation

rosbridge solution diagram

3. Function implementation

3.1.1 Simulink configuration

The Simulink toolkit has a ROS support package, and the ROS network address is configured as shown in Figure 2. Hostname/IP Address and Port are the address and port number of ROS_MASTER_URI respectively, which are explained in the communication mechanism above.

Apollo partners with Carsim/TruckSim for joint simulation

Configure ROS network address

ROS subscriber receives messages from the interface, so the Topic, Message type, and Sample time must correspond to the program in the interface.

Apollo partners with Carsim/TruckSim for joint simulation

Configuring ros subcribe

In order to facilitate debugging and verification, now start ROS on the MATLAB side. The configuration process is as follows:

MATLAB setting instructions:

>> setenv('ROS_MASTER_URI','http://192.168.103.122:11311')>> setenv('ROS_IP','192.168.103.198')>> rosinit('192.168.103.122')
Copy after login

3.1.2 TruckSim configuration

Configuration interface

Trucksim is a wizard-based programming. Parameter configuration interface: Select 5A Tractor (SS_SSS) for trucks. See Figure 3 for specific parameters. Control interface: Select simulink for Models.

Apollo partners with Carsim/TruckSim for joint simulation

Main interface

Apollo partners with Carsim/TruckSim for joint simulation

Input parameter configuration interface

Apollo partners with Carsim/TruckSim for joint simulation

Output parameter configuration interface

3.2 Apollo, rosbridge and Trucksim solutions

3.2.1 Configuring rosbridge in apollo

There are many online tutorials for rosbridge installation. This article will not go into details.

The usage is as follows:

cd ros_pkgs_ws

catkin_make

Start rosbridge

source /apollo/ros_pkgs_ws/devel/setup.bash

PATH=/usr/local/miniconda2/bin:$PATH

roslaunch rosbridge_server rosbridge_websocket.launch

3.2.1 Qt project configuration instructions

3.2.1.1 Qt and CMake version information

Apollo partners with Carsim/TruckSim for joint simulation

3.2.1.3 Interface definition of Apollo project and QT project

Apollo partners with Carsim/TruckSim for joint simulation

/apollo/trucksim/pose

{"op":"publish","topic":"/apollo/tucksim/pose","msg": {"header": {"timestamp_sec":1572253610.76292, "sequence_num":77}, "trucksimpose": {"XCG_TM":30.9964522249, // 单位:m "YCG_TM":0.657853758823, // 单位:m "ZCG_TM":1.00644079555, // 单位:m "YAW":-0.015505948987, // 单位:rad "VX":7.81497285565, // 单位:m/s "STEER_SW":2.84450684087, // 单位:rad "AV_Y":0.133153549217, // 单位:rad/s "GEARSTAT":5.0, // 无单位 "XCG_TM2":22.5890979801, // 单位:m "YCG_TM2":-0.471483304991, // 单位:m "ZCG_TM2":2.08466406388, // 单位:m "YAW_2":-0.0253130178796, // 单位:rad "VY":0.326368169782, // 单位:m/s "DISTANCE":31.0034324244, // 单位:m "DELTA_YAW":-0.015505948987, // 单位:rad "DISTANCE_2":22.5940178822, // 单位:m "DELTA_YAW_2":-0.0253130178796 // 单位:rad/s } }}
Copy after login

4. 使用心得

  1. TruckSim模型离散时间补偿设置为0.001s,即模型更新频率为1000hz,选择每个步长更新两次的积分方法(如:AM-2, RK-2等)。

注释:
1)真车是一个高阶非线性连续系统,TruckSim通过固定时间步长离散系统来模拟真车,当模型步长选择较大时(如之前设置的0.01s),模型较不准;TruckSim模型是由悬架系统-动力系统-转向系统-制动系统-轮胎模型-空气动力学等系统构成的复杂系统,当其中一个或多个系统因为时间步长太大而很不准时,就会出现车抖动比较明显的现象。

2)模型更新频率设为1000hz是TruckSim官网推荐的,经验证,这个频率能解决车抖动问题。

  1. 接口线程加载频率用定时器控制,加载调用simfile.sim,license和DLL的频率设置为1000hz,与Trucksim模型离散步长一致。

注释:
受3中积分方法决定,当选择每个步长更新两次的积分方法,VS_EXT_EQ_IN和VS_EXT_EQ_OUT更新频率是加载频率的2倍,为2000hz。

Apollo partners with Carsim/TruckSim for joint simulation

原文链接:https://mp.weixin.qq.com/s/8QNp5iQebE3lPJzEgq_bOA

The above is the detailed content of Apollo partners with Carsim/TruckSim for joint simulation. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Bitcoin price today Bitcoin price today Apr 28, 2025 pm 07:39 PM

Bitcoin’s price fluctuations today are affected by many factors such as macroeconomics, policies, and market sentiment. Investors need to pay attention to technical and fundamental analysis to make informed decisions.

Recommended reliable digital currency trading platforms. Top 10 digital currency exchanges in the world. 2025 Recommended reliable digital currency trading platforms. Top 10 digital currency exchanges in the world. 2025 Apr 28, 2025 pm 04:30 PM

Recommended reliable digital currency trading platforms: 1. OKX, 2. Binance, 3. Coinbase, 4. Kraken, 5. Huobi, 6. KuCoin, 7. Bitfinex, 8. Gemini, 9. Bitstamp, 10. Poloniex, these platforms are known for their security, user experience and diverse functions, suitable for users at different levels of digital currency transactions

Free coins trading market software recommendations The top ten easy-to-use coins trading apps Free coins trading market software recommendations The top ten easy-to-use coins trading apps Apr 28, 2025 pm 04:33 PM

The top ten recommended cryptocurrency trading software are: 1. OKX, 2. Binance, 3. Coinbase, 4. KuCoin, 5. Huobi, 6. Crypto.com, 7. Kraken, 8. Bitfinex, 9. Bybit, 10. Gate.io. These apps all provide real-time market data and trading tools, suitable for users at different levels.

How much is Bitcoin worth How much is Bitcoin worth Apr 28, 2025 pm 07:42 PM

Bitcoin’s price ranges from $20,000 to $30,000. 1. Bitcoin’s price has fluctuated dramatically since 2009, reaching nearly $20,000 in 2017 and nearly $60,000 in 2021. 2. Prices are affected by factors such as market demand, supply, and macroeconomic environment. 3. Get real-time prices through exchanges, mobile apps and websites. 4. Bitcoin price is highly volatile, driven by market sentiment and external factors. 5. It has a certain relationship with traditional financial markets and is affected by global stock markets, the strength of the US dollar, etc. 6. The long-term trend is bullish, but risks need to be assessed with caution.

Download the official website of Ouyi Exchange app for Apple mobile phone Download the official website of Ouyi Exchange app for Apple mobile phone Apr 28, 2025 pm 06:57 PM

The Ouyi Exchange app supports downloading of Apple mobile phones, visit the official website, click the "Apple Mobile" option, obtain and install it in the App Store, register or log in to conduct cryptocurrency trading.

Spot King Transformation Note: How to layout the next generation of on-chain ecosystem with Gate.io MeMebox 2.0? Spot King Transformation Note: How to layout the next generation of on-chain ecosystem with Gate.io MeMebox 2.0? Apr 28, 2025 pm 03:36 PM

Gate.io has achieved the transformation from spot trading to on-chain ecosystem through MeMebox 2.0. 1) Build a cross-chain infrastructure and support the interoperability of 12 main chains; 2) Create a DeFi application ecosystem and provide one-stop services; 3) Implement incentive mechanisms and reconstruct value allocation.

How to choose a compliant and secure Bitcoin trading platform How to choose a compliant and secure Bitcoin trading platform Apr 28, 2025 pm 05:42 PM

When choosing a compliant and secure Bitcoin trading platform, you need to evaluate its regulatory license, KYC/AML policies and security measures, and recommend three major platforms: Binance, OKX and gate.io.

Ouyi official website entrance Ouyi official latest entrance 2025 Ouyi official website entrance Ouyi official latest entrance 2025 Apr 28, 2025 pm 07:48 PM

Choose a reliable trading platform such as OKEx to ensure access to the official entrance.

See all articles