Simulation Assignment-1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Institute of Informatics

Aeronautical Informatics

Contact Person:
apl. Prof. Dr.-Ing. habil. Umut Durak

Phone: +49-53 23-72-71 29


umut.durak@tu-clausthal.de

WiSe 21/22
Announced: 12.11.2021
Deadline: 26.11.2021

W1269 Simulation Engineering

Assignment 1

Motion in space of physical objects can be represented with six degrees of


freedom. Three of these represent position in three-dimensional space,and
three represent orientation in space. We assume three axes, x, y, and z, where
by convention x is drawn increasing to the right, y is drawn increasing Visitors Address:
upwards, and z is drawn increasing out of the page. Roll θx is an angle of
rotation around the x axis, where by convention an angle of 0 radians Building D5
Albrecht-von-Groddeck-Str. 7
represents horizontally flat along the z axis (i.e., the angle is given relative to Room 202a
the z axis). Yaw θy is the rotation around the y axis, where D-38678 Clausthal-Zellerfeld

by convention 0 radians represents pointing directly to the right (i.e., the


angle is given relative to the x axis). Pitch θz is rotation around the z axis,
where by convention 0 radians represents pointing horizontally (i.e., the angle
is given relative to the x axis). The position of an object in space, therefore, is
represented by six functions of the form 𝑓: ℝ → ℝ, where the domain
represents time and the codomain represents either distance along an axis or
angle relative to an axis.

Changes in position or orientation are governed by Newton’s second law,


relating force with acceleration. Acceleration is the second derivative of
position. Our first equation handles the position information,
Seite 2

𝐅(𝑡) = 𝑀𝑥(𝑡) ̈
where F is the force vector in three directions, M is the mass of the object,
and 𝑥̈ is the second derivative of x with respect to time (i.e., the acceleration).

The versions of these equations of motion that affect orientation use torque,
the rotational version of force. It is again a three-element vector as a function
of time, representing the net rotational force on an object.
𝐓(𝑡) = 𝐼𝜃(𝑡) ̈
where T is the torque vector in three axes and I is the moment of inertia of
the object.

Using these equations, if you know the initial orientation and initial rotational
velocity of an object and the torques on the object in all three axes as a
function of time, you can determine the rotational acceleration, velocity, and
orientation of the object at any time. Often, we can simplify these equations
by reducing the number of dimensions that are considered. In general, such a
simplification is called a model-order reduction.

Consider a simple control problem that admits such reduction of


dimensionality. A helicopter has two rotors, one above, which provides lift,
and one on the tail. Without the rotor on the tail, the body of the helicopter
would spin. The rotor on the tail counteracts that spin. Specifically, the force
produced by the tail rotor must counter the torque produced by the main
rotor. Here we consider this role of the tail rotor independently from all other
motion of the helicopter. A simplified model of the helicopter is shown
above. Here, we assume that the helicopter position is fixed at the origin, so
there is no need to consider equations describing position. Moreover, we
assume that the helicopter remains vertical, so pitch and roll are fixed at zero.
These assumptions are not as unrealistic as they may seem since we can
define the coordinate system to be fixed to the helicopter. With these
assumptions, the moment of inertia reduces to a scalar that represents a
torque that resists changes in yaw. The changes in yaw will be due to
Newton’s third law, the action-reaction law, which states that every
action has an equal and opposite reaction. This will tend to cause the
helicopter to rotate in the opposite direction from the rotor rotation. The tail
rotor has the job of countering that torque to keep the body of the helicopter
from spinning. We model the simplified helicopter by a system that takes as
Seite 3

input a continuous time signal Ty, the torque around the y axis (which causes
changes in yaw). This torque is the sum of the torque caused by the main
rotor and that caused by the tail rotor. When these are perfectly balanced, that
sum is zero. The output of our system will be the angular velocity 𝜃̈ and yaw
𝜃 around the y axis.

The dimensionally reduced version can be written as:

𝜃̈𝑦 = 𝑇𝑦 (𝑡)/𝐼𝑦𝑦

Please write a simulation in C++ using the above formula to calculate the yaw
of a helicopter for 10 seconds with the following input, parameter and initial
state specification.

𝐼𝑦𝑦 = 3800 𝑘𝑔𝑚2 , the moment of intertie of the helicopter in y axis


𝜃̇ (0) = 0 𝑟𝑎𝑑/𝑠, the initial yaw rate of the helicopter
𝜃(0) = 0 rad, the initial yaw of the helicopter
𝑇𝑦 (𝑡) = 0.3𝑡 𝑘𝑔𝑚2 /𝑠 2 , the torque applied to helicopter.

Your simulation shall have a 10ms step size.


Your simulation shall implement Euler integration.
Your simulation shall log every second (in simulation time) time and yaw to
console.

Please provide your source files, a make file with a build and run target, and a
Markdown document or an attached PDF.

1. The Code and its associated makefile should be well documented. Please
ensure that the code runs with the right output.
2. A design document supporting your code. It should explain the rationale
behind your work and should make the code easier to understand for us.
You may use diagrams to supplement your code in this document. It
should also contain the output of your program.
3. Please add the files to git repo and send only the link to your repo to
ahmad.naja@tu-clausthal.de with the subject Simulation Engineering
Assignment 1 along with your name and enrollment number.

(CC BY-NC-ND 4.0)


The figures and parts of the text are from E.A.Lee and S. A. Seshia, Introduction to Embedded Systems - A Cyber-Physical Systems
Approach, Second Edition, MIT Press, 2017.
Institute of Informatics
Aeronautical Informatics

Contact Person:
apl. Prof. Dr.-Ing. habil. Umut Durak

Phone: +49-53 23-72-71 29


umut.durak@tu-clausthal.de

WiSe 21/22
Announced: 26.11.2021
Deadline: 10.12.2021

W1269 Simulation Engineering

Assignment 2

An extended state machine describing a traffic light at a pedestrian crosswalk


is shown above. This is a time triggered machine that assumes it will react
once per second. It starts in the red state and counts 60 seconds with the help
of the variable count. It then transitions to green, where it will remain until
the pure input pedestrian is present. That input could be generated, for Visitors Address:
example, by a pedestrian pushing a button to request a walk light. When Building D5
pedestrian is present, the machine transitions to yellow if it has been in state Albrecht-von-Groddeck-Str. 7
green for at least 60 seconds. Otherwise, it transitions to pending, where it Room 202a
D-38678 Clausthal-Zellerfeld
stays for the remainder of the 60 second interval. This ensures that once the
light goes green, it stays green for at least 60 seconds. At the end of 60
seconds, it will transition to yellow, where it will remain for 5 seconds before
transitioning back to red.

The outputs produced by this machine are sigG to turn on the green light,
sigY to change the light to yellow, and sigR to change the light to red.

Please write a simulation in Python using the above formula to simulate the
traffic light for 200 seconds with a scenario where a pedestrian is present at
70. second.

.
Seite 2

Your simulation shall have a one second step size.


Your simulation shall log every second (in simulation time) time, inputs.
system state and the outputs to console.

Please follow the following steps. The git repo should contain your code and
an associated file (markdown or PDF).

1. The Code should be well documented. Please ensure that the code runs
with the right output.
2. A design document supporting your code. It should explain the rationale
behind your work and should make the code easier to understand for us.
You may use diagrams to supplement your code in this document. It
should also contain the output of your program.
3. Please add the files to git repo and send only the link to your repo to
ahmad.naja@tu-clausthal.de with the subject Simulation Engineering
Assignment 2 along with your name and enrollment number.
Seite 3

(CC BY-NC-ND 4.0)


The figures and parts of the text are from E.A.Lee and S. A. Seshia, Introduction to Embedded Systems - A Cyber-Physical Systems
Approach, Second Edition, MIT Press, 2017.
Institute of Informatics
Aeronautical Informatics

Contact Person:
apl. Prof. Dr.-Ing. habil. Umut Durak

Phone: +49-53 23-72-71 29


umut.durak@tu-clausthal.de

WiSe 21/22
Announced: 17.12.2021
Deadline: 21.01.2022

W1269 Simulation Engineering

Assignment 3

Consider the above figure depicting a system comprising two tanks containing
water. Each tank is leaking at a constant rate. Water is added at a constant rate
to the system through a hose, which at any point in time is filling either one
tank or the other. It is assumed that the hose can switch between the tanks
instantaneously. For 𝑖 ∈ {1,2}, let 𝑥𝑖 denote the volume of water in Tank i and
Visitors Address:
𝑣𝑖 > 0 denote the constant flow of water out of Tank i. Let w denote the
constant flow of water into the system. The objective is to keep the water Building D5
volumes above 𝑟1 and 𝑟2 , respectively, assuming that the water volumes are Albrecht-von-Groddeck-Str. 7
Room 202a
above 𝑟1 and 𝑟2 initially. This is to be achieved by a controller that switches the D-38678 Clausthal-Zellerfeld
inflow to Tank 1 whenever 𝑥1 (𝑡) ≤ 𝑟1 (𝑡) and to Tank 2 whenever 𝑥2 (𝑡) ≤
𝑟2 (𝑡)
Seite 2

The hybrid automaton representing this two-tank system is given below


figure

Construct a model of this hybrid automaton in Ptolemy II . Use the following


parameter values: 𝑟1 = 𝑟2 = 0, 𝑣1 = 𝑣2 = 0.5, and 𝑤 = 0.75. Set the
initial state to be (𝑞1 ; (0; 1)). (That is, initial value 𝑥1 is 0 and 𝑥2 is 1.)
Simulate your model for 100 seconds and plot how 𝑥1 and 𝑥2 vary as a function
of time t.

Please provide your model files, your Plot, and a PDF document with
additional explanation (including output graph) in a zip file. Please send the
zip file to ahmad.naja@tu-clausthal.de.

Hint: Please read the following document for help (especially chapter 6)
https://ptolemy.berkeley.edu/books/Systems/PtolemyII_DigitalV1_02.pdf

This assignment uses a tool called Plotemy II. You can install it using the link
https://ptolemy.berkeley.edu/ptolemyII/tutorial.htm.
Seite 3

(CC BY-NC-ND 4.0)


The figures and parts of the text are from E.A.Lee and S. A. Seshia, Introduction to Embedded Systems - A Cyber-Physical Systems
Approach, Second Edition, MIT Press, 2017.
Institute of Informatics
Aeronautical Informatics

Contact Person:
apl. Prof. Dr.-Ing. habil. Umut Durak

Phone: +49-53 23-72-71 29


umut.durak@tu-clausthal.de

WiSe 21/22
Announced: 04.02.2022
Deadline: 18.02.2022

W1269 Simulation Engineering

Assignment 4

For this assignment, we will work with Ubuntu 18.04 and ROS Melodic Morenia. We
highly recommend you use a virtual machine and the provided image that already
contains a preinstalled environment. If you wish to install it manually, please install
ROS Melodic with Gazebo 9.
http://wiki.ros.org/melodic/Installation/Ubuntu (Please use Full Desktop Install)
http://gazebosim.org/tutorials?tut=install_ubuntu&ver=9.0&cat=install

To run the provided image, you need the VMware Workstation free player(windows)
or VMware fusion (Mac). Please follow the given instructions to download and install
the software from VMware. We recommend you have at least 20GB of available disk
space on your computer to run the virtual machine.
Download the zipped folder “Ubuntu_18_04_ROS_Course.zip” using the link
below
( https://polybox.ethz.ch/index.php/s/iSwkLBhRJNKuv8a) (~ 5.6 GB) from polybox
and extract it.
Start Up Virtual Machine
● Open VMware Workstation
● Open file Ubuntu_18_04_ROS_Course.vmx in the downloaded folder

Start the virtual machine with “Power on this virtual machine” or “Start up this guest
operating system”. Important! If it is the first time you are using an virtual machine Visitors Address:
on your laptop, there might be an error message that tells you that “This host
Building D5
supports Intel VT-x, but Intel VT-x is disabled”. The Intel Virtual Technology Albrecht-von-Groddeck-Str. 7
(Intel VT) has to be enabled in your BIOS (or UEFI). You will have to restart the Room 202a
D-38678 Clausthal-Zellerfeld
computer and press either Enter, F1, F10, or DEL to go to BIOS settings (depending
on your PC manufacturer). Under Security -> System Security you will find the
option to enable VT. Some more explanations can be found here.
To login under Ubuntu use the provided account ROS Course:
Password: student

Please run the following commands. The workspace is already setup for you. The
default keyboard is German. You can change it to English using the top right
section of the desktop. Before proceeding further make sure you understand the
concepts from the “Intro to Gazebo” session.
Seite 2

Task1:
• Build a simple vehicle model Using Gazebo Model Editor. The vehicle
should have Chassis, Wheels, joints between each wheel and the chassis.
• Add a depth camera sensor to the car to detect objects in front of the car (It
is already installed, just add it from the model database).
• Add "libFollowerPlugin.so" plugin to enhance the model with some
autonomy.
• Insert a box in front of the vehicle, then run the Model. The vehicle is
expected to move slowly towards the box.

Links to use:
http://gazebosim.org/tutorials?cat=guided_b&tut=guided_b3
Task2:
• Creating an SDF model of an HDL-32 sensor. The sensor has:
o a base cylinder and top cylinder, where the top cylinder spins, and
o a set of laser rays oriented in the vertical fan. Just follow the link to
create this sensor:
http://gazebosim.org/tutorials?cat=guided_i&tut=guided_i1
• Use the created car in task1 with your HDL-32 sensor. Make a simple
scenario like illustrated in the image below (the car moves through the rays).
Run the model and visualize the sensors data (camera and HDL-32) using
Gazebo's topic visualizer.

Links to use:
http://gazebosim.org/tutorials?cat=guided_i&tut=guided_i3

Instructions for submission:

1. Please submit the model files and three screenshots from different angles
2. Please add the files to git repo and send only the link to your repo to
ahmad.naja@tu-clausthal.de with the subject Simulation Engineering
Assignment 4 along with your name and enrollment number.

You might also like