Commit e52c15fa authored by Tiziano Munaro's avatar Tiziano Munaro
Browse files

[*] Initial commit

parents
# Dumps
core
# IDEs
.vscode/
workspace/
# ROS
build/
devel/
src/CMakeLists.txt
.catkin_workspace
# Inventor
OldVersions/
lockfile.lck
This diff is collapsed.
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
# FF1 Simulation Environment
## Getting Started
Execute the following commands on your local machine/virtual machine: The `setup.bash` installs the required packages in an Ubuntu 18.04 environment.
```
$ sudo bash setup.bash
```
## Build & Launch Simulation
**SCRIPT**
Execute the following commands in the simulation directory. The `start.bash` starts the FF1 simulation in Gazebo (independently of the environment) and allows the user to pass the world as an argument (default = monza_1922) after the `-w` flag. Run `$ ./start.bash -h` for help.
```
$ bash start.bash
```
**MANUAL**
Execute the following commands in the simulation directory to manually build and launch the simulation, independently of the environment (native or docker).
You may need to run `$ source /opt/ros/melodic/setup.bash` first.
```
$ catkin_make
$ source devel/setup.bash
$ roslaunch ff1_gazebo ff1_platoon.launch
```
## Configuration & Advanced Setup
Instructions for configuring the simulation can be found [here](docs/configuration-advanced-setup.md).
## Licenses
The fortissimo Simulation is made available under the GNU Lesser General Public License v3.0. The following terms apply:
```
Copyright 2021 fortiss GmbH
This file is part of the fortissimo Simulation.
The fortissimo Simulation is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The fortissimo Simulation is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the fortissimo Simulation. If not, see <https://www.gnu.org/licenses/>.
```
This software includes work published by third parties. The files in question explicitly state licenses and terms. The satellite image of the Autodromo Nazionale Monza (see `src/ff1_gazebo/models/monza/materials/textures/monza_satellite.png`) is made available under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/?) by Planet Labs, Inc (cf. [source](https://medium.com/planet-stories/a-grand-prix-world-tour-86b08d45ae46)). The binary contained in the Functional Mock-up Unit (FMU) included in the `share/` folder (see `share/System.fmu`) was built using [Modelon's FMI Library](https://github.com/modelon-community/fmi-library), published under the following license:
```
Copyright (C) 2012 Modelon AB
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Modelon AB nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL MODELON AB BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```
# Configuration & Advanced Setup
## Sensors
The rover is defined in the `src\ff1_vehicle\urdf\rover.urdf.xacro` file. There, each of its sensors is specified with a `<xacro:distance_sensor />` tag like so:
```
<xacro:distance_sensor
link_name="distance_sensor"
parent_name="chassis"
mass="0.01" radius="0.01" height="0.025"
xyz="0.4 0 0.1" rpy="0 1.507 3.1415"
h_ray_direction="0" h_ray_angle="160" h_samples="160"
range_min="0.015"
/>
```
By including and/or modifying the `h_ray_angle` and `v_ray_angle` the horizontal and vertical field of view can be adapted.
## Keyboard input
The `ff1_teleop` package handles keyboard input and maps it to specific signals on ROS topics. As of now, two instances of the node are launched, one for each rover.
You can specify a different keyboard mapping for each rover by creating a respective YAML file in the `src/ff1_gazebo/config` folder and passing it as argument to the respective launch file like so:
```
<include file="$(find ff1_gazebo)/launch/ff1_rover.launch">
<arg name="name" value="rover_1" />
<arg name="x" default="0.0" />
<arg name="y" default="0.0" />
<arg name="custom_mapping_file" value="$(find ff1_gazebo)/config/key_mapping_1.yaml" />
</include>
```
If none is specified, then the default mapping (`src/ff1_teleop/config/key_teleop.yaml`) is used.
Key mapping do not have to be complete! A custom key mapping can specify only the inputs which need to be different from the other rovers.
### Default key bindings
- _Up_ [ButtonR2]: Gas
- _Down_ [ButtonL2]: Brake
- _Left_ [LeftStick_X]: Steer left
- _Right_ [LeftStick_X]: Steer right
- _L_ [ButtonStart]: Lake Keeping On/Off
- _A_ [ButtonSelect]: ACC On/Off
- _F_ [ButtonY]: Forward drving mode
- _B_ [ButtonA]: Reversing mode
## Port description
*Note:* Some port ranges are specified as bool or int. While all ROS messages have the type double, sending values outside of the expected value range will lead to undefined behaviour!
### Input ports
#### Controller
- *ButtonA* [bool]: Shifts into backward mode
- *ButtonB* [bool]: Shifts into parking mode
- *ButtonX* [bool]: Changes acceleration mode
- *ButtonY* [bool]: Shifts into forward mode
- *ButtonL1* [bool]: Shifts down
- *ButtonL2* [double: 0,1024]: Acutates the brake
- *ButtonR1* [double: 0,1]: Shifts up
- *ButtonR2* [double: 0,1024]: Acutates the gas pedal
- *LeftStick_X* [double: -32768,32768]: Steering
- *LeftStick_Y* [double: -32768,32768]: Unused
- *RightStick_X* [double: -32768,32768]: Change ACC timegap
- *RightStick_Y* [double: -32768,32768]: Change ACC speed
- *ButtonHome* [bool]: Toggle EB
- *ButtonStart* [bool]: Toggle LK
- *ButtonSelect* [bool]: Toggle ACC
- *DPadLeft* [bool]: Unused
- *DPadRight* [bool]: Unused
- *DPadUp* [bool]: Unused
- *DPadDown* [bool]: Unused
- *Automatic_On* [bool]: Whether to use manual or automatic gearshifting
#### Lane detection
- *LD_present_left* [bool]: Whether a left lane was detected
- *LD_present_right* [bool]: Whether a right lane was detected
- *LD_Distance_Left* [double]: Distance to left lane, centimeter
- *LD_Distance_Right* [double]: Distance to right lane, centimeter
- *LD_Orientation* [double]: Orientation of the vehicle to the lane, currently unused
- *LD_curve_detected* [bool]: Whether a curve was detected
- *LD_curve_radius* [double]: Radius of the curve, only used for feedforward in the PID controller
- *LD_rover_detected* [bool]: Whether the LD detected a rover in front
- *LD_rover_id* [int]: Id of the rover in front
- *LD_rover_distance* [double]: Estimated distance to the rover in front, meter
- *LD_server_connected* [bool]: Whether the LD server is connected
#### Sensors
- *DistanceToFrontUS1* [double]: Distance of first US sensor, centimeters. See US_[Correction, Min, Max] in datadictionary for specific offsets
- *DistanceToFrontUS2* [double]: Distance of second US sensor, centimeters. See US_[Correction, Min, Max] in datadictionary for specific offsets
- *DistanceToFontLaser* [double]: Distance of laser sensor, centimeters. See Laser_[Correction, Max, Max_Invalid, Min, Zero_Min_Value] in datadictionary for specific offsets
- *VelocityIn* [double]: Current actual velocity of the vehicle, m/s
### Output ports
- *SteeringAngle* [double]: Commanded steering angle, radians (clockwise!)
- *SteeringValue* [double: 4200, 7800]: Transformed SteeringAngle, see Steering_Value_[Left, Right, Straight]_[Min, Max] in datadictionary for specific ranges
- *Max_Acceleration* [double]: Current maximum acceleration according to drive mode and driver demand, used in calculation of MotorValue, m/s^2
- *TargetVelocity* [double], Unbounded target velocity, does not take maximum acceleration into acount, m/s
- *MotorValue* [double]: Bounded target velocity, bounds TargetVelocity using current Velocity_In and Max_Acceleration, m/s
- *DistanceToFront* [double]: Calculated distance to the front obstacle/vehicle, meter
- *VelocityFrontVehicle* [double]: Calculated velocity of the front obstacle/vehicle, currently always 0 because sensor values were too unstable, m/s
- *ACC_TargetDistance* [double]: Current target distance of ACC, meter
- *ACC_TimeGap* [double]: Current target timegap of ACC, seconds
- *ACC_MaxVelocity* [double]: Current target velocity of ACC, m/s
- *EB_On* [bool]: Whether the EB is enabled
- *Critical* [bool]: Whether the EB thinks it's about to crash into something
#!/bin/bash
# Copyright 2021 fortiss GmbH
#
# This file is part of the fortissimo Simulation.
#
# The fortissimo Simulation is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The fortissimo Simulation is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the fortissimo Simulation. If not, see <https://www.gnu.org/licenses/>.
# --------------------- PREREQUISITES ---------------------
# Ensure super user privileges
if [ $(id -u) -ne 0 ]; then
echo "[EXIT] Run this script with root privileges!"
exit
fi
# Check operating system
if [[ ! $(lsb_release -rs) =~ ^(18)\.[0-9]{2} ]]; then
echo "[EXIT] Check the README file for supported operating systems!"
exit
fi
# Start package installation
apt-get update
apt-get install -y gnupg2
# --------------------- ROS -------------------------------
# Setup system to accept software from packages.ros.org
apt-get install -y lsb-release
apt-get clean all
sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
# Set up keys
apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
# Install ROS Melodic
apt-get update
apt-get install -y ros-melodic-desktop-full
# Environment setup
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
# Dependencies for building packages
apt-get install -y \
python-rosdep \
python-rosinstall \
python-rosinstall-generator \
python-wstool \
build-essential
rosdep init
rosdep update
rosdep fix-permissions
# --------------------- GAZEBO & MORE ---------------------
apt-get update
apt-get install --no-install-recommends -y apt-utils
apt-get install --no-install-recommends -y python-pip
pip install wheel
# Install Gazebo
python -m pip install -U pynput
apt-get update
apt-get install --no-install-recommends -y \
python-catkin-tools \
ros-melodic-robot \
ros-melodic-gazebo-* \
ros-melodic-rqt* \
ros-melodic-teleop-twist-joy \
ros-melodic-joy-* \
ros-melodic-effort-controllers \
ros-melodic-joint-state-controller \
ros-melodic-position-controllers \
ros-melodic-fmi-adapter \
ros-melodic-ackermann-msgs
apt-get clean
rm -rf /var/lib/apt/lists/*
# --------------------- DONE ------------------------------
echo "[DONE] Start the simulation by executing the start script."
This diff is collapsed.
# Copyright 2021 fortiss GmbH
#
# This file is part of the fortissimo Simulation.
#
# The fortissimo Simulation is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The fortissimo Simulation is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the fortissimo Simulation. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8.3)
project(ff1_control)
catkin_package()
include_directories(
include ${catkin_INCLUDE_DIRS}
)
# ackermann_controller.yaml
#
# This file defines ackermann_controller parameter values used for simulating a
# Traxxas(R) E-Maxx(R) #3905 RC (Radio Controlled) truck.
#
# Traxxas(R) and E-Maxx(R) are registered trademarks of Traxxas Management,
# LLC. ackermann_controller.yaml was independently created by
# Wunderkammer Laboratory, and neither ackermann_controller.yaml nor
# Wunderkammer Laboratory is affiliated with, sponsored by, approved by,
# or endorsed by Traxxas Management, LLC. All other trademarks and service
# marks are the property of their respective owners.
#
# Copyright (c) 2013 Wunderkammer Laboratory
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
left_front_wheel:
steering_link_name: left_front_wheel
steering_controller_name: left_steering_ctrlr
axle_controller_name: left_front_axle_ctrlr
diameter: 0.14605
right_front_wheel:
steering_link_name: right_front_wheel
steering_controller_name: right_steering_ctrlr
axle_controller_name: right_front_axle_ctrlr
diameter: 0.14605
left_rear_wheel:
link_name: left_rear_wheel
axle_controller_name: left_rear_axle_ctrlr
diameter: 0.14605
right_rear_wheel:
link_name: right_rear_wheel
axle_controller_name: right_rear_axle_ctrlr
diameter: 0.14605
# The equilibrium position of each shock absorber is wheel_travel / 2.
# wheel_travel, defined in rover.urdf.xacro, is 0.084 meters.
shock_absorbers:
- controller_name: left_front_shock_ctrlr
equilibrium_position: 0.042
- controller_name: right_front_shock_ctrlr
equilibrium_position: 0.042
- controller_name: left_rear_shock_ctrlr
equilibrium_position: 0.042
- controller_name: right_rear_shock_ctrlr
equilibrium_position: 0.042
# joint_controller.yaml
#
# This file defines joint controller parameter values used for simulating a
# Traxxas(R) E-Maxx(R) #3905 RC (Radio Controlled) truck.
#
# Traxxas(R) and E-Maxx(R) are registered trademarks of Traxxas Management,
# LLC. joint_controller.yaml was independently created by
# Wunderkammer Laboratory, and neither joint_controller.yaml nor
# Wunderkammer Laboratory is affiliated with, sponsored by, approved by, or
# endorsed by Traxxas Management, LLC. All other trademarks and service marks
# are the property of their respective owners.
#
# Copyright (c) 2013-2014 Wunderkammer Laboratory
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Publish the joint states to joint_states.
joint_state_ctrlr:
type: joint_state_controller/JointStateController
publish_rate: 30
# Steering Effort Controllers
left_steering_ctrlr:
joint: left_steering_joint
type: effort_controllers/JointPositionController
pid: {p: 4.0, i: 0.0, d: 1.0}
right_steering_ctrlr:
joint: right_steering_joint
type: effort_controllers/JointPositionController
pid: {p: 4.0, i: 0.0, d: 1.0}
# Velocity Effort Controllers
left_front_axle_ctrlr:
joint: left_front_axle
type: effort_controllers/JointVelocityController
pid: {p: 0.2, i: 0.0, d: 0.0, i_clamp: 10.0}
right_front_axle_ctrlr:
joint: right_front_axle
type: effort_controllers/JointVelocityController
pid: {p: 0.2, i: 0.0, d: 0.0, i_clamp: 10.0}
left_rear_axle_ctrlr:
joint: left_rear_axle
type: effort_controllers/JointVelocityController
pid: {p: 0.2, i: 0.0, d: 0.0, i_clamp: 10.0}
right_rear_axle_ctrlr:
joint: right_rear_axle
type: effort_controllers/JointVelocityController
pid: {p: 0.2, i: 0.0, d: 0.0, i_clamp: 10.0}
# The proportional gain of each shock absorber controller is
# 2 * (shock_stroke * shock_spring_constant / wheel_travel). shock_stroke is
# 0.028575 m. shock_spring_constant, an approximation of a Traxxas Ultra Shock
# shock absorber spring's constant, is 437.817 N/m. wheel_travel, defined in
# rover.urdf.xacro, is 0.084 m.
#
# The derivative gain of each shock absorber controller is 2 * shock_damping.
# shock_damping, an approximation of the viscous damping coefficient of an
# Ultra Shock shock absorber, is 36.2416 Ns/m
# (i.e. sqrt(3 * shock_spring_constant)).