Apollo partners with Carsim/TruckSim for joint simulation
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.
2.1 Apollo, simulink and Trucksim solutions
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.
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.
rosbridge solution diagram
3. Function implementation
3.1 Apollo, simulink and Trucksim solutions
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.
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.
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')
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.
Main interface
Input parameter configuration interface
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
3.2.1.3 Interface definition of Apollo project and QT project
/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 } }}
4. 使用心得
- TruckSim模型离散时间补偿设置为0.001s,即模型更新频率为1000hz,选择每个步长更新两次的积分方法(如:AM-2, RK-2等)。
注释:
1)真车是一个高阶非线性连续系统,TruckSim通过固定时间步长离散系统来模拟真车,当模型步长选择较大时(如之前设置的0.01s),模型较不准;TruckSim模型是由悬架系统-动力系统-转向系统-制动系统-轮胎模型-空气动力学等系统构成的复杂系统,当其中一个或多个系统因为时间步长太大而很不准时,就会出现车抖动比较明显的现象。
2)模型更新频率设为1000hz是TruckSim官网推荐的,经验证,这个频率能解决车抖动问题。
- 接口线程加载频率用定时器控制,加载调用simfile.sim,license和DLL的频率设置为1000hz,与Trucksim模型离散步长一致。
注释:
受3中积分方法决定,当选择每个步长更新两次的积分方法,VS_EXT_EQ_IN和VS_EXT_EQ_OUT更新频率是加载频率的2倍,为2000hz。
原文链接: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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Since April 2, the "Liberation Day", the U.S. stock market has experienced unprecedented drastic fluctuations. The US's aggressive trade policy caught Wall Street off guard, triggering panic selling and violent shocks last week. The Dow Jones Index plummeted 4,000 points in just 48 hours, setting an unprecedented record of falling more than 1,500 points on two consecutive days in history. Meanwhile, the S&P 500 fell 10.5%, and its market value evaporated by nearly $5 trillion. False information and speculative market false information plays an important role in recent market fluctuations. For example, a Twitter account with about 1,000 followers claimed that the United States would suspend tariffs for 90 days, and was then forwarded by another account with about 800,000 followers, "Walter Bloomberg." This incident caused severe market fluctuations and stock prices soared.

The top ten safe and reliable exchanges in the 2025 cryptocurrency circle include: 1. Binance, 2. OKX, 3. Gate.io (Sesame Open), 4. Coinbase, 5. Kraken, 6. Huobi Global, 7. Gemini, 8. Crypto.com, 9. Bitfinex, 10. KuCoin. These exchanges are rated as safe and reliable based on compliance, technical strength and user feedback.

South Korean court sentenced three people to prison for cryptocurrency scams. South Korea's Busan District Court recently made a verdict on a complicated cryptocurrency fraud case, and the three main culprits were sentenced to jail for fraudulent investors of 110 million won (about 416,000 US dollars). The court found that the three people used the fake "exclusive trading algorithm" as bait and promised a huge monthly return of 30% to defraud many victims. This algorithm does not actually exist, it is a tool used to commit fraud. The three defendants (published by last names only: Kim, Lee and Joe) used the public's enthusiasm for cryptocurrencies to fabricate lies from a global trading network to attract investors. The main culprit Jin was sentenced to four and a half years in prison, while Li and Qiao were sentenced to three and a half years in prison respectively. The judge pointed out that their behavior was severe

The top ten cryptocurrency exchanges in 2025 are: 1. Binance, 2.Bybit, 3.OKX, 4.Coinbase, 5.Kraken, 6.HTX, 7.Gate.io, 8.KuCoin, 9.Crypto.com, 10.BitMEX. These exchanges have their own characteristics to meet the needs of different users.

The charity party hosted by the Langley Community Health and Hospital Foundation raised $331,000 to establish the Guru Nanak Endowment Fund. The donation raised by the "Heart of Giving" charity party for Langley Memorial Hospital has reached one-third of its million-dollar target. On April 4, more than 250 guests attended the annual fundraising event at the Cloverdale Mirage Ballroom. Activities include raffle draws, silent auctions, live auctions and fundraising games, with 50/50 draws continuing until May 2. Since 2019, the Heart of Giving charity party has brought together donors every year to celebrate the community and raise donations, said Heather Scott, executive director of the Langley Community Health and Hospital Foundation. She said: "Testimation

The world's leading ten digital currency apps include: 1. OKX, 2. Binance, 3. Huobi, 4. Matcha (MXC), 5. Bitget, 6. BitMEX, 7. Pionex, 8. Deribit, 9. Bybit, 10. Kraken. These platforms have their own characteristics in security, transaction services, technical architecture, risk control team, user experience and ecosystem.

The top ten digital currency exchanges in the currency circle: 1. OKX, 2. Binance, 3. Gate.io, 4. Coinbase, 5. Bybit, 6. Kraken, 7. KuCoin, 8. Bitget, 9. MEXC, 10. HTX, each performs outstandingly in the world's top digital asset platforms, daily trading volume, ten-year-old exchanges, Nasdaq listing, derivative trading volume, bank-level asset custody, innovative currency, order-study systems, innovation zone projects, Huobi brand upgrades, etc.

There are multiple choices for virtual currency quantitative trading platforms, including: 1. Anbi quantitative trading platform, providing rich API interfaces and real-time market conditions; 2. Gate.io quantitative trading platform, known for its stable systems and high-quality services; 3. oKx quantitative trading platform, having leading trading depth and liquidity; 4. BitMEX quantitative trading platform, focusing on Bitcoin derivatives trading; 5. Bihuo quantitative trading platform, providing strong technical support and strategy templates; 6. ZB quantitative trading platform, with high quantitative functions and high praise; 7. Matcha quantitative trading platform, developing rapidly and providing profit sharing; 8. Bybit quantitative trading platform, known for its high performance and high stability; 9. MXC quantitative trading platform, with high functionality and cost-effectiveness;
