+ All Categories
Home > Documents > mvsim - Read the Docs

mvsim - Read the Docs

Date post: 19-Mar-2022
Category:
Upload: others
View: 7 times
Download: 0 times
Share this document with a friend
33
mvsim Mar 06, 2022
Transcript

mvsim

Mar 06, 2022

Contents

1 Features 1

2 Installing 32.1 Build from sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 ROS: Compiling & usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 First steps 53.1 1. Manual vehicle teleop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 Architecture 7

5 Simulated world definition 95.1 1. Global XML tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95.2 2. GUI options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95.3 3. β€œWorld elements” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105.4 4. Vehicle class descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

5.4.1 Vehicle dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115.4.2 Common . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115.4.3 Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115.4.4 Ackermann-drivetrain model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115.4.5 Friction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125.4.6 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

5.5 5. Vehicle instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.6 6. β€œObstacle block” classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.7 7. β€œObstacle block” instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.8 8. Vehicles and blocks parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5.8.1 Related to topic publication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.8.2 Related to visual aspect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

6 Simulation execution 15

7 Physic models 177.1 1. Wheel dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177.2 2. Friction models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

7.2.1 Friction models base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177.2.2 Default friction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187.2.3 Ward-Iagnemma friction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

i

7.3 3. Vehicle models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197.3.1 Vehicle base class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197.3.2 Differential driven . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207.3.3 Ackermann driven . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207.3.4 Ackermann-driven with drivetrain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

7.4 4. Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227.4.1 Differential raw controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227.4.2 Differential Twist controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227.4.3 Ackermann raw controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227.4.4 Ackermann twist controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227.4.5 Ackermann steering controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237.4.6 Ackermann-drivetrain controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

8 Extensions 25

9 About 27

10 Indices and tables 29

ii

CHAPTER 1

Features

β€’ Lightweight in memory, CPU and library requirements.

β€’ Fully configurable via .xml β€œworld” files.

β€’ World maps:

– Occupancy gridmaps: input as images or MRPT binary maps (from icp-slam, rbpf-slam, etc.)

– Elevation meshes.

β€’ Vehicle models:

– Differential driven (2 & 4 wheel drive).

– Ackermann steering (kinematic & dynamic steering, different mechanical drive models).

β€’ Sensors:

– 2D lidar scanners: Robots see each other, their own bodies, etc.

β€’ Interface to vehicles: Choose among:

– Raw access to forces and motor torques.

– Twist commands (using internal controllers).

1

mvsim

2 Chapter 1. Features

CHAPTER 2

Installing

2.1 Build from sources

Dependencies:

β€’ A decent C++17 compiler.

β€’ CMake >= 3.1

β€’ MRPT (>=2.0.0): In Windows, build from sources or install precompiled binaries.

β€’ Box2D: Will use an embedded copy if no system version is found.

In Ubuntu, this will install all requirements:

sudo apt install \build-essential cmake g++ \libbox2d-dev \libmrpt-opengl-dev libmrpt-obs-dev libmrpt-maps-dev \libmrpt-gui-dev libmrpt-tfest-dev \protobuf-compiler \libzmq3-dev \pybind11-dev \libprotobuf-dev \libpython3-dev

Compile as usual:

mkdir buildcd buildcmake ..make#make test

3

mvsim

2.2 ROS: Compiling & usage

Either install as a precompiled package:

sudo apt install ros-$ROS_DISTRO-mvsim

Or build from sources, by cloning into a catkin workspace and build as usual.

Usage: See docs and tutorials in https://wiki.ros.org/mvsim

4 Chapter 2. Installing

CHAPTER 3

First steps

After installing or building from sources, you are ready to test the standalone simulator applications to get used toMVSIM.

3.1 1. Manual vehicle teleop

build/bin/mvsim-server mvsim_tutorial/mvsim_demo_2robots.xml

You should see the GUI of a demo world with two robots equipped with a 2D lidar, scanning a model defined bymeans of an occupancy grid map and a couple of boxes.

Use the keyboard to teleop the vehicle: w/s to increase/decrease the PI controller setpoint linear speed, and a/d toturn the Ackermann steering to the left/right. Use the spacebar as a brake.

Select the active robot by pressing the keys 1 or 2.

Note: The GUI of this program is likely to change soon.

5

mvsim

Fig. 1: Screenshot of the mvsim_demo_2robots example world.

6 Chapter 3. First steps

CHAPTER 4

Architecture

The project comprises:

β€’ A C++ library: libmvsim

β€’ A ROS1 node. It can be run standalone.

β€’ mvsim-server: A standalone program to run the simulation and, optionally, displaying a GUI live view ofthe world, accept keyboard/mouse orders, etc. It also uses ZMQ+protobuf as a communication system for userprograms to interact with the simulation (for example, from a C++ or Python program).

7

mvsim

8 Chapter 4. Architecture

CHAPTER 5

Simulated world definition

Simulation happens inside a World object. This is the central class for usage from user code, running the simulation,loading XML models, managing GUI visualization, etc. The ROS node acts as a bridge between this class and theROS subsystem.

Simulated worlds are described via configuration files called β€œworld” files, defined in the XML file format.

Many examples can be found in the mvsim_tutorial directory.

The next sections explain possible XML elements in a world file.

5.1 1. Global XML tags

World definition begins with tag <mvsim_world>. To define simulation timestep, use <simul_timestep> with floatvalue specified in seconds.

<mvsim_world version="1.0">...

<!-- General simulation options --><simul_timestep>0.005</simul_timestep> <!-- Simulation fixed-time interval

β†’Λ“for numerical integration [s] -->...</mvsim_world>

5.2 2. GUI options

GUI options are specified with tag gui. gui has several nested tags:

<mvsim_world version="1.0">...

<!-- GUI options -->

(continues on next page)

9

mvsim

(continued from previous page)

<gui><!-- Is camera orthographic or projective? --><ortho>false</ortho>

<!-- Show reaction forces on wheels with lines --><show_forces>true</show_forces><force_scale>0.01</force_scale> <!-- (Newtons to meters draw scale) --

β†’Λ“>

<!-- default camera distance in world units --><cam_distance>35</cam_distance>

<!-- camera vertical field of view in degrees --><fov_deg>35</fov_deg>

<!-- <follow_vehicle>r1</follow_vehicle> --></gui>

...</mvsim_world>

5.3 3. β€œWorld elements”

Scenario defines the β€œlevel” where the simulation takes place.

<element class=”occupancy_grid”> depicts MRPT occupancy map which can be specified with both image file(black and while) and MRPT grid maps. <file> specifies file path to image of the map.

<element class=”ground_grid”> is the metric grid for visual reference.

<element class=”elevation_map”> is an elevation map (!experimental). Mesh-based map is build of elevation mapin simple bitmap where whiter means higher and darker - lower.

This tag has several subtags:

β€’ <elevation_image> - path the elevation bitmap itself

β€’ <elevation_image_min_z> - minimum height in world units

β€’ <elevation_image_max_z> - maximum height in world units

β€’ <texture_image> - path texture image for elevation bitmap. Mus not be used with mesh_color simultaneously

β€’ <mesh_color> - mesh color in HEX RGB format

β€’ <resolution> - mesh XY scale

5.4 4. Vehicle class descriptions

Tag <vehicle:class> depictd description of vehicle class. The attribute name will be later referenced when describingvehicle exemplars.

Inside <vehicle:class> tag, there are tags <dynamics>, <friction> and exemplars of <sensor>.

10 Chapter 5. Simulated world definition

mvsim

5.4.1 Vehicle dynamics

At the moment, there are three types of vehicle dynamics implemented. Refer [vehicle_models] for more information.

<dynamics> with attribute class specifies class of dynamics used. Currently available classes:

β€’ differential

β€’ car_ackermann

β€’ ackermann_drivetrain

Each class has specific inner tags structure for its own configuration.

5.4.2 Common

Every dynamics has wheels specified with tags <i_wheel> where i stand for wheel position index (r, l for differentialdrive and fr, fl, rl, rr for Ackermann-drive)

Wheel tags have following attributes:

β€’ pos - two floats representing x an y coordinate of the wheel in local frame

β€’ mass - float value for mass of the wheel

β€’ width - float value representing wheel width [fig:wheel_forces]

β€’ diameter - float value to represent wheel diameter [fig:wheel_forces]

Ackermann models also use <max_steer_ang_deg> to specify maximum steering angle.

<chassis> is also common for all dynamics, it has attributes:

β€’ mass - mass of chassis

β€’ zmin - distance from bottom of the robot to ground

β€’ zmax - distance from top of the robot to ground

5.4.3 Controllers

There are controllers for every dynamics type [sec:controllers]. In XML their names are

β€’ raw - control raw forces

β€’ twist_pid - control with twist messages

β€’ front_steer_pid - [Ackermann only] - control with PID for velocity and raw steering angles

Controllers with pid in their names use PID regulator which needs to be configured. There are tags <KP><KI><KD>for this purpose. Also they need the parameter <max_torque> to be set.

Twist controllers need to set initial <V> and <W> for linear and angular velocities respectively.

Steer controllers need to set initial <V> and <STEER_ANG> for linear velocity and steering angle respectively.

5.4.4 Ackermann-drivetrain model

needs a differential type and split to be configured. For this purpose there is a tag <drivetrain> with argument type.Supported types are defined in [sec:ackermann_drivetrain]. In XML their names are:

β€’ open_front

5.4. 4. Vehicle class descriptions 11

mvsim

β€’ open_rear

β€’ open_4wd

β€’ torsen_front

β€’ torsen_rear

β€’ torsen_4wd

<drivetrain> has inner tags describing its internal structure:

β€’ <front_rear_split>

β€’ <front_rear_bias>

β€’ <front_left_right_split>

β€’ <front_left_right_bias>

β€’ <rear_left_right_split>

β€’ <rear_left_right_bias>

which are pretty self-explanatory.

5.4.5 Friction

Friction models are described in [sec:friction_models] and defined outside of <dynamics>. The tag for friction is<friction> with attribute class.

Class names in XML are:

β€’ wardiagnemma

β€’ default

Default friction [sec:default_friction] uses subtags:

β€’ <mu> - the friction coefficient

β€’ <C_damping> - damping coefficient

In addition to default, Ward-Iagnemma friction includes subtags:

β€’ A_roll

β€’ R1

β€’ R2

that are described in [sec:wi_friction].

5.4.6 Sensors

Sensors are defined with <sensor> tag. It has attributes type and name.

At the moment, only laser scanner sensor is implemented, its type is laser. Subtags are:

β€’ <pose> - an MRPT CPose3D string value

β€’ <fov_degrees> - FOV of the laser scanner

β€’ <sensor_period> - period in seconds when sensor sends updates

β€’ <nrays> - laser scanner rays per FOV

12 Chapter 5. Simulated world definition

mvsim

β€’ <range_std_noise> - standard deviation of noise in distance measurements

β€’ <angle_std_noise_deg> - standatd deviation of noise in angles of rays

β€’ <bodies_visible> - boolean flag to see other robots or not

5.5 5. Vehicle instances

For each vehicle class, an arbitrary number of vehicle instances can be created in a given world.

Vehicle instances are defined with the <vehicle> tag that has attributes name and class. class must match one of theclasses defined earlier with <vehicle:class> tag.

Subtags are:

β€’ <init_pose> - in global coordinates: π‘₯, 𝑦, 𝛾 (deg)

β€’ <init_vel> - in local coordinates: 𝑣π‘₯,𝑣𝑦 , πœ” (deg/s)

5.6 6. β€œObstacle block” classes

Write me!

5.7 7. β€œObstacle block” instances

Write me!

5.8 8. Vehicles and blocks parameters

Vehicles and obstacles blocks share common C++ mvsim::Simulable and mvsim::VisualObject interfacesthat provide the common parameters below.

Note: The following parameters can appear in either the {vehicle,block} class definitions or in a particular instantia-tion block, depending on whether you want parameters to be common to all instances or not, respectively.

5.8.1 Related to topic publication

Under the <publish> </publish> tag group:

β€’ publish_pose_topic: If provided, the pose of this object will be published as a topic with message typemvsim_msgs::Pose.

β€’ publish_pose_period: Period (in seconds) for the topic publication.

Example:

<publish><publish_pose_topic>/r1/pose</publish_pose_topic><publish_pose_period>50e-3</publish_pose_period>

</publish>

5.5. 5. Vehicle instances 13

mvsim

5.8.2 Related to visual aspect

Under the <visual> </visual> tag group:

β€’ model_uri: Path to 3D model file. Can be any file format supported by ASSIMP, like .dae, .stl, etc. Ifempty, the default visual aspect will be used.

β€’ model_scale: (Default=1.0) Scale to apply to the 3D model.

β€’ model_offset_x, model_offset_y , model_offset_z: (Default=0) Offset translation [meters].

β€’ model_yaw, model_pitch, model_roll: (Default=0) Optional model rotation [degrees].

β€’ show_bounding_box: (Default=β€˜β€˜falseβ€˜β€˜) Initial visibility of the object bounding box.

Example:

<visual><model_uri>robot.obj</model_uri><model_scale>1.0</model_scale><model_offset_x>0.0</model_offset_x><model_offset_y>0.0</model_offset_y><model_offset_z>0.0</model_offset_z>

</visual>

14 Chapter 5. Simulated world definition

CHAPTER 6

Simulation execution

Simulation executes step-by-step with user-defined βˆ†π‘‘ time between steps. Each step has several sub steps:

β€’ Before time step - sets actions, updates models, etc.

β€’ Actual time step - updates dynamics

β€’ After time step - everything needed to be done with updated state

Each vehicle is equipped with parameters logger(s). This logger is not configurable and can be rewritten programmat-icaly.

Logger are implemented via CsvLogger class and make log files in CSV format which then can be opened via anyeditor or viewer.

Loggers control is introduced via robot controllers, each controller controls only loggers of its robot.

Best results in visualizing offers QtiPlot [fig:qtiplot_example1].

At the moment, following characteristics are logged:

β€’ Pose (π‘₯, 𝑦, 𝑧, 𝛼, 𝛽, 𝛾)

β€’ Body velocity (οΏ½Μ‡οΏ½, οΏ½Μ‡οΏ½, οΏ½Μ‡οΏ½)

β€’ Wheel torque (𝜏 )

β€’ Wheel weight (π‘šπ‘€π‘)

β€’ Wheel velocity (𝑣π‘₯, 𝑣𝑦)

Loggers support runtime clear and creating new session. The new session mode finalizes current log files and starts towrite to a new bunch of them.

β€’ A limitation of box2d is that no element can be thinner than 0.05 units, or

the following assert will be raised while loading the world model:

15

mvsim

16 Chapter 6. Simulation execution

CHAPTER 7

Physic models

7.1 1. Wheel dynamics

We introduce wheels as a mass with cylindrical shape (Figure [fig:wheel_forces]). Each wheel has following proper-ties:

β€’ location of the wheel as to the chassis ref point [m,rad] in local coordinates 𝐿𝑀 = {π‘₯𝑀, 𝑦𝑀,Ξ¦}

β€’ diameter 𝑑𝑀 [m]

β€’ width 𝑀𝑀 [m]

β€’ mass π‘šπ‘€ [kg]

β€’ inertia 𝐼𝑦𝑦

β€’ spinning angular position πœ‘π‘€ [rad]

β€’ spinning angular velocity πœ”π‘€ [rad/s]

Thus, each wheel is represented as π‘Š = {𝐿𝑀, 𝑑𝑀, 𝑀𝑀,π‘šπ‘€, 𝐼𝑦𝑦, πœ‘π‘€, πœ”π‘€}

Fig. 1: Wheel forces

7.2 2. Friction models

7.2.1 Friction models base

Friction model base introduces Friction input structure, that incorporates forces of wheel

β€’ weight on this wheel from the car chassis, excluding the weight of the wheel itself 𝑀 [N]

β€’ motor torque 𝜏 [Nm]

17

mvsim

β€’ instantaneous velocity

𝜈 =

[οΈ‚πœˆπ‘₯πœˆπ‘¦

]οΈ‚in local coordinate frame

7.2.2 Default friction

At the moment, there is only one basic friction model available for vehicles. Default friction model evaluates . . .

Default friction evaluates forces in the wheel coordinate frame:

πœˆπ‘€ =

[οΈ‚πœˆπ‘€π‘₯

πœˆπ‘€π‘¦

]οΈ‚= 𝑅(Φ𝑀) Β· 𝜈

To calculate maximal allowed friction for the wheel, we introduce partial mass:

π‘šπ‘€π‘ =𝑀𝑀

𝑔+ π‘šπ‘€

𝐹𝑓,π‘šπ‘Žπ‘₯ = πœ‡ Β·π‘šπ‘€π‘ Β· 𝑔

Where πœ‡ is friction coefficient for wheel.

Calculating latitudinal friction (decoupled sub-problem):

𝐹𝑓,π‘™π‘Žπ‘‘ = π‘šπ‘€π‘ Β· π‘Ž = π‘šπ‘€π‘ Β·βˆ’πœˆπ‘€π‘¦

βˆ†π‘‘

𝐹𝑓,π‘™π‘Žπ‘‘ = π‘šπ‘Žπ‘₯(βˆ’πΉπ‘“,π‘šπ‘Žπ‘₯,π‘šπ‘–π‘›(𝐹𝑓,π‘™π‘Žπ‘‘, 𝐹𝑓,π‘šπ‘Žπ‘₯))

Calculating wheel desired angular velocity:

πœ”π‘π‘œπ‘›π‘ π‘‘π‘Ÿπ‘Žπ‘–π‘›π‘‘ =2πœˆπ‘€π‘₯

𝑑𝑀

π½π‘‘π‘’π‘ π‘–π‘Ÿπ‘’π‘‘ = πœ”π‘π‘œπ‘›π‘ π‘‘π‘Ÿπ‘Žπ‘–π‘›π‘‘ βˆ’ πœ”π‘€

πœ”π‘‘π‘’π‘ π‘–π‘Ÿπ‘’π‘‘ =π½π‘‘π‘’π‘ π‘–π‘Ÿπ‘’π‘‘

βˆ†π‘‘

Calculating longitudinal friction:

𝐹𝑓,π‘™π‘œπ‘› =1

𝑅· (𝜏 βˆ’ 𝐼𝑦𝑦 Β· πœ”π‘‘π‘’π‘ π‘–π‘Ÿπ‘’π‘‘ βˆ’ πΆπ‘‘π‘Žπ‘šπ‘ Β· πœ”π‘€)

𝐹𝑓,π‘™π‘œπ‘› = π‘šπ‘Žπ‘₯(βˆ’πΉπ‘“,π‘šπ‘Žπ‘₯,π‘šπ‘–π‘›(𝐹𝑓,π‘™π‘œπ‘›, 𝐹𝑓,π‘šπ‘Žπ‘₯))

Simply composing friction forces to vector:

𝐹𝑓 =

[︂𝐹𝑓,π‘™π‘Žπ‘‘

𝐹𝑓,π‘™π‘œπ‘›

]οΈ‚With new friction, we evaluate angular acceleration (code says angular velocity impulse, but the units are for acceler-ation) of the wheel:

𝛼 =𝜏 βˆ’π‘… Β· 𝐹𝑓,π‘™π‘œπ‘› βˆ’ πΆπ‘‘π‘Žπ‘šπ‘ Β· πœ”π‘€

𝐼𝑦𝑦

Using given angular acceleration, we update wheel’s angular velocity:

πœ”π‘€ = πœ”π‘€ + 𝛼 Β· βˆ†π‘‘

18 Chapter 7. Physic models

mvsim

7.2.3 Ward-Iagnemma friction

This type of friction is an implementation of paper from Chris Ward and Karl Iagnemma :raw-latex:β€˜\cite{ward-iagnemma-friction}β€˜.

Rolling resistance is generally modeled as a combination of static- and velocity-dependant forces [17], [21]. Authorspropose function with form similar to Pacejka’s model :raw-latex:β€˜\cite{pacejka_tire_model}β€˜ as a continuouslydifferentiable formulation of the rolling resistance with the static force smoothed at zero velocity to avoid a singularity.The rolling resistance is

πΉπ‘Ÿπ‘Ÿ = 𝑠𝑖𝑔𝑛(𝑉𝑓𝑀𝑑) ·𝑁 Β· (𝑅1 Β· (1π‘’π΄π‘Ÿπ‘œπ‘™π‘™|𝑉𝑓𝑀𝑑|) + 𝑅2 Β· |𝑉𝑓𝑀𝑑|)

Where π΄π‘Ÿπ‘œπ‘™π‘™, 𝑅1, 𝑅2 are the model-dependent coefficients. The impact of these coefficients is shown at figure[fig:wi_rr] taken from original paper.

This force πΉπ‘Ÿπ‘Ÿ is then added to 𝐹𝑓,π‘™π‘œπ‘›.

Default constants were chosen as in reference paper and showed good stability and robust results. In addition, theycan be altered via configuration file.

7.3 3. Vehicle models

Vehicle models are fully configurable with world XML files.

7.3.1 Vehicle base class

Vehicle base incorporates basic functions for every vehicle actor in the scene. It is also responsible for updating stateof vehicles.

It has implementation of interaction with world. Derived classes re-implement only work with torques/forces onwheels.

At the moment, no model takes into account the weight transfer, so weight on wheels is calculated in this base class.

Vehicle base class also provides ground-truth for velocity and position.

𝑝𝑀 =π‘π‘β„Žπ‘Žπ‘ π‘ π‘–π‘ π‘π‘€

β€’ Before time step:

– Update wheels position using Box2D

– Invoke motor controllers (reimplemented in derived classes)

– Evaluate friction of wheels with passed friction model

– Apply force to vehicle body using Box2D

β€’ Time step - update internal vehicle state variables π‘ž and π‘ž

β€’ After time step - updates wheels rotation

Center of mass is defined as center of Box2D shape, currently there is no +Z mobility.

7.3. 3. Vehicle models 19

mvsim

7.3.2 Differential driven

A differential wheeled robot is a mobile robot whose movement is based on two separately driven wheels placed oneither side of the robot body. It can thus change its direction by varying the relative rate of rotation of its wheels andhence does not require an additional steering motion.

Odometry-based velocity estimation is implemented via Euler formula (consider revising, it doesn’t include side slip):

πœ”π‘£π‘’β„Ž =πœ”π‘Ÿ Β·π‘…π‘Ÿ βˆ’ πœ”π‘™ Β·π‘…π‘Ÿ

π‘¦π‘Ÿ βˆ’ 𝑦𝑙

𝜈π‘₯ = πœ”π‘™ ·𝑅𝑙 + πœ” Β· 𝑦𝑙

πœˆπ‘¦ = 0

π‘Šβ„Žπ‘’π‘Ÿπ‘’ : π‘šπ‘Žπ‘‘β„Ž : β€˜πœ”π‘£π‘’β„Žβ€˜π‘–π‘ π‘Žπ‘›π‘”π‘’π‘™π‘Žπ‘Ÿπ‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦π‘œπ‘“π‘‘β„Žπ‘’π‘Ÿπ‘œπ‘π‘œπ‘‘,

𝑅𝑖 - radius of the wheel, 𝑦𝑖 is the y position of the wheel, πœ”π‘– is the angular velocity of the wheel. All calculations inthe robot’s local frame.

Nothing more interesting here.

7.3.3 Ackermann driven

Ackermann steering geometry is a geometric arrangement of linkages in the steering of a car or other vehicle designedto solve the problem of wheels on the inside and outside of a turn needing to trace out circles of different radii.

Ackermann wheels’ angles are computed as following:

π›Όπ‘œπ‘’π‘‘π‘’π‘Ÿ = π‘Žπ‘‘π‘Žπ‘›(π‘π‘œπ‘‘(|𝛼| +𝑀

2𝑙)

π›Όπ‘–π‘›π‘›π‘’π‘Ÿ = π‘Žπ‘‘π‘Žπ‘›(π‘π‘œπ‘‘(|𝛼| βˆ’ 𝑀

2𝑙)

π‘€β„Žπ‘’π‘Ÿπ‘’ : π‘šπ‘Žπ‘‘β„Ž : β€˜π›Όβ€˜π‘–π‘ π‘‘β„Žπ‘’π‘‘π‘’π‘ π‘–π‘Ÿπ‘’π‘‘π‘’π‘žπ‘’π‘–π‘£π‘Žπ‘™π‘’π‘›π‘‘π‘ π‘‘π‘’π‘’π‘Ÿπ‘–π‘›π‘”π‘Žπ‘›π‘”π‘™π‘’,

𝑀 is wheels distance and 𝑙 is wheels base. Outer and inner wheel are defined by the turn direction.

Odometry-based velocity estimation is implemented via Euler formula (consider revising, it doesn’t include side slip):

πœ”π‘£π‘’β„Ž =πœ”π‘Ÿπ‘Ÿ Β·π‘…π‘Ÿπ‘Ÿ βˆ’ πœ”π‘Ÿπ‘™ Β·π‘…π‘Ÿπ‘Ÿ

π‘¦π‘Ÿπ‘Ÿ βˆ’ π‘¦π‘Ÿπ‘™

𝜈π‘₯ = πœ”π‘Ÿπ‘™ Β·π‘…π‘Ÿπ‘™ + πœ” Β· π‘¦π‘Ÿπ‘™

πœˆπ‘¦ = 0

π‘Šβ„Žπ‘’π‘Ÿπ‘’ : π‘šπ‘Žπ‘‘β„Ž : β€˜πœ”π‘£π‘’β„Žβ€˜π‘–π‘ π‘Žπ‘›π‘”π‘’π‘™π‘Žπ‘Ÿπ‘£π‘’π‘™π‘œπ‘π‘–π‘‘π‘¦π‘œπ‘“π‘‘β„Žπ‘’π‘Ÿπ‘œπ‘π‘œπ‘‘,

π‘…π‘Ÿπ‘– - radius of the rear wheel, π‘¦π‘Ÿπ‘– is the y position of the rear wheel, πœ”π‘Ÿπ‘– is the angular velocity of the rear wheel. Allcalculations in the robot’s local frame.

7.3.4 Ackermann-driven with drivetrain

This type of dynamics has the same geometry as simple Ackermann-driven robots. However, its powertrain is com-pletely different.

Instead of one β€œmotor” per wheel, this type of dynamics incorporates one β€œmotor” linked to wheels by differentials.

There are two types of differentials:

20 Chapter 7. Physic models

mvsim

β€’ Open differntial

β€’ Torsen-like locking differential :raw-latex:β€˜\cite{torsen-whitepaper}β€˜

Each type of differential can be linked with following configurations:

β€’ Front drive

β€’ Rear drive

β€’ 4WD

Split is customizable between all axes.

As engine plays controller, whose torque output is then fed into differentials.

For open differential act the following equations:

𝜏𝐹𝐿 = πœπ‘šπ‘œπ‘‘π‘œπ‘Ÿ ·𝐾𝑠,𝑓 ·𝐾𝑠,π‘“π‘Ÿπ‘™

πœπΉπ‘… = πœπ‘šπ‘œπ‘‘π‘œπ‘Ÿ ·𝐾𝑠,𝑓 Β· (1 βˆ’πΎπ‘ ,π‘“π‘Ÿπ‘™)

πœπ‘…πΏ = πœπ‘šπ‘œπ‘‘π‘œπ‘Ÿ ·𝐾𝑠,π‘Ÿ ·𝐾𝑠,π‘Ÿπ‘Ÿπ‘™

πœπ‘…π‘… = πœπ‘šπ‘œπ‘‘π‘œπ‘Ÿ ·𝐾𝑠,π‘Ÿ Β· (1 βˆ’πΎπ‘ ,π‘“π‘Ÿπ‘™)

Where 𝐾𝑠,𝑓 ,𝐾𝑠,π‘“π‘Ÿπ‘™,𝐾𝑠,π‘Ÿπ‘Ÿπ‘™ are split coefficients between axes.

Different things happen for Torsen-like differentials. As this type is self-locking, its torque output per wheel dependson wheel’s velocity. Here is the function of selecting torque on the next time step based on previous time step velocity.First, introduce the bias ratio - the ratio indicating how much more torque the Torsen can send to the tire with moreavailable traction, than is used by the tire with less traction. This ratio represents the β€œlocking effect” of the differential.By default, it is set to 𝑏 = 1.5

πœ”1, πœ”2 and 𝑑1, 𝑑2 are the output axles angular velocities and torque splits respectively. 𝐾𝑠 is differential split when itis not locked.

πœ”π‘šπ‘Žπ‘₯ = π‘šπ‘Žπ‘₯(|πœ”1|, |πœ”2|)

πœ”π‘šπ‘–π‘› = π‘šπ‘–π‘›(|πœ”1|, |πœ”2|)

π›Ώπ‘™π‘œπ‘π‘˜ = πœ”π‘šπ‘Žπ‘₯ βˆ’ 𝑏 Β· πœ”π‘šπ‘–π‘›

𝛿𝑑 =

{οΈƒπ›Ώπ‘™π‘œπ‘π‘˜ Β· πœ”π‘šπ‘Žπ‘₯, if π›Ώπ‘™π‘œπ‘π‘˜ > 0

0, if π›Ώπ‘™π‘œπ‘π‘˜ ≀ 0

𝑓1 =

{︃𝐾𝑠 Β· (1 βˆ’ 𝛿𝑑) if |πœ”1| βˆ’ |πœ”2| > 0

𝐾𝑠 Β· (1 + 𝛿𝑑)

𝑓2 =

{οΈƒ(1 βˆ’πΎπ‘ ) Β· (1 + 𝛿𝑑) if |πœ”1| βˆ’ |πœ”2| > 0

(1 βˆ’πΎπ‘ ) Β· (1 βˆ’ 𝛿𝑑)

𝑑1 =𝑓1

𝑓1 + 𝑓2

𝑑2 =𝑓2

𝑓1 + 𝑓2

Torque delivery for 2WD is pretty straightforward. There is one input from β€œmotor” and two outputs to wheels, sowheel torques are:

πœπ‘– = πœπ‘šπ‘œπ‘‘π‘œπ‘Ÿ Β· 𝑑𝑖

7.3. 3. Vehicle models 21

mvsim

where 𝑑𝑖 is the output of Torsen differential for 𝑖-th wheel.

With 4WD, torque is first split with Torsen to front and rear parts, each of them is than split independently with anotherTorsen.

At the moment, there is no model of the engine and thus no feedback of tires torque to engine.

7.4 4. Controllers

Different vehicles have different controllers. At the moment, differential and Ackermann drives have their own con-trollers.

Controllers are divided into several types:

β€’ Raw forces

β€’ Twist

Ackermann has controller, which controls steering angle and speed.

Controllers’ input and output are described by dynamics’ classes that they use.

7.4.1 Differential raw controller

This type of controller has simple response to user’s input integrating wheel torque with each simulation frame.

7.4.2 Differential Twist controller

Differential twist controller uses PID regulator to control linear and angular speed of the robot.

Setpoints for π‘£π‘Ÿ and 𝑣𝑙 are calculated as following:

𝑣𝑙 = 𝜈 βˆ’ πœ”

2Β· 𝑀

π‘£π‘Ÿ = 𝜈 +πœ”

2Β· 𝑀

where 𝜈 is desired linear velocity and πœ” is desired angular velocity.

Inverted formula are suitable to get actual velocities from odometry estimates.

Then, velocity of the wheels is controlled with PID regulator.

7.4.3 Ackermann raw controller

As a raw differential controller, raw Ackermann controller integrates user input and sets wheel torques and steeringwheel angle.

7.4.4 Ackermann twist controller

Ackermann twist controller uses PID regulator to control wheel torques responding to angular and linear velocitycommands. Turn radius and desired steering angle are calculated:

𝑅 =πœˆπ‘ πœ”π‘ 

22 Chapter 7. Physic models

mvsim

𝛼 = π‘Žπ‘‘π‘Žπ‘›(𝑀

π‘Ÿ)

Desired velocities for wheels are computed by rotating desired linear velocity to the steering angle. In the same way,actual velocities from β€œodometry” are computed.

Then, torque of separate wheels is controlled with PID regulators for each wheel.

7.4.5 Ackermann steering controller

Ackermann steering controller takes as input linear speed an steering angle.

Then, it executes Ackermann twist controller to control wheels’ torques.

7.4.6 Ackermann-drivetrain controllers

These controllers’ steering is identical to Ackermann contollers, however, their torque part is different.

These controllers’ output acts like ’engine’ for drivetrain. Instead of separate outputs to wheels, it has one torqueoutput to differentials that will split it to separate wheels.

7.4. 4. Controllers 23

mvsim

24 Chapter 7. Physic models

CHAPTER 8

Extensions

It is possible to extend the simulator with custom models for sensors, vehicles, and world elements.

Note: Write me!

25

mvsim

26 Chapter 8. Extensions

CHAPTER 9

About

Lightweight, realistic dynamical simulator for 2D (β€œ2.5D”) vehicles and robots. It is tailored to analysis of vehicledynamics, wheel-ground contact forces and accurate simulation of typical robot sensors (e.g. laser scanners).

This project includes a C++ library mvsim, a standalone app, and a ROS1 node.

Licensed under the permissive 3-clause BSD License.

Documentation credits:

β€’ Borys Tymchenko @spsancti

β€’ Jose Luis Blanco Claraco @jlblancoc

Github repository: https://github.com/MRPT/mvsim

27

mvsim

28 Chapter 9. About

CHAPTER 10

Indices and tables

β€’ genindex

β€’ modindex

β€’ search

29


Recommended