search
HomeTechnology peripheralsAIApollo 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.

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')

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 } }}

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
This article is reproduced at:51CTO.COM. If there is any infringement, please contact admin@php.cn delete
A Comprehensive Guide to ExtrapolationA Comprehensive Guide to ExtrapolationApr 15, 2025 am 11:38 AM

Introduction Suppose there is a farmer who daily observes the progress of crops in several weeks. He looks at the growth rates and begins to ponder about how much more taller his plants could grow in another few weeks. From th

The Rise Of Soft AI And What It Means For Businesses TodayThe Rise Of Soft AI And What It Means For Businesses TodayApr 15, 2025 am 11:36 AM

Soft AI — defined as AI systems designed to perform specific, narrow tasks using approximate reasoning, pattern recognition, and flexible decision-making — seeks to mimic human-like thinking by embracing ambiguity. But what does this mean for busine

Evolving Security Frameworks For The AI FrontierEvolving Security Frameworks For The AI FrontierApr 15, 2025 am 11:34 AM

The answer is clear—just as cloud computing required a shift toward cloud-native security tools, AI demands a new breed of security solutions designed specifically for AI's unique needs. The Rise of Cloud Computing and Security Lessons Learned In th

3 Ways Generative AI Amplifies Entrepreneurs: Beware Of Averages!3 Ways Generative AI Amplifies Entrepreneurs: Beware Of Averages!Apr 15, 2025 am 11:33 AM

Entrepreneurs and using AI and Generative AI to make their businesses better. At the same time, it is important to remember generative AI, like all technologies, is an amplifier – making the good great and the mediocre, worse. A rigorous 2024 study o

New Short Course on Embedding Models by Andrew NgNew Short Course on Embedding Models by Andrew NgApr 15, 2025 am 11:32 AM

Unlock the Power of Embedding Models: A Deep Dive into Andrew Ng's New Course Imagine a future where machines understand and respond to your questions with perfect accuracy. This isn't science fiction; thanks to advancements in AI, it's becoming a r

Is Hallucination in Large Language Models (LLMs) Inevitable?Is Hallucination in Large Language Models (LLMs) Inevitable?Apr 15, 2025 am 11:31 AM

Large Language Models (LLMs) and the Inevitable Problem of Hallucinations You've likely used AI models like ChatGPT, Claude, and Gemini. These are all examples of Large Language Models (LLMs), powerful AI systems trained on massive text datasets to

The 60% Problem — How AI Search Is Draining Your TrafficThe 60% Problem — How AI Search Is Draining Your TrafficApr 15, 2025 am 11:28 AM

Recent research has shown that AI Overviews can cause a whopping 15-64% decline in organic traffic, based on industry and search type. This radical change is causing marketers to reconsider their whole strategy regarding digital visibility. The New

MIT Media Lab To Put Human Flourishing At The Heart Of AI R&DMIT Media Lab To Put Human Flourishing At The Heart Of AI R&DApr 15, 2025 am 11:26 AM

A recent report from Elon University’s Imagining The Digital Future Center surveyed nearly 300 global technology experts. The resulting report, ‘Being Human in 2035’, concluded that most are concerned that the deepening adoption of AI systems over t

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.