The cache-enabled local_setup.bash is attached as [ new_local_setup.bash.txt
](https://github.com/ros2/ros2/files/3486293/new_local_setup.bash.txt) and can
directly replace /opt/ros2_$ROS_DISTRO/install/local_setup.bash or that of any
workspace.
Original to patch would be [ https://github.com/colcon/colcon-
bash/blob/master/colcon_bash/shell/template/prefix.bash.em
](https://github.com/colcon/colcon-
bash/blob/master/colcon_bash/shell/template/prefix.bash.em) , but because of
the caveat, I am hestiant to create a pull request.

---

All reactions


All changes have landed for Eloquent.

---

🎉  2  paulbovbel and luator reacted with hooray emoji


* Set locale


**[ hdino ](/hdino) ** commented  Aug 20, 2019


These instructions are for ROS Groovy and later. For ROS Fuerte and earlier,
select rosbuild.


####  ROS 2 Documentation


[ what is the use of --symlink-install in ROS2 colcon build?
](/question/371822/what-is-the-use-of-symlink-install-in-ros2-colcon-build/)


To confirm that your package path has been set, echo the ROS_PACKAGE_PATH
variable.


[ how to debug a ros2 python launch file ](/question/412294/how-to-debug-a-
ros2-python-launch-file/)


I noticed the same behavior. I thought it was just my personal computer but
apparently it is prevalent on all of my other systems as well.

---

All reactions


Sorry, something went wrong.


####  Actual behavior


$ catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3


[
![@hdino](https://avatars.githubusercontent.com/u/7059909?s=80&u=3298ba8a6b0e9797edc44c49055ba37e7fcc123b&v=4)
](/hdino)


The machine I mentioned above takes about twice as long.

---

All reactions


> > adding an ampersand at the end of this line ...
>
> What you are suggesting isn't going to work. While the invocation is faster
> it simply doesn't set the environment variable it is supposed to. You can't
> source scripts in the background since the current shell needs to wait for
> the script in order to update the environment variables.


**[ Karsten1987 ](/Karsten1987) ** commented  Aug 20, 2019  •


Could this solved by replacing /opt/ros_$ROS_DISTRO/install/setup.bash with a
file that effectively stores the changes to the environment settings like [
@christianrauch ](https://github.com/christianrauch) posted above? A script to
update setup.bash would be required and run e.g. from the postprocessing
script in ros2 Debian packages. So unless something new is installed from .deb
packages in "/opt/ros_...", setup.bash would be static and instantaneously
executable.

---

All reactions


All reactions


      * Package-level
      * Workspace-level
    * Different shells
      * Primary shells
      * Non-primary / additional shells
    * Avoid duplicate entries
      * .dsv files
    * Implementation
    * Tracing
  * [ Program flow ](program-flow.html)
  * [ Extension points ](extension-point.html)
  * [ Contributions ](contribution.html)
  * [ Make Releases ](release.html)
  * [ Changelog ](changelog.html)

Migrate from other build tools

  * [ ament_tools ](../migration/ament_tools.html)
  * [ catkin_make_isolated ](../migration/catkin_make_isolated.html)
  * [ catkin_tools ](../migration/catkin_tools.html)

__ [ colcon ](../index.html)

  * [ Docs ](../index.html) »
  * Environment setup
  * [ Edit on GitHub ](https://github.com/colcon/colcon.readthedocs.org/blob/released/developer/environment.rst)

* * *

#  Environment setup  Â¶

Using a package after it has been built or building a package on top of its
dependencies might require updating environment variables. For the former, the
best option for the user is to have a script perform the environment update
for ease of use. In the latter case, automating the process is necessary to
build packages in topological order without user interaction. E.g. if a
package installs an executable which should be invocable by name, the
directory containing the executable needs to be part of the ` PATH  `
environment variable.


Environment setup files are generated for you, but can come from different
places:


##  Install dependencies using rosdep  ï


[*] Realized this phrase means nothing. I write it, nonetheless!

---

👍  3  yeshasvitirupachuri, paulbovbel, and thraen reacted with thumbs up emoji


Copy link


To make sure your workspace is properly overlayed by the setup script, make
sure ` ROS_PACKAGE_PATH ` environment variable includes the directory you're
in.


[ ![@wjwwood](https://avatars.githubusercontent.com/u/100427?s=80&v=4)
](/wjwwood)


Author


**Python 3 users in ROS Melodic and earlier** : note, if you are building ROS
from source to achieve Python 3 compatibility, and have setup your system
appropriately (ie: have the Python 3 versions of all the required ROS Python
packages installed, such as ` catkin ` ) the first [ catkin_make
](/catkin/commands/catkin_make) command in a clean [ catkin workspace
](/catkin/workspaces) must be:


#  Primary shells  Â¶

All environment changes necessary to use a package should be expressed in
script with the extension of a primary shell. Primary shell extensions are:

  * ` .sh  ` : plain shell
  * ` .bat  ` : Windows cmd
  * ` .ps1  ` : PowerShell


Sorry, something went wrong.


##  Create a ROS Workspace


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=40&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas) [ dirk-thomas ](/dirk-thomas) removed the [ help wanted
](/ros2/ros2/labels/help%20wanted) Extra attention is needed  label  Sep 13,
2018


Member


##  Alternate compilers  ï


Milestone


$ printenv | grep ROS


I've implemented the caching of environment and found that the bash completion
needs to be sourced separately, otherwise the approach works. It works by
introducing the caching in local_setup.bash.


Are you sourcing the ` local_setup ` file or ` setup ` ?

---

All reactions


###  Source the setup script  ï


Just to weigh in, this is the first things that struck me negatively when
starting to tinker with ros2.


Built with [ Sphinx ](https://www.sphinx-doc.org/) using a [ theme
](https://github.com/readthedocs/sphinx_rtd_theme) provided by [ Read the Docs
](https://readthedocs.org) .


edited


###  Set locale  ï


    sudo apt update && sudo apt install -y \
      build-essential \
      cmake \
      git \
      python3-colcon-common-extensions \
      python3-pip \
      python-rosdep \
      python3-vcstool \
      wget
    # install some pip packages needed for testing
    python3 -m pip install -U \
      argcomplete \
      flake8 \
      flake8-blind-except \
      flake8-builtins \
      flake8-class-newline \
      flake8-comprehensions \
      flake8-deprecated \
      flake8-docstrings \
      flake8-import-order \
      flake8-quotes \
      pytest-repeat \
      pytest-rerunfailures \
      pytest \
      pytest-cov \
      pytest-runner \
      setuptools
    # install Fast-RTPS dependencies
    sudo apt install --no-install-recommends -y \
      libasio-dev \
      libtinyxml2-dev
    # install Cyclone DDS dependencies
    sudo apt install --no-install-recommends -y \
      libcunit1-dev


Every time the entries in the workspace change, it is necessary to re-source `
~/fuerte_workspace/setup.bash ` to make sure that the updated `
ROS_PACKAGE_PATH ` is used.


[ Sign up
](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-
name%3E%2F%3Crepo-
name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-
repo&source_repo=ros2%2Fros2)


* Environment setup


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=80&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas)


#  Wiki


* Install development tools and ROS tools


     [ Iron (latest) ](../../iron/index.html)
     [ Humble ](../../humble/index.html)
     [ Galactic (EOL) ](../../galactic/index.html)
     [ Foxy (EOL) ](../../foxy/index.html)
     [ Eloquent (EOL) ](Linux-Development-Setup.html)
     [ Dashing (EOL) ](../../dashing/index.html)
     [ Crystal (EOL) ](../../crystal/Installation/Linux-Development-Setup.html)


    sudo apt install clang
    export CC=clang
    export CXX=clang++
    colcon build --cmake-force-configure


##  Footer


In ROS2 sourcing the default workspace takes a considerable amount of time
(more than 2 seconds on my PC). Sourcing the default workspace by default in
the ` .bashrc ` is therefore not an option. On less powerfull devices like the
Raspberry Pi, sourcing takes even longer (more than 10 seconds).

---

The text was updated successfully, but these errors were encountered:


{{ message }}


Sorry, something went wrong.


Closed


[ ![](/custom/images/brought_by_horiz.png) ](https://www.openrobotics.org/)


If you are ever having problems finding or using your ROS packages make sure
that you have your environment properly setup. A good way to check is to
ensure that [ environment variables ](/ROS/EnvironmentVariables) like [
ROS_ROOT ](/ROS/EnvironmentVariables#ROS_ROOT) and [ ROS_PACKAGE_PATH
](/ROS/EnvironmentVariables#ROS_PACKAGE_PATH) are set:


  * [ Terms ](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
  * [ Privacy ](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
  * [ Security ](/security)
  * [ Status ](https://www.githubstatus.com/)
  * [ Docs ](https://docs.github.com/)
  * [ Contact ](https://support.github.com?tags=dotcom-footer)
  * Manage cookies
  * Do not share my personal information


© Copyright 2024, Open Robotics.


**[ christianrauch ](/christianrauch) ** commented  Jul 20, 2019


I suspect that both ROS 1 and ROS 2 are being sourced because of the [
ros1_bridge ](https://github.com/ros2/ros1_bridge) .


[ @Levi-Armstrong ](https://github.com/Levi-Armstrong) Sourcing the workspace
generally does things like setup PYTHONPATH, LD_LIBRARY_PATH, and things of
that nature. So you definitely need to do it when introducing new packages so
it can set up the environment for the new package. If you are just iterating
on a package by changing the source code, adding/removing libraries, and
things of that nature, sourcing the workspace once when you start working is
generally sufficient[1]. I'd say that you generally don't need to continually
source the workspace.


You will need to run this command on every new shell you open to have access
to the ROS commands, unless you add this line to your .bashrc. This process
allows you to install several ROS distributions (e.g. indigo and kinetic) on
the same computer and switch between them.


Skip to content


**You're reading the documentation for a version of ROS 2 that has reached its
EOL (end-of-life), and is no longer officially supported. If you want up-to-
date information, please have a look at[ Iron ](../../iron/index.html) . **


In both cases, they seem to source the source file of every package
individually, e.g.:


**[ dirk-thomas ](/dirk-thomas) ** commented  Aug 20, 2019  •


Copy link


[ benchmark.sh.txt
](https://github.com/ros2/ros2/files/4587553/benchmark.sh.txt) (GitHub doesn't
allow .sh)
[ profiling.log ](https://github.com/ros2/ros2/files/4587526/profiling.log)


Basically someone needs to take a look at the profiling that [ @hdino
](https://github.com/hdino) kindly did in [ #573 (comment)
](https://github.com/ros2/ros2/issues/573#issuecomment-624699716) (or redo it
themselves), and spend some time looking at ways to reduce the time spent in
those functions. Do feel free to open another issue to track the fact that it
is too slow for your use case, but please provide as much information as
possible

---

👍  3  fujitatomoya, richichiare, and EricCousineau-TRI reacted with thumbs up
emoji


[
![@Karsten1987](https://avatars.githubusercontent.com/u/5419873?s=80&u=5f8ea920f6368629c049511435297ffd550d15ea&v=4)
](/Karsten1987)


##  Comments


#  Package-level  Â¶

Note

Each package installs its files under its install prefix. This corresponds to
` install/<package_name> ` except when ` colcon  build  --merge-install  ` is
used. In that case, the install prefix is ` install/  ` .

For each built package ` colcon  ` generates a set of package-level scripts
(one for each supported shell type): ` share/<package_name>/package.<ext> ` .
These script files update the environment with information specific to this
package.

` colcon  ` supports multiple different approaches to update environment
variables:

  * A heuristic checking the installed files for known file types or known destinations. A few of the supported heuristics:
    * An executable under ` bin  ` adds that directory to the ` PATH  `
    * An existing Python library directory adds that directory to the ` PYTHONPATH  `
    * A file ending in ` -config.cmake  ` or ` Config.cmake  ` adds the directory to the ` CMAKE_PREFIX_PATH  ` (provided by ` colcon-cmake  ` )
    * A file starting with ` Find  ` and ending in ` .cmake  ` adds the directory to the ` CMAKE_MODULE_PATH  ` (provided by ` colcon-cmake  ` )
    * A shared library adds the directory to one of the following environment variables (depending on the platform): ` LD_LIBRARY_PATH  ` , ` DYLD_LIBRARY_PATH  ` , ` PATH  ` (provided by ` colcon-library-path  ` )
    * A file ending in ` .pc  ` in a directory ` lib/pkgconfig  ` adds the directory to the ` PKG_CONFIG_PATH  ` (provided by ` colcon-pkg-config  ` )
  * Specific package types providing their own scripts to setup the package specific environment. E.g. ` ament_cmake  ` packages (supported by ` colcon-ros  ` ) provide a file named ` share/<package_name>/local_setup.<ext> ` .


[ ALL ](/questions/scope:all/sort:activity-desc/page:1/) [ UNANSWERED
](/questions/scope:unanswered/sort:answers-asc/page:1/)


[
![@hdino](https://avatars.githubusercontent.com/u/7059909?s=80&u=3298ba8a6b0e9797edc44c49055ba37e7fcc123b&v=4)
](/hdino)


In another terminal source the setup file and then run a Python ` listener  `
:


    mkdir -p ~/new_ros2_ws/src
    cd ~/new_ros2_ws
    colcon build


Sorry, something went wrong.


Usage is (e.g. in .bashrc):


TODO: using ThreadSanitizer, MemorySanitizer


**[ Seanmatthews ](/Seanmatthews) ** commented  Jan 8, 2019


Pick a username


` _colcon_prefix_bash_source_script
"$COLCON_CURRENT_PREFIX/share/${_colcon_package_name}/package.bash" `

---

👍  2  LouisChen1905 and Naveen1812Rawat reacted with thumbs up emoji  👎  6
dirk-thomas, richichiare, abylikhsanov, karl-schulz, Naveen1812Rawat, and
rty813 reacted with thumbs down emoji


    * [ About ROS 2 interfaces ](../Concepts/About-ROS-Interfaces.html)
    * [ About ROS 2 client libraries ](../Concepts/ROS-2-Client-Libraries.html)
    * [ About logging and logger configuration ](../Concepts/Logging.html)
    * [ About parameters in ROS 2 ](../Concepts/About-ROS-2-Parameters.html)
  * [ Troubleshooting ](../Troubleshooting.html)
    * [ Installation troubleshooting ](../Troubleshooting/Installation-Troubleshooting.html)
    * [ DDS tuning information ](../Troubleshooting/DDS-tuning.html)
  * [ Contributing ](../Contributing.html)
    * [ ROS 2 on-boarding guide ](../Contributing/ROS-2-On-boarding-Guide.html)
    * [ ROS 2 developer guide ](../Contributing/Developer-Guide.html)
    * [ Code style and language versions ](../Contributing/Code-Style-Language-Versions.html)
    * [ Design guide: common patterns in ROS 2 ](../Contributing/Design-Guide.html)
    * [ Quality guide: ensuring code quality ](../Contributing/Quality-Guide.html)
    * [ Build cop and build farmer guide ](../Contributing/Build-Cop-and-Build-Farmer-Guide.html)
      * [ How to setup the Jenkins master ](../Contributing/CI-Server-Setup.html)
      * [ How to setup Linux Jenkins nodes ](../Contributing/Set-up-a-new-Linux-CI-node.html)
      * [ How to setup a macOS Jenkins node ](../Contributing/Set-up-a-new-macOS-CI-node.html)
      * [ How to setup a Windows Jenkins node ](../Contributing/Set-up-a-new-Windows-CI-node.html)
    * [ Migration guide from ROS 1 ](../Contributing/Migration-Guide.html)
      * [ Python migration guide from ROS 1 ](../Contributing/Migration-Guide-Python.html)
    * [ Examples and tools for ROS1-to-ROS2 migration ](../Contributing/Examples-and-Tools-for-ROS1----ROS2-Migrations.html)
    * [ Using Sphinx for cross-referencing packages ](../Contributing/Inter-Sphinx-Support.html)
  * [ Contact ](../Contact.html)
  * [ ROSCon Content ](../ROSCon-Content.html)
  * [ Distributions ](../Releases.html)
    * [ ROS 2 alpha releases (Aug 2015 - Oct 2016) ](../Releases/Alpha-Overview.html)
    * [ Beta 1 (codename âAsphaltâ; December 2016) ](../Releases/Beta1-Overview.html)
    * [ Beta 2 (codename âr2b2â; July 2017) ](../Releases/Beta2-Overview.html)
    * [ Beta 3 (codename âr2b3â; September 2017) ](../Releases/Beta3-Overview.html)
    * [ ROS 2 Ardent Apalone (codename âardentâ; December 2017) ](../Releases/Release-Ardent-Apalone.html)
    * [ ROS 2 Bouncy Bolson (codename âbouncyâ; June 2018) ](../Releases/Release-Bouncy-Bolson.html)
    * [ ROS 2 Crystal Clemmys (codename âcrystalâ; December 2018) ](../Releases/Release-Crystal-Clemmys.html)
    * [ ROS 2 Dashing Diademata (codename âdashingâ; May 31st, 2019) ](../Releases/Release-Dashing-Diademata.html)
    * [ ROS 2 Eloquent Elusor (codename âeloquentâ; November 22nd, 2019) ](../Releases/Release-Eloquent-Elusor.html)
    * [ ROS 2 Foxy Fitzroy (codename âfoxyâ; June 5th, 2020) ](../Releases/Release-Foxy-Fitzroy.html)
    * [ ROS 2 Galactic Geochelone (codename âgalacticâ; May, 2021) ](../Releases/Release-Galactic-Geochelone.html)
    * [ How to release ](../Releases/Release-Howto.html)
    * [ ROS 2 Rolling Ridley (codename ârollingâ; June 2020) ](../Releases/Release-Rolling-Ridley.html)
  * [ Features Status ](../Features.html)
  * [ Roadmap ](../Roadmap.html)


#  .dsv files  Â¶

Since shell scripts can contain arbitrary logic it is opaque from the outside
how they affect the environment. That makes it impossible to optimize their
execution.

Most scripts perform one of the following common operations:

  * Set an environment variable to a value.
  * Add a value to an environment variable (using a platform specific delimiter) if the value is not already in the collection.
  * Source / call another script file.

A ` .dsv  ` file contains the descriptive information about the intended
environment change (instead of shell specific logic). The content of such a
file uses a semicolon as the delimiter and contains a single line. The first
value is the ` type  ` of the operation followed by a variable number of
arguments specific to the operation.

The following list enumerates the supported types and their arguments:

  * ` prepend-non-duplicate;<name>;<value> ` : Prepend a value ` <value> ` to an environment variable ` <name> ` (using a platform specific delimiter) if the value is not already in the collection. The value is considered to be a path. If the value is not an absolute path the prefix path of the ` .dsv  ` file is prepended to the value. An empty value therefore represents the prefix path.
  * ` prepend-non-duplicate-if-exists;<name>;<value> ` : Same as ` prepend-non-duplicate  ` but only if the path described by the value exists.
  * ` set;<name>;<value> ` : Set an environment variable ` <name> ` to a value ` <value> ` . If the value is an existing relative path in the install prefix the install prefix is prepended to the value. Otherwise the value is used as is.
  * ` set-if-unset;<name>;<value> ` : Same as ` set  ` but only if the environment variable is not yet set (or empty).
  * ` source;<path> ` : Source / call another script file ` <path> ` . If the value is not an absolute path the prefix path of the ` .dsv  ` file is prepended.


To see all available qualifiers, see our [ documentation
](https://docs.github.com/search-github/github-code-search/understanding-
github-code-search-syntax) .


I came across this thread looking for the same answer to this awful core
problem. I don't know what the real solution should be, but I sped up the
sourcing a tad by adding an ampersand at the end of this line in `
install/local_setup.bash ` :


When working with ROS source code, it is often useful to do so in a
"workspace". For the following ROS tutorials you will need an area for working
on tutorials and creating new ROS stacks and packages.


Sort by »  [ oldest  ](/question/389464/why-does-ros2-installsetupbash-source-
ros1-and-ros2/?sort=oldest#sort-top) [ newest  ](/question/389464/why-does-
ros2-installsetupbash-source-ros1-and-ros2/?sort=latest#sort-top) [ most voted
](/question/389464/why-does-ros2-installsetupbash-source-ros1-and-
ros2/?sort=votes#sort-top)


Closed


Related question: [ https://answers.ros.org/question/302608/sourcing-setup-in-
ros2-slow/ ](https://answers.ros.org/question/302608/sourcing-setup-in-
ros2-slow/)


As far as I understand, the source script in ROS2 recursively traverses all
packages and calls their source scripts (as shown by `
AMENT_TRACE_SETUP_FILES=1 source /opt/ros/dashing/setup.bash ` ) to gather the
environment variables. This involves multiple scripts (about 5) per colcon
package. I assume that this is necessary since packages can be relocated, i.e.
they can be installed in a separated or merged workspace.


**[ clalancette ](/clalancette) ** commented  May 21, 2020


How did you install ROS 2 Foxy?


**[ hdino ](/hdino) ** commented  Aug 20, 2019


Asked: ** 2021-10-26 22:24:57 -0500  **


**[ fujitatomoya ](/fujitatomoya) ** commented  May 21, 2020


Copy link


[ ![@kelvin-
sudani](https://avatars.githubusercontent.com/u/11326188?s=80&u=79b8cdb71ffa039e8b8857d1369027ea66bb3ae4&v=4)
](/kelvin-sudani)


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=80&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas)


> adding an ampersand at the end of this line ...


[ Getting the rclcpp::Duration in microseconds ](/question/399382/getting-the-
rclcppduration-in-microseconds/)


rosws init ~/fuerte_workspace /opt/ros/fuerte


**Note:** rosws is part of the [ rosinstall package ](/rosinstall) , which is
not installed by default. The following command downloads it using the Ubuntu
package manager:


Sorry, something went wrong.


[ enhancement  ](/ros2/ros2/labels/enhancement) New feature or request


* 👍  10 reactions


edited


###  Install development tools and ROS tools  ï


Search or jump to...


Projects


The ROS Wiki is for ROS 1. Are you using ROS 2 ( [ Humble
](http://docs.ros.org/en/humble/) , [ Iron ](http://docs.ros.org/en/iron/) ,
or [ Rolling ](http://docs.ros.org/en/rolling/) )?
[ Check out the ROS 2 Project Documentation ](http://docs.ros.org)
Package specific documentation can be found on [ index.ros.org
](https://index.ros.org)


I don't know why your ` setup.bash ` file in your ` ros2_ws ` has references
to noetic, it was probably done while following a tutorial on sourcing two
distributions in one workspace?


    # time source /opt/ros/eloquent/setup.bash

    real    0m1.491s
    user    0m0.727s
    sys     0m0.814s


Does anybody handle this bug?

---

All reactions


**[ wjwwood ](/wjwwood) ** commented  Sep 17, 2018


* Fedora 30, see [ alternate instructions  ](Fedora-Development-Setup.html)


Releases


Optionally install all packages into a combined directory (rather than each
package in a separate subdirectory). On Windows due to limitations of the
length of environment variables you should use this option when building
workspaces with many (~ >> 100 packages).


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=40&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas) [ dirk-thomas ](/dirk-thomas) added [ enhancement
](/ros2/ros2/labels/enhancement) New feature or request  and removed [ bug
](/ros2/ros2/labels/bug) Something isn't working  labels  Aug 20, 2019


These results sound pretty common.

---

All reactions


##  Additional RMW implementations (optional)  ï


* [ ros2 ](/questions/scope:all/sort:activity-desc/tags:ros2/page:1/)


Member


#  Sourcing setup.bash on ROS2 takes considerably longer compared to ROS1
#573


Sorry, something went wrong.


[ ros2 ](/ros2) /  **[ ros2 ](/ros2/ros2) ** Public


[ ](https://github.com "GitHub") © 2024 GitHub, Inc.


##  Question Tools


[ subscribe to rss feed ](/feeds/question/389464/ "subscribe to the rss feed")


__ [ ROS 2 Documentation: Eloquent ](../index.html)


Query


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=80&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas)


###  Creating a new workspace


[ ![Logo](../_static/colcon.svg) ](../index.html)

released

User Documentation

  * [ Installation ](../user/installation.html)
  * [ Quick start ](../user/quick-start.html)
  * [ Configuration ](../user/configuration.html)
  * [ How to ](../user/how-to.html)
  * [ What is a Workspace? ](../user/what-is-a-workspace.html)
  * [ Log Files ](../user/log-files.html)
  * [ Isolated vs Merged Workspaces ](../user/isolated-vs-merged-workspaces.html)
  * [ Using Multiple Workspaces ](../user/using-multiple-workspaces.html)
  * [ Overriding Packages ](../user/overriding-packages.html)

Reference

  * [ ` build  ` \- Build Packages ](../reference/verb/build.html)
  * [ ` edit  ` \- Edit File ](../reference/verb/edit.html)
  * [ ` graph  ` \- Visualize Dependencies ](../reference/verb/graph.html)
  * [ ` info  ` \- Show Package Information ](../reference/verb/info.html)
  * [ ` list  ` \- List Packages ](../reference/verb/list.html)
  * [ ` metadata  ` \- Manage metadata ](../reference/verb/metadata.html)
  * [ ` mixin  ` \- Manage mixins ](../reference/verb/mixin.html)
  * [ ` test  ` \- Test Packages ](../reference/verb/test.html)
  * [ ` test-result  ` \- Summarize Test Results ](../reference/verb/test-result.html)
  * [ Global arguments ](../reference/global-arguments.html)
  * [ Executor arguments ](../reference/executor-arguments.html)
  * [ Event handler arguments ](../reference/event-handler-arguments.html)
  * [ Discovery arguments ](../reference/discovery-arguments.html)
  * [ Package selection arguments ](../reference/package-selection-arguments.html)
  * [ Mixin arguments ](../reference/mixin-arguments.html)

Developer Documentation

  * [ Design ](design.html)
  * [ Bootstrap from source ](bootstrap.html)
  * Environment setup
    * Entry points


Already on GitHub? [ Sign in
](/login?return_to=%2Fros2%2Fros2%2Fissues%2Fnew%2Fchoose) to your account


Now that your environment is setup, continue with the [ ROS file system
tutorial ](/ROS/Tutorials/NavigatingTheFilesystem) .


[ @hdino ](https://github.com/hdino) Just curious; would you be up for trying
to profile the execution?
A quite comprehensive sampling of different profile methods: [
https://stackoverflow.com/a/20855353/7829525
](https://stackoverflow.com/a/20855353/7829525)
That might help to pinpoint the bottlenecks.


If you then look at the ` setup.bash ` from this new workspace, it won't have
noetic sourced, and you can add this one to your ` bashrc ` .


###  Add the ROS 2 apt repository  ï


* Add the ROS 2 apt repository


[ (1) ROS2 Apps takes way too long to start [0]  robotics-4-all/device-app-
manager#25  ](/robotics-4-all/device-app-manager/issues/25)


I understand your point of view. That is why work is ongoing to improve the
performance.


Instead of recursively gathering environment variables from all shell scripts,
wouldn't it be possible to cache these variables (as shown above) once a new
package gets installed and only use a simple source script with this cache
environment from there one?
Alternatively, there should be an option to not recursively iterate through a
merged workspace and just set the standard library and executable paths. I
believe this is how ` virtualenv ` is separating environments too.

---

👍  6  Seanmatthews, SteveMacenski, felixendres, traversaro, svaichu, and
thraen reacted with thumbs up emoji


[
![@Seanmatthews](https://avatars.githubusercontent.com/u/5208933?s=80&u=aefe9cb33106bf693478e4aaaaf9399ed5db0503&v=4)
](/Seanmatthews)


    ROS_DISTRO was set to 'foxy' before. Please make sure that the environment does not mix paths from different distributions.
    ROS_DISTRO was set to 'noetic' before. Please make sure that the environment does not mix paths from different distributions.


$ source /opt/ros/<distro>/setup.bash


Copy link


But in the conversation you mentioned "several seconds even for ... two
packages". I just asked for the additional context to clarify that it is
actually not the time for only two packages but numerous (likely hundreds)
installed Dashing packages. Otherwise we would needed to troubleshoot why your
performance was different (which at the end it isn't).

---

All reactions


  * [ Distributions ](/Distributions)
  * [ ROS/Installation ](/ROS/Installation)
  * [ ROS/Tutorials ](/ROS/Tutorials)
  * [ RecentChanges ](/RecentChanges)
  * [ Installinga...Environment ](/ROS/Tutorials/InstallingandConfiguringROSEnvironment)


##  Video Demonstration


Sorry, something went wrong.


If you have both distributions already installed correctly, you can just
create a new workspace and that will only source foxy.


since this is closed, is there any related issue?

---

All reactions


Free document hosting provided by [ Read the Docs
](http://www.readthedocs.org) .


I just did a fresh install of Ubuntu 18.04 and Eloquent from the official
repository, i.e. ` ros-eloquent-ros-workspace ` version `
0.8.0-1bionic.20191213.040754 ` is installed.


[ Hi there! Please sign in ](/account/signin/?next=/question/389464/why-does-
ros2-installsetupbash-source-ros1-and-ros2/) [ help ](/help/ "help")


[ ![@Levi-
Armstrong](https://avatars.githubusercontent.com/u/9803128?s=80&u=f6e9c208021299989b6d8a27c8cf60e69c3340ac&v=4)
](/Levi-Armstrong)


I have installed ROS1 **noetic** and ROS2 **foxy** on my system. I switch
between them by commenting out the sourcing of either in my .bashrc file as
follows:


**[ EricCousineau-TRI ](/EricCousineau-TRI) ** commented  May 5, 2020  •


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=40&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas) [ dirk-thomas ](/dirk-thomas) removed the [ in progress
](/ros2/ros2/labels/in%20progress) Actively being worked on (Kanban column)
label  Oct 4, 2019


Using a different compiler besides gcc to compile ROS 2 is easy. If you set
the environment variables ` CC  ` and ` CXX  ` to executables for a working C
and C++ compiler, respectively, and retrigger CMake configuration (by using `
--force-cmake-config  ` or by deleting the packages you want to be affected),
CMake will reconfigure and use the different compiler.


On other platforms you will find these setup.*sh files wherever you installed
ROS.


[ @fujitatomoya ](https://github.com/fujitatomoya) I think everyone agrees
that faster would be desired. If you have specific suggestion to improve the
time please don't hesitate to open a new ticket or even better pull request.


[ @clalancette ](https://github.com/clalancette) thank you for the feedback.
That is typically been my experience too when developing. What I will do is
add an option to the setting which enables auto sourcing workspace and have
this on by default. I will then add a button to the project build setting that
when clicked will source the workspace and update the IDE environment for
those who want to manually source the workspace when needed and they can turn
off auto sourcing.

---

All reactions


The ROS 1 bridge can connect topics from ROS 1 to ROS 2 and vice-versa. See
the dedicated [ documentation
](https://github.com/ros2/ros1_bridge/blob/master/README.md) on how to build
and use the ROS 1 bridge.


[ ![@LouisChen1905](https://avatars.githubusercontent.com/u/4928339?s=80&v=4)
](/LouisChen1905)


[ ![@christianrauch](https://avatars.githubusercontent.com/u/8573621?s=80&v=4)
](/christianrauch)


Make sure you have a locale which supports ` UTF-8  ` . If you are in a
minimal environment (such as a docker container), the locale may be something
minimal like ` POSIX  ` . We test with the following settings. However, it
should be fine if youâre using a different UTF-8 supported locale.


[ jmadd ](/users/5269/jmadd/)
11  ●  2  ●  2  ●  4


[ ![@dirk-thomas](https://avatars.githubusercontent.com/u/1335366?s=40&v=4)
](/dirk-thomas) [ dirk-thomas  ](/dirk-thomas)


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=80&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas)


For


Copy link


Member


Sorry, something went wrong.


##  Get ROS 2 code  ï


* Solutions


    source PATH/ros2_quick_setup.sh
    setup_ros2_environment /opt/ros/ dashing
    add_ros2_workspace /home/user/my_workspace


This is still too slow to do it in every terminal I open.

---

All reactions


  1. Install ROS
  2. Managing Your Environment
  3. Create a ROS Workspace
  4. Video Demonstration


More info on working with a ROS workspace can be found in [ this tutorial
](../Tutorials/Colcon-Tutorial.html) .


You will need to add the ROS 2 apt repositories to your system. To do so,
first authorize our GPG key with apt like this:


    locale  # check for UTF-8

    sudo apt update && sudo apt install locales
    sudo locale-gen en_US en_US.UTF-8
    sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
    export LANG=en_US.UTF-8

    locale  # verify settings


    sudo rosdep init
    rosdep update
    rosdep install --from-paths src --ignore-src --rosdistro eloquent -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 libopensplice69 rti-connext-dds-5.3.1 urdfdom_headers"


**[ Levi-Armstrong ](/Levi-Armstrong) ** commented  Jun 2, 2019


See [ Maintaining a source checkout of ROS 2  ](Maintaining-a-Source-
Checkout.html#maintainingsource) to periodically refresh your source
installation.


$ source devel/setup.bash


    time source install/setup.bash

    real	0m1,409s
    user	0m1,132s
    sys	0m0,326s

    time source install/local_setup.bash

    real	0m0,192s
    user	0m0,174s
    sys	0m0,022s


**[ clalancette ](/clalancette) ** commented  Jun 3, 2019


##  Stay up to date  ï


First time here? Check out the FAQ!


For others to explore potential solutions, is there a suggested toy benchmark
in which people can tinker with and some pointers to what source to play with?


  * [ Feature Ideas ](../Feature-Ideas.html)
  * [ Project Governance ](../Governance.html)
  * [ Marketing Materials ](../Marketing.html)
  * [ Related Projects ](../Related-Projects.html)
    * [ Intel ROS 2 Projects ](../Related-Projects/Intel-ROS2-Projects.html)


[ ![ gravatar image]() ]() [ ]() (  2024-04-18 17:31:33 -0500  )  edit


[ Can we use MQTT in ROS2? [closed] ](/question/369262/can-we-use-mqtt-in-
ros2/)


Copy link


* Install dependencies using rosdep


If you just installed ROS from ` apt ` on Ubuntu then you will have setup.*sh
files in ' ` /opt/ros/<distro>/ ` ', and you could source them like so:


**[ dirk-thomas ](/dirk-thomas) ** commented  Sep 13, 2018  •


In one terminal, source the setup file and then run a C++ ` talker  ` :


Is there a way to speed-up the sourcing process in ros2 Eloquent? For example,
is there a way to do the sourcing only once (e.g., at boot time), rather than
repeating the process for all bashes?
In another thread [ @dirk-thomas ](https://github.com/dirk-thomas) said that
Eloquent has better performances (he said that sourcing ~300 pkgs takes about
half a second) but still in my NVIDIA Jetson Nano with Ubuntu 18.04 and
Eloquent, sourcing ~200 pkgs takes dozens of seconds.
Do you have any advice for reducing this sourcing time?

---

All reactions


[ none ](/questions/scope:all/sort:activity-desc/tags:none/page:1/) ×


Using the short name of your ROS distribution instead of ` <distro> `


##  1  Answer


##  Use saved searches to filter your results more quickly


[ Sign in
](/login?return_to=https%3A%2F%2Fgithub.com%2Fros2%2Fros2%2Fissues%2F573)


[ **asked 2021-10-26 22:24:57 -0500  ** ](/questions/389464/revisions/)


Toggle navigation


* Product


* Uninstall


[ ![@wjwwood](https://avatars.githubusercontent.com/u/100427?s=40&v=4)
](/wjwwood) [ wjwwood ](/wjwwood) added [ bug ](/ros2/ros2/labels/bug)
Something isn't working  [ help wanted ](/ros2/ros2/labels/help%20wanted)
Extra attention is needed  labels  Sep 8, 2018


Though this is still a workaround, having one common script to source
arbitrary workspaces might be a good idea for further development.

---

All reactions


* [ setup.bash ](/questions/scope:all/sort:activity-desc/tags:setup.bash/page:1/)


Wiki: ROS/Tutorials/InstallingandConfiguringROSEnvironment (last edited
2024-01-30 17:50:03 by  [ ChrisLalancette ](/ChrisLalancette "ChrisLalancette
@ 71.174.62.76\[71.174.62.76\]") )


**[ dirk-thomas ](/dirk-thomas) ** commented  Aug 20, 2019


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=40&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas) [ dirk-thomas ](/dirk-thomas) added the [ in progress
](/ros2/ros2/labels/in%20progress) Actively being worked on (Kanban column)
label  Aug 20, 2019


Last updated: **Nov 03 '21**


source ~/fuerte_workspace/setup.bash


    $ echo $ROS_PACKAGE_PATH
    /home/youruser/catkin_ws/src:/opt/ros/kinetic/share


Sorry, something went wrong.


Explore


Closed


Contents


Member


Additional navigation options


* 🎉  1 reaction


[ Rolling ](../../rolling/index.html)


Since the long loading time of terminals is really annoying when sourcing
setup.bash, I wanted to try the caching approach. However, my dashing
installation on Ubuntu 18.04 from the official repository doesn't have an
install folder and replacing local_setup.bash in /opt/ros/dashing caused an
error on my fresh system (I think a python script was missing). Therefore, as
a temporary workaround I put everything in a script which I source:


##  Comments


Contributor


* Get ROS 2 code


  Implementation  Â¶

Implementing the logic to determine the topological order of packages in every
primary shell would be a lot of effort and (depending on the shell)
cumbersome. Also parsing and interpreting ` .dsv  ` files would likely not be
much faster than invoking the native scripts.

Therefore both parts are implemented in a Python script located in the root of
the install prefix: ` _local_setup_util_<ext>.py  ` . The Python script itself
canât change the environment. However, it is able to efficiently interpret
the operations described by the ` .dsv  ` files and generate the shell
specific commands necessary to update the environment. The Python file is
templated with information specific to the primary shell itâs used from,
hence the ` <ext> ` in the filename.


![\(!\)](/moin_static197/rostheme/img/idea.png) Please ask about problems and
questions regarding this tutorial on [ answers.ros.org
](http://answers.ros.org) . Don't forget to include in your question the link
to this page, the versions of your OS & ROS, and also add appropriate tags.
---

#  Installing and Configuring Your ROS Environment


As you can see, it is sourcing noetic and then sourcing foxy. Why? Did I set
something up incorrectly? I confirmed that I can comment out the line where it
sources **noetic** and I get exactly the behavior I want but I am not
comfortable with a solution that has me modifying an auto-generated file.


[ ![ROS Answers logo](/m/ros/media/images/logoros.png?v=28) ](/questions/)


  *[
              2021-10-26 22:24:57 -0500
             ]: 2021-10-26 22:24:57 -0500
  *[
             2021-11-01 17:24:49 -0500
            ]: 2021-11-01 17:24:49 -0500
  *[
              2021-11-03 04:15:13 -0500
             ]: 2021-11-03 04:15:13 -0500
  *[
             2021-11-03 04:24:11 -0500
            ]: 2021-11-03 04:24:11 -0500
  *[
        2021-10-26 22:24:57 -0500
       ]: 2021-10-26 22:24:57 -0500
  *[
        2024-04-18 17:31:33 -0500
       ]: 2024-04-18 17:31:33 -0500


#  Saved searches


Set up your environment by sourcing the following file.


ROS Resources: [ Documentation ](http://wiki.ros.org/) | [ Support
](http://wiki.ros.org/Support) | [ Discussion Forum
](http://discourse.ros.org/) | [ Index ](http://index.ros.org/) | [ Service
Status ](http://status.ros.org/) | [ ros @ Robotics Stack Exchange
](https://robotics.stackexchange.com/questions/tagged/ros)
---

_Attention:_ Answers.ros.org is deprecated as of August the 11th, 2023. Please
visit [ robotics.stackexchange.com ](http://robotics.stackexchange.com) to ask
a new question. This site will remain online in read-only mode during the
transition and into the foreseeable future. Selected questions and answers
have been migrated, and redirects have been put in place to direct users to
the corresponding questions on Robotics Stack Exchange. Additional details are
[ available here ](https://discourse.ros.org/t/ros-and-gazebo-answers-
migration-to-robotics-stack-exchange-process/31494) .


**[ Levi-Armstrong ](/Levi-Armstrong) ** commented  Jun 3, 2019


Name


* Try some examples


Sorry, something went wrong.


Sign up for GitHub


Anyway, you can just do


**Note:** The ROS Wiki is generally for ROS 1 only! If you have installed ROS
2 please use the [ ROS 2 documentation website ](https://docs.ros.org/) .


    * [ All features ](/features)
    * [ Documentation  ](https://docs.github.com)
    * [ GitHub Skills  ](https://skills.github.com/)
    * [ Blog  ](https://github.blog)


If you want an in depth explanation you can check out this video I made: [
https://www.youtube.com/watch?v=TIMJ-...
](https://www.youtube.com/watch?v=TIMJ-WL_lGU)


All reactions


No branches or pull requests


If they are not then you might need to 'source' some setup.*sh files.


* 👍  6 reactions


> Example workspace containing just ` example_interfaces ` and ` examples ` :


New packages need to be put in a path that is in the variable `
ROS_PACKAGE_PATH ` . All directories that are managed by rosws, i.e. that have
been added using rosws are automatically added to the ` ROS_PACKAGE_PATH `
when the file ` setup.bash ` of the corresponding workspace is sourced.
Although new packages should always be put in repositories that have been
installed using rosws, it can be very convenient to have a sandbox directory
where for instance packages created during the tutorials can be put without
requiring any additional rosws commands. For that we create a new directory
sandbox and add it to the hidden ` .rosinstall ` file with rosws:


Repositories


Development


I noticed however that even with ROS 1 sourcing commented out, it was being
sourced as indicated by the following message every time I opened a terminal:


    $ ./env_example.sh
    + set-env
    + export MY_VARIABLE=hello
    + MY_VARIABLE=hello
    + echo 'Set MY_VARIABLE=hello'
    Set MY_VARIABLE=hello
    + echo hello
    hello
    + wait
    + set-env
    + export MY_VARIABLE=hello
    + MY_VARIABLE=hello
    + echo 'Set MY_VARIABLE=hello'
    Set MY_VARIABLE=hello
    + echo did not work
    did not work


[
![@Seanmatthews](https://avatars.githubusercontent.com/u/5208933?s=80&u=aefe9cb33106bf693478e4aaaaf9399ed5db0503&v=4)
](/Seanmatthews)


[ Create Dockerfile for ros2 package : ament_cmake error
](/question/319610/create-dockerfile-for-ros2-package-ament_cmake-error/)


$ source /opt/ros/kinetic/setup.bash


[
![@hdino](https://avatars.githubusercontent.com/u/7059909?s=80&u=3298ba8a6b0e9797edc44c49055ba37e7fcc123b&v=4)
](/hdino)


[ ![@wjwwood](https://avatars.githubusercontent.com/u/100427?s=52&v=4)
](/wjwwood) [
![@clalancette](https://avatars.githubusercontent.com/u/163000?s=52&v=4)
](/clalancette) [ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=52&v=4) ](/dirk-
thomas) [
![@LouisChen1905](https://avatars.githubusercontent.com/u/4928339?s=52&v=4)
](/LouisChen1905) [
![@Seanmatthews](https://avatars.githubusercontent.com/u/5208933?s=52&v=4)
](/Seanmatthews) [
![@Karsten1987](https://avatars.githubusercontent.com/u/5419873?s=52&v=4)
](/Karsten1987) [
![@felixendres](https://avatars.githubusercontent.com/u/6112784?s=52&v=4)
](/felixendres) [
![@hdino](https://avatars.githubusercontent.com/u/7059909?s=52&v=4) ](/hdino)
[ ![@routiful](https://avatars.githubusercontent.com/u/7092473?s=52&v=4)
](/routiful) [
![@christianrauch](https://avatars.githubusercontent.com/u/8573621?s=52&v=4)
](/christianrauch) [ ![@Levi-
Armstrong](https://avatars.githubusercontent.com/u/9803128?s=52&v=4) ](/Levi-
Armstrong) [ ![@kelvin-
sudani](https://avatars.githubusercontent.com/u/11326188?s=52&v=4) ](/kelvin-
sudani) [ ![@EricCousineau-
TRI](https://avatars.githubusercontent.com/u/26719449?s=52&v=4)
](/EricCousineau-TRI) [
![@richichiare](https://avatars.githubusercontent.com/u/43334081?s=52&v=4)
](/richichiare) [
![@fujitatomoya](https://avatars.githubusercontent.com/u/43395114?s=52&v=4)
](/fujitatomoya)


##  Bug report


**[ kelvin-sudani ](/kelvin-sudani) ** commented  Sep 12, 2018


[ ![@klpanagi](https://avatars.githubusercontent.com/u/4770702?s=40&v=4)
](/klpanagi) [ klpanagi ](/klpanagi) mentioned this issue  Jun 9, 2020


I removed the "help wanted" label - not because we wouldn't like to get help
on this but since it is a rather complicated issue to resolve and might not be
a good issue to be found when users check to which tickets they could
contribute...

---

All reactions


Let's create and build a [ catkin workspace ](/catkin/workspaces) :


Sorry, something went wrong.


* Open Source


> I do not think that we could accept the following as product


##  Try some examples  ï


    sudo apt update && sudo apt install curl gnupg2 lsb-release
    curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -


[ @dirk-thomas ](https://github.com/dirk-thomas) We are currently integrating
colcon into the ROS Qt Creator plugin and also noticed the pause due to
sourcing. In the IDE I can run this in the background sometimes but not always
and when finished update the IDE environment, but currently every time I
execute commands that need the environment I go ahead and resource the
workspace which I believe is excessive. I am trying to understand when a user
should resource the workspace? Is it simple like after new package are
introduced to the workspace or is it more complicated than that?

---

All reactions


Labels


Search


**[ felixendres ](/felixendres) ** commented  Aug 7, 2019  •


**[ dirk-thomas ](/dirk-thomas) ** commented  Aug 20, 2019


During the installation of ROS, you will see that you are prompted to ` source
` one of several setup.*sh files, or even add this 'sourcing' to your shell
startup script. This is required because ROS relies on the notion of combining
spaces using the shell environment. This makes developing against different
versions of ROS or against different sets of packages easier.


    # time source /opt/ros/eloquent/setup.bash

    real    0m1.291s
    user    0m0.520s
    sys     0m0.248s


  Entry points  Â¶

To update environment variables:

  * On non-Windows platforms a shell script needs to be ` source  ` -ed (e.g. ` .sh  ` , ` .bash  ` , ` .zsh  ` )
  * On Windows a shell script needs to be ` call  ` -ed (e.g. ` .bat  ` , ` .ps1  ` )

Note

Executables are unable to change the environment of the current shell.
Therefore this needs to be done from a shell script.


##  Comments


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=80&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas)


* System setup


Copy link


**[ richichiare ](/richichiare) ** commented  May 21, 2020


I haven't tried this in a while, but wouldn't the problem arise if you're
trying to use a Docker container, or similar, for deployment or development?

---

All reactions


* Raspi4/Ubuntu18.04/Eloquent


* Source the setup script


[ ![jmadd gravatar image](/m/default/media/images/nophoto.png?v=27)
](/users/5269/jmadd/)


##  Environment setup  ï


Sorry, something went wrong.


[ ![jacobperron gravatar
image](/upfiles/avatars/jacobperron/resized/16/avatar.jpeg)
](/users/26373/jacobperron/) [ jacobperron ](/users/26373/jacobperron/) (
2021-11-01 17:24:49 -0500  )  edit


add a comment


    mkdir ~/fuerte_workspace/sandbox
    rosws set ~/fuerte_workspace/sandbox


    LD_LIBRARY_PATH=/opt/ros/dashing/opt/yaml_cpp_vendor/lib:/opt/ros/dashing/opt/rviz_ogre_vendor/lib:/usr/lib:/opt/ros/dashing/lib
    AMENT_PREFIX_PATH=/opt/ros/dashing
    OSPL_VERBOSITY=2
    OSPL_URI=file:///opt/ros/dashing/share/opensplice_cmake_module/config/ros_ospl.xml
    OSPL_HOME=/usr
    OSPL_INFOFILE=<stdout>
    ROS_VERSION=2
    ROS_PYTHON_VERSION=3
    OSPL_ERRORFILE=<stderr>
    PYTHONPATH=/opt/ros/dashing/lib/python3.6/site-packages
    PATH=/opt/ros/dashing/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    ROS_DISTRO=dashing
    OSPL_TMPL_PATH=/usr/etc/opensplice/idlpp


    time bash-isolate -c ./benchmark.sh

    real	0m1,762s
    user	0m1,242s
    sys	0m0,516s


[ tags ](/tags/) [ users ](/users/) [ badges ](/badges/)


####  Expected behavior


* Troubleshooting


Create a workspace and clone all repos:


**[ dirk-thomas ](/dirk-thomas) ** commented  Oct 21, 2020


  * install ` ros-bouncy-desktop `
  * measure the time it takes to source the default workspace: ` time source /opt/ros/bouncy/setup.bash `


* [ The ReadME Project  GitHub community articles  ](/readme)


You should see the ` talker  ` saying that itâs ` Publishing  ` messages and
the ` listener  ` saying ` I  heard  ` those messages. This verifies both the
C++ and Python APIs are working properly. Hooray!


Sourcing the default ROS2 workspace via ` source /opt/ros/bouncy/setup.bash `
takes much longer than sourcing a ROS1 workspace. This makes setting it by
default in ` .bashrc ` uncomfortable.


Password


[ ![rodrigo55 gravatar
image](/upfiles/avatars/rodrigo55/resized/32/Screenshot%20from%202020-03-30%2015-03-17.png)
](/users/53015/rodrigo55/)


* Install additional DDS implementations (optional)


* Tier 1: Ubuntu Linux - Bionic Beaver (18.04) 64-bit


Which could be _why_ he is in the situation he's currently in.


Please run this script to see:


Copy link


**[ hdino ](/hdino) ** commented  Aug 15, 2019  •


    [...]
    . "/opt/ros/bouncy/share/tf2/local_setup.bash"
    . "/opt/ros/bouncy/share/tf2/local_setup.sh"
    . "/opt/ros/bouncy/share/tf2/environment/ament_prefix_path.sh"
    . "/opt/ros/bouncy/share/tf2/environment/library_path.sh"
    . "/opt/ros/bouncy/share/tf2/environment/path.sh"
    [...]


Watch the video below to have more explanation on Custom Workspace and Package
Creation with step by step guide .


[ ![@clalancette](https://avatars.githubusercontent.com/u/163000?s=80&v=4)
](/clalancette)


edited


Closed


[ christianrauch ](/christianrauch) opened this issue  Sep 8, 2018  · 36
comments


    time source /opt/ros/dashing/setup.bash

    real	0m1,353s
    user	0m1,087s
    sys	0m0,325s

    time source /opt/ros/dashing/local_setup.bash

    real	0m1,119s
    user	0m0,971s
    sys	0m0,193s


###  Creating a sandbox directory for new packages


* 👍  2 reactions


##  System setup  ï


    * [ Topics ](/topics)
    * [ Trending ](/trending)
    * [ Collections ](/collections)


Resources


#  Workspace-level  Â¶

In the root of the install prefix path, ` colcon  ` generates two kinds of
scripts:

  * ` local_setup.<ext> ` : updates the environment with information from all packages installed under this prefix path. Since package-level scripts rely on information from their dependencies the package-level scripts must be invoked in topological order. In order to determine the topological order of all packages under the prefix path, ` colcon  ` stores all run dependencies of a package in a file named ` share/colcon-core/packages/<package_name> ` .
  * ` setup.<ext> ` : first invokes the ` local_setup.<ext> ` files from all parent prefix paths and then invokes the sibling ` local_setup.<ext> ` file.


1 follower


Labels


Also, if you have already installed ROS 2 from Debian make sure that you run
the ` build  ` command in a fresh environment. You may want to make sure that
you do not have ` source  /opt/ros/${ROS_DISTRO}/setup.bash  ` in your `
.bashrc  ` .


I just did a fresh install of Ubuntu 18.04 on a Ryzen machine with a fast PCIe
SSD (native, not in a virtual machine) and dashing from the official
repository. Results:


    . ~/ros2_eloquent/install/local_setup.bash
    ros2 run demo_nodes_py listener


* 👍  1 reaction


You should see something similar to:


Sourcing it with a ` merge-install ` setup:


Example workspace containing just ` example_interfaces ` and ` examples ` :


[ ![gvdhoorn gravatar image](/upfiles/avatars/gvdhoorn/resized/16/4550046.png)
](/users/5184/gvdhoorn/) [ gvdhoorn ](/users/5184/gvdhoorn/) (  2021-11-03
04:24:11 -0500  )  edit


Copy link


[ about ](/about/) |  [ faq ](/faq/) |  [ help ](/help/ "help") |  [ privacy
policy ](/privacy/) |  [ terms of service ](/terms/)


` local_setup.bash ` sources the environment hooks for just one package or
just one workspace (depending on where it was located. ` setup.bash ` will
source environment hooks for the current package or workspace _and_ it's
dependencies. In both cases each file needs to be sourced by the setup file.
There's no single file that aggregates all environment hooks for all packages.

---

All reactions


Contributor


  Different shells  Â¶

Each shell has a potentially different syntax and supports a different set of
features. Some environment changes like extending the ` PATH  ` are applicable
to all shells while others like providing completion functionality are only
applicable to some. If one shell (e.g. ` bash  ` ) provides a superset of
functionality and syntax of another shell (e.g. ` sh  ` ) the logic of the `
.sh  ` scripts doesnât have to be duplicated for ` bash  ` but can be
invoked from the package-level setup files. The latter shell is called a
_primary shell_ .


The command that takes the longest is in line 6528:


Sorry, something went wrong.


It works very well for me, when replacing the respective "local_setup.bash" of
the system-installation and my workspaces sourcing is instantanous.


[ rosws ](/rosws) is a tool that provides a uniform interface to various
version control systems such as SVN, Git and Mercurial and for managing all
packages installed in a ROS overlay. An extensive tutorial on rosws can be
found [ here ](http://www.ros.org/doc/api/rosinstall/html/rosws_tutorial.html)
.


[ ![ros.org](/custom/images/ros_org.png) ](/) |  [ About
](http://www.ros.org/about-ros) | [ Support ](/Support) | [ Discussion Forum
](http://discourse.ros.org/) | [ Index ](http://index.ros.org/) | [ Service
Status ](http://status.ros.org/) | [ ros @ Robotics Stack Exchange
](https://robotics.stackexchange.com/questions/tagged/ros)
---|---
![](/custom/images/menu_left.png) [
![Documentation](/custom/images/menu_documentation.png) ](/)
![](/custom/images/menu_spacer.png) [ ![Browse
Software](/custom/images/menu_browse_software.png)
](https://index.ros.org/packages) ![](/custom/images/menu_spacer.png) [
![News](/custom/images/menu_news.png) ](https://discourse.ros.org/c/general)
![](/custom/images/menu_spacer.png) [
![Download](/custom/images/menu_download.png) ](/ROS/Installation)
![](/custom/images/menu_right.png)

  * [ ROS ](/ROS)
  * [ Tutorials ](/ROS/Tutorials)
  * [ InstallingandConfiguringROSEnvironment ](/ROS/Tutorials/InstallingandConfiguringROSEnvironment)


[ **answered 2021-11-03 04:15:13 -0500  ** ](/answers/389914/revisions/)


**Description:** This tutorial walks you through installing ROS and setting up
the ROS environment on your computer.

**Tutorial Level:** BEGINNER

**Next Tutorial:** [ Navigating the ROS Filesystem
](/ROS/Tutorials/NavigatingTheFilesystem)


Random thoughts: If this is strongly coupled to decoupling [*], might there be
a way to speed up composition?
Can info collection be delegated to python if the file matches some pattern in
which the script is more declarative than imperative? (e.g. if the user
doesn't supply their own template, put some token near the top, and attempt to
fast aggregation beforehand?)


    0.439764	1.5125	+++++ _ament_ordered_commands='export AMENT_PREFIX_PATH="/opt/ros/eloquent:$AMENT_PREFIX_PATH"

---

🎉  1  EricCousineau-TRI reacted with hooray emoji


Note: if you are having trouble compiling all examples and this is preventing
you from completing a successful build, you can use ` AMENT_IGNORE  ` in the
same manner as [ CATKIN_IGNORE ](https://github.com/ros-
infrastructure/rep/blob/master/rep-0128.rst) to ignore the subtree or remove
the folder from the workspace. Take for instance: you would like to avoid
installing the large OpenCV library. Well then simply ` $  touch  AMENT_IGNORE
` in the ` cam2image  ` demo directory to leave it out of the build process.


Cancel  Create saved search


#  Provide feedback


FYI I tend to try out solutions from GitHub blindly sometimes, so it's helpful
if you have the time to vet it first!

---

All reactions


##  Stats


Copy link


edited


No milestone


The second column contains the accumulated time, the first one the time
differences.


**[ christianrauch ](/christianrauch) ** commented  Sep 17, 2018


#  Building ROS 2 on Linux  ï


Before starting these tutorials please complete installation as described in
the [ ROS installation instructions ](/ROS/Installation) .


While these hacks might work for your use cases locally they don't satisfy the
requirement we have for the environment setup. Please see [ #764
](https://github.com/ros2/ros2/issues/764) which explicitly enumerated the
goals and also references some work in progress to address this problem.

---

All reactions


#  Sourcing setup.bash on ROS2 takes considerably longer compared to ROS1
#573


I do not think that we could accept the following as product, since boot time
is key especially consumer devices, which reflects on user experience.


[ ![@clalancette](https://avatars.githubusercontent.com/u/163000?s=80&v=4)
](/clalancette)


. ~/ros2_eloquent/install/setup.bash


**[ EricCousineau-TRI ](/EricCousineau-TRI) ** commented  Mar 18, 2020


It is very common to replace the line ` source /opt/ros/fuerte/setup.bash ` to
source the setup.bash in ` ~/fuerte_workspace ` or whichever workspace you use
most often.


> Form the name of the source files, I would assume that local_setup.bash is
> sourcing every package individually (as observed), but setup.bash should
> source the whole workspace at once.


All reactions


Is this supposed to happen? Form the name of the source files, I would assume
that ` local_setup.bash ` is sourcing every package individually (as
observed), but ` setup.bash ` should source the whole workspace at once.

---

All reactions


    * [ Actions  Automate any workflow  ](/features/actions)
    * [ Packages  Host and manage packages  ](/features/packages)
    * [ Security  Find and fix vulnerabilities  ](/features/security)
    * [ Codespaces  Instant dev environments  ](/features/codespaces)
    * [ Copilot  Write better code with AI  ](/features/copilot)
    * [ Code review  Manage code changes  ](/features/code-review)
    * [ Issues  Plan and track work  ](/features/issues)
    * [ Discussions  Collaborate outside of code  ](/features/discussions)


Table of Contents


* Alternate compilers


  * 👍  2 reactions
  * 👎  6 reactions


edited


    #!/bin/bash
    set -euxo pipefail

    # Use subshells () to get separate bash processes.
    # The syntax ${var:-unset value} will print the value of ${var} if set;
    # otherwise, it will print "unset value" (or whatever else you type there).

    set-env() {
        export MY_VARIABLE=hello
        echo "Set MY_VARIABLE=hello"
    }

    # Direct usage, works.
    (
        set-env
        # Works
        echo ${MY_VARIABLE:-did not work}
    )

    # Indirect usage via forking, does not work.
    (
        set-env &
        wait
        echo ${MY_VARIABLE:-did not work}
    )


Member


Copy link


[
![@routiful](https://avatars.githubusercontent.com/u/7092473?s=80&u=1a16d9551a710b937267a1786567af6407146198&v=4)
](/routiful)


Jump to bottom


**[ felixendres ](/felixendres) ** commented  Aug 9, 2019


Sorry, something went wrong.


edit


  * ROS packages installed with package managers provide setup.*sh files
  * [ rosbuild workspaces ](http://www.ros.org/wiki/fuerte/Installation/Overlays) provide setup.*sh files using tools like [ rosws ](/rosws)


catkin  rosbuild


##  Next steps after installing  ï


#  Non-primary / additional shells  Â¶

Other shells which are able to invoke primary shell scripts within their
context commonly donât duplicate their content and logic. Instead they first
invoke the primary shell script and then add additional logic to provide
specific functionalities like completion.


[ ![@EricCousineau-
TRI](https://avatars.githubusercontent.com/u/26719449?s=80&u=85559e6a1fdfc12d6200ad76cc5c26d7928cdc03&v=4)
](/EricCousineau-TRI)


###  Install additional DDS implementations (optional)  ï


[ @Karsten1987 ](https://github.com/Karsten1987) If I recall correctly on your
macOS the title bar of your terminal tab was constantly being updated while
the sourcing was ongoing. That seems to indicate another problem which is
probably slowing down the process. I would suggest to first look into that /
resolve that and then measure again.

---

All reactions


New issue


* [ GitHub Sponsors  Fund open source developers  ](/sponsors)


15 participants


add a comment


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=40&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas) [ dirk-thomas ](/dirk-thomas) added this to the [ crystal
](/ros2/ros2/milestone/4) milestone  Sep 13, 2018


**Note:** If you installed ROS from a package manager like ` apt ` , then
those packages will not be write accessible and should not be edited by you
the user. When working with ROS packages from source or when creating a new
ROS package, you should always work in a directory that you have access to,
like your home folder.


Assignees


The site is read-only. Please transition to use Robotics Stack Exchange


#  Search code, repositories, users, issues, pull requests...


[ enhancement  ](/ros2/ros2/labels/enhancement) New feature or request


[ @EricCousineau-TRI ](https://github.com/EricCousineau-TRI) I used the first
profiling method ( ` set -x ` and ` date ` ) and got the following results:


Sorry, something went wrong.


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=80&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas)


> Is there a way to speed-up the sourcing process in ros2 Eloquent? For
> example, is there a way to do the sourcing only once (e.g., at boot time),
> rather than repeating the process for all bashes?


[ ![@felixendres](https://avatars.githubusercontent.com/u/6112784?s=80&v=4)
](/felixendres)


Email Address


Tier 3 platforms (not actively tested or supported) include:


Contributor


If you installed ROS Kinetic, that would be:


If you would like to use another DDS or RTPS vendor besides the default,
eProsimaâs Fast RTPS, you can find instructions [ here  ](DDS-
Implementations.html) .


##  Troubleshooting  ï


I know. However, as long as the setup scripts take several seconds even for
small workspaces (two packages, each includes only one library/executable) on
relatively fast systems (recent Core i5, Samsung 850 Pro SSD), these hacks
might be an option to setup the environment. Of course, they were not intended
to replace anything and should not be used after these problems have been
fixed.

---

All reactions


edited


Include my email address so I can be contacted


Troubleshooting techniques can be found [ here
](../Troubleshooting/Installation-Troubleshooting.html#linux-troubleshooting)
.


[ Sourcing setup script from Debian takes considerably longer than the
local_setup script  #929  ](/ros2/ros2/issues/929)


This will only work if the OP hasn't actually already added an auto- ` source
` of both ` setup.bash ` files to his shell configuration.


Running this inside of script:


sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'


* [ Pricing ](/pricing)


[ ![@EricCousineau-
TRI](https://avatars.githubusercontent.com/u/26719449?s=80&u=85559e6a1fdfc12d6200ad76cc5c26d7928cdc03&v=4)
](/EricCousineau-TRI)


[ ![@Levi-
Armstrong](https://avatars.githubusercontent.com/u/9803128?s=80&u=f6e9c208021299989b6d8a27c8cf60e69c3340ac&v=4)
](/Levi-Armstrong)


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=40&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas) [ dirk-thomas ](/dirk-thomas) closed this as [ completed
](/ros2/ros2/issues?q=is%3Aissue+is%3Aclosed+archived%3Afalse+reason%3Acompleted)
Oct 4, 2019


Copy link


[ ROS2 nodes launched with systemd aren't discovered
](/question/389577/ros2-nodes-launched-with-systemd-arent-discovered/)


**[ hdino ](/hdino) ** commented  May 6, 2020


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=40&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas) [ dirk-thomas ](/dirk-thomas) removed this from the [ crystal
](/ros2/ros2/milestone/4) milestone  Jan 17, 2019


* Stay up to date


[ improve performance when setting up environment  #764
](/ros2/ros2/issues/764)


    * [ CI/CD & Automation ](/solutions/ci-cd/)
    * [ DevOps ](/solutions/devops/)
    * [ DevSecOps  ](https://resources.github.com/devops/fundamentals/devsecops/)


* System requirements


[ Sign up for free ](/join?source=comment-repo) **to join this conversation on
GitHub** . Already have an account? [ Sign in to comment
](/login?return_to=https%3A%2F%2Fgithub.com%2Fros2%2Fros2%2Fissues%2F573)


Except where otherwise noted, the ROS wiki is licensed under the
[ Creative Commons Attribution 3.0
](http://creativecommons.org/licenses/by/3.0/)


[
![@hdino](https://avatars.githubusercontent.com/u/7059909?s=80&u=3298ba8a6b0e9797edc44c49055ba37e7fcc123b&v=4)
](/hdino)


##  Related questions


* 👍  3 reactions


[ edit ](/s/answers/389914/edit/) flag offensive  delete  [ link
](/question/389464/why-does-ros2-installsetupbash-source-ros1-and-
ros2/?answer=389914#post-id-389914 "permanent link") more


[1] There are more complicated scenarios where this isn't exactly true, but
for the most part it should work and is how I do development.

---

All reactions


**[ dirk-thomas ](/dirk-thomas) ** commented  Aug 20, 2019


Author


###  Clang  ï


Any help is greatly appreciated!!!


**[ dirk-thomas ](/dirk-thomas) ** commented  Oct 4, 2019


Member


Afterwards source the ` local_setup.*  ` from the ` install  ` folder.


  Avoid duplicate entries  Â¶

Several environment variables store multiple values separated by a delimiter.
Commonly, duplicate values are not useful and only increase length and
decrease readability. Therefore, shell scripts try to avoid adding duplicate
values where applicable.

With the number of values in such an environment variable the cost to check if
a given value is already in the collection increases. This significantly
affects the time it takes to ` source  ` / ` call  ` the workspace-level setup
file since for each attempt to update an environment variable the collection
needs to be split and each existing value compared to the to-be-added value.

Therefore ` colcon  ` provides an alternative way to update the environment.


The following command creates a new workspace in ` ~/fuerte_workspace ` which
extends the set of packages installed in /opt/ros/fuerte:


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=40&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas) [ dirk-thomas ](/dirk-thomas) mentioned this issue  Aug 20,
2019


#  User


    . ~/ros2_eloquent/install/local_setup.bash
    ros2 run demo_nodes_cpp talker


* Additional RMW implementations (optional)


* Arch Linux, see [ alternate instructions ](https://wiki.archlinux.org/index.php/ROS#ROS_2)


[ ![@dirk-thomas](https://avatars.githubusercontent.com/u/1335366?s=40&v=4)
](/dirk-thomas)


[ rodrigo55 ](/users/53015/rodrigo55/)
156  ●  2  ●  9  ●  8


  * Operating System: Ubuntu 18.04
  * Installation type: binary
  * Version or commit hash: bouncy


  * Immutable Page
  * Comments
  * [ Info ](/action/info/ROS/Tutorials/InstallingandConfiguringROSEnvironment?action=info)
  * [ Attachments ](/action/AttachFile/ROS/Tutorials/InstallingandConfiguringROSEnvironment?action=AttachFile)
  * More Actions:  Raw Text  Print View  Render as Docbook  Delete Cache  \------------------------  Check Spelling  Like Pages  Local Site Map  \------------------------  Rename Page  Copy Page  Delete Page  \------------------------  My Pages  Subscribe User  \------------------------  Remove Spam  Revert to this revision  Package Pages  Sync Pages  \------------------------  CreatePdfDocument  Load  RawFile  Save  SlideShow


**[ christianrauch ](/christianrauch) ** commented  Sep 8, 2018


[ ![@christianrauch](https://avatars.githubusercontent.com/u/8573621?s=80&v=4)
](/christianrauch)


For a workspace with separated packages, I assume that ` LD_LIBRARY_PATH ` , `
PATH ` and ` PYTHONPATH ` will have multiple entries.


**[ routiful ](/routiful) ** commented  Mar 19, 2019


Copy link


##  Using the ROS 1 bridge  ï


All reactions


**[ hdino ](/hdino) ** commented  Aug 20, 2019  •


####  Steps to reproduce issue


[ Previous ](../Installation.html "Installation") [ Next  ](Linux-Install-
Binary.html "Installing ROS 2 on Linux")


Of course, this is limited to a default installation, but maybe it's useful
for someone as long as there is no better working solution.

---

All reactions


The [ catkin_make ](/catkin/commands/catkin_make) command is a convenience
tool for working with [ catkin workspaces ](/catkin/workspaces) . Running it
the first time in your workspace, it will create a ` CMakeLists.txt ` link in
your 'src' folder.


This is certainly not a common performance for such a setup. For an isolated
workspace with ~200 pkgs it takes me 1-2s to source on Ubuntu on a Lenovo P50
using an SSD.


* Setup.*sh files are created as a by-product of [ building ](/catkin/workspaces#Building_Packages_with_catkin) or [ installing ](/catkin/workspaces#Installing_Packages_with_Catkin) catkin packages


Sorry, something went wrong.


To further understand the problem, I ran
` AMENT_TRACE_SETUP_FILES=1 source /opt/ros/bouncy/setup.bash `
and
` AMENT_TRACE_SETUP_FILES=1 source /opt/ros/bouncy/local_setup.bash `
to compare the list of sourced files.
( ` COLCON_TRACE=1 source ... ` does not provide a list of source files for
me.)


**Required Info:**


    * [ Enterprise ](/enterprise)
    * [ Teams ](/team)
    * [ Startups ](/enterprise/startups)
    * [ Education  ](https://education.github.com)


**[ EricCousineau-TRI ](/EricCousineau-TRI) ** commented  Mar 26, 2019


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=40&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas) [ dirk-thomas ](/dirk-thomas) self-assigned this  Aug 20, 2019


* OpenEmbedded / webOS OSE, see [ alternate instructions ](https://github.com/ros/meta-ros/wiki/OpenEmbedded-Build-Instructions)


In Development


Caveat: If environment variables (e.g., PATH) are changed after first usage,
before next usage, they are overwritten.


    * [ Learning Pathways  ](https://resources.github.com/learn/pathways/)
    * [ White papers, Ebooks, Webinars  ](https://resources.github.com/)
    * [ Customer Stories ](/customer-stories)
    * [ Partners  ](https://partner.github.com/)


Seen: **2,101 times**


  * [ Code  ](/ros2/ros2)
  * [ Issues  129  ](/ros2/ros2/issues)
  * [ Pull requests  2  ](/ros2/ros2/pulls)
  * [ Actions  ](/ros2/ros2/actions)
  * [ Security  ](/ros2/ros2/security)
  * [ Insights  ](/ros2/ros2/pulse)


* [ Login ](/action/login/ROS/Tutorials/InstallingandConfiguringROSEnvironment?action=login)


Copy link


[ ROS 2 Documentation: Eloquent ![Logo](../_static/eloquent-small.png)
](../index.html)


Member


* NVIDIA Jetson Nano/Ubuntu18.04/Eloquent


If I may chip in: If I build my ros2 workspace (274 pkgs) in isolation on my
2016 macbook pro, sourcing the workspace takes more than 20 seconds.


sudo apt-get install python-rosinstall


**[ hdino ](/hdino) ** commented  May 5, 2020


[ Why there is no timestamp field in sensor_msgs ? ](/question/338345/why-
there-is-no-timestamp-field-in-sensor_msgs/)


👍  10  kelvin-sudani, Tutorgaming, EricCousineau-TRI, fabianschilling,
TakeshiKishita, comran, carlosjoserg, svaichu, UmutDumandag, and ZhenshengLee
reacted with thumbs up emoji


Since sourcing the setup files of other workspaces is as slow as the main
setup, I extended my script to allow sourcing those as well: [
ros2_quick_setup.sh
](https://github.com/BAMresearch/ros2_tools/blob/master/ros2_quick_setup.sh)


**Have a question about this project?** Sign up for a free GitHub account to
open an issue and contact its maintainers and the community.


Please note: ROS Answers requires javascript to work properly, please enable
javascript in your browser, [ here is how
](https://www.google.com/support/bin/answer.py?answer=23852)


To configure CMake to detect and use Clang:


Sorry, something went wrong.


    * [ Writing an action server and client (Python) ](../Tutorials/Actions/Writing-a-Py-Action-Server-Client.html)
    * [ Developing a ROS 2 package ](../Tutorials/Developing-a-ROS-2-Package.html)
    * [ Using colcon to build packages ](../Tutorials/Colcon-Tutorial.html)
    * [ ament_cmake user documentation ](../Tutorials/Ament-CMake-Documentation.html)
    * [ Launching/monitoring multiple nodes with Launch ](../Tutorials/Launch-system.html)
    * [ Passing ROS arguments to nodes via the command-line ](../Tutorials/Node-arguments.html)
    * [ Introspection with command line tools ](../Tutorials/Introspection-with-command-line-tools.html)
    * [ Overview and usage of RQt ](../Tutorials/RQt-Overview-Usage.html)
      * [ Building RQt from source ](../Tutorials/RQt-Source-Install.html)
        * [ Building RQt from source on macOS ](../Tutorials/RQt-Source-Install-MacOS.html)
        * [ Building RQt from source on Windows 10 ](../Tutorials/RQt-Source-Install-Windows10.html)
    * [ Composing multiple nodes in a single process ](../Tutorials/Composition.html)
    * [ Overriding QoS Policies For Recording And Playback ](../Tutorials/Ros2bag/Overriding-QoS-Policies-For-Recording-And-Playback.html)
    * [ Synchronous vs. asynchronous service clients ](../Tutorials/Sync-Vs-Async.html)
    * [ Working with multiple ROS 2 middleware implementations ](../Tutorials/Working-with-multiple-RMW-implementations.html)
    * [ On the mixing of ament and catkin (catment) ](../Tutorials/catment.html)
    * [ Cross-compilation ](../Tutorials/Cross-compilation.html)
    * [ Implement a custom memory allocator ](../Tutorials/Allocator-Template-Tutorial.html)
    * [ Releasing a ROS 2 package with bloom ](../Tutorials/Releasing-a-ROS-2-package-with-bloom.html)
    * [ Porting RQt plugins to Windows ](../Tutorials/RQt-Port-Plugin-Windows.html)
    * [ Running 2 nodes in a single docker container [community-contributed] ](../Tutorials/Run-2-nodes-in-a-single-docker-container.html)
    * [ Running 2 nodes in 2 separate docker containers [community-contributed] ](../Tutorials/Run-2-nodes-in-two-separate-docker-containers.html)
    * [ ROS2 on IBM Cloud Kubernetes [community-contributed] ](../Tutorials/Deploying-ROS-2-on-IBM-Cloud.html)
    * [ Migrating launch files from ROS 1 to ROS 2 ](../Tutorials/Launch-files-migration-guide.html)
    * [ Eclipse Oxygen with ROS 2 and rviz2 [community-contributed] ](../Tutorials/Eclipse-Oxygen-with-ROS-2-and-rviz2.html)
    * [ Building ROS 2 on Linux with Eclipse Oxygen [community-contributed] ](../Tutorials/Building-ROS-2-on-Linux-with-Eclipse-Oxygen.html)
    * [ Building realtime Linux for ROS 2 [community-contributed] ](../Tutorials/Building-Realtime-rt_preempt-kernel-for-ROS-2.html)
    * [ Migrating YAML parameter files from ROS 1 to ROS 2 ](../Tutorials/Parameters-YAML-files-migration-guide.html)
    * [ Use quality-of-service settings to handle lossy networks ](../Tutorials/Quality-of-Service.html)
    * [ Management of nodes with managed lifecycles ](../Tutorials/Managed-Nodes.html)
    * [ Efficient intra-process communication ](../Tutorials/Intra-Process-Communication.html)
    * [ Recording and playback of topic data with rosbag using the ROS 1 bridge ](../Tutorials/Rosbag-with-ROS1-Bridge.html)
    * [ Using tf2 with ROS 2 ](../Tutorials/tf2.html)
    * [ Using URDF with robot_state_publisher ](../Tutorials/URDF/Using-URDF-with-Robot-State-Publisher.html)
    * [ Real-time programming in ROS 2 ](../Tutorials/Real-Time-Programming.html)
    * [ Trying the dummy robot demo ](../Tutorials/dummy-robot-demo.html)
    * [ Logging and logger configuration demo ](../Tutorials/Logging-and-logger-configuration.html)
  * [ Concepts ](../Concepts.html)
    * [ About different ROS 2 DDS/RTPS vendors ](../Concepts/DDS-and-ROS-middleware-implementations.html)
    * [ About Quality of Service settings ](../Concepts/About-Quality-of-Service-Settings.html)


* Build the code in the workspace


None yet


1. If you installed your workspace with colcon as instructed above, âuninstallingâ could be just a matter of opening a new terminal and not sourcing the workspaceâs ` setup  ` file. This way, your environment will behave as though there is no Eloquent install on your system.


    $ mkdir -p ~/catkin_ws/src
    $ cd ~/catkin_ws/
    $ catkin_make


Copy link


Clear


##  Install ROS


[ ![@dirk-
thomas](https://avatars.githubusercontent.com/u/1335366?s=80&u=ec35ea6bae7c6e04a5df7482044bbc7681968435&v=4)
](/dirk-thomas)


[
![@richichiare](https://avatars.githubusercontent.com/u/43334081?s=80&u=3539ff923f24468fa75f807a7b95ff668182a45f&v=4)
](/richichiare)


All reactions


[ Unable to build sim_ros2_interface for CoppeliaSim
](/question/409032/unable-to-build-sim_ros2_interface-for-coppeliasim/)


* Clang


(copy-pasta'd ` bash-isolate ` from my gist, [
https://gist.github.com/EricCousineau-
TRI/6870970d68f75d23061177a52932a5d1#file-bash_helper_functions-sh-L34
](https://gist.github.com/EricCousineau-
TRI/6870970d68f75d23061177a52932a5d1#file-bash_helper_functions-sh-L34) )

---

All reactions


[ Powered by Askbot version 0.10.2 ](http://askbot.com)


  2. If youâre also trying to free up space, you can delete the entire workspace directory with:

        rm -rf ~/ros2_eloquent


##  System requirements  ï


Member


Assignees


You can’t perform that action at this time.


**[ LouisChen1905 ](/LouisChen1905) ** commented  Mar 18, 2020


     ➭ time source install/local_setup.bash
    not found: "/Users/karsten/workspace/osrf/ros2_full/install/share/rttest/local_setup.sh"
    not found: "/Users/karsten/workspace/osrf/ros2_full/install/share/rttest/local_setup.bash"
    not found: "/Users/karsten/workspace/osrf/ros2_full/install/share/tlsf/local_setup.sh"
    not found: "/Users/karsten/workspace/osrf/ros2_full/install/share/tlsf/local_setup.bash"
    not found: "/Users/karsten/workspace/osrf/ros2_full/install/share/tlsf_cpp/local_setup.sh"
    not found: "/Users/karsten/workspace/osrf/ros2_full/install/share/tlsf_cpp/local_setup.bash"
    not found: "/Users/karsten/workspace/osrf/ros2_full/install/share/pendulum_control/local_setup.sh"
    not found: "/Users/karsten/workspace/osrf/ros2_full/install/share/pendulum_control/local_setup.bash"

    real	0m9.085s
    user	0m4.685s
    sys	0m3.311s

---

All reactions


* 👍  3 reactions


  * [ Installation ](../Installation.html)
    * Building ROS 2 on Linux
    * [ Installing ROS 2 on Linux ](Linux-Install-Binary.html)
    * [ Installing ROS 2 via Debian Packages ](Linux-Install-Debians.html)
    * [ Building ROS 2 on macOS ](macOS-Development-Setup.html)
    * [ Installing ROS 2 on macOS ](macOS-Install-Binary.html)
    * [ Building ROS 2 on Windows ](Windows-Development-Setup.html)
    * [ Installing ROS 2 on Windows ](Windows-Install-Binary.html)
    * [ Building ROS 2 on Fedora Linux ](Fedora-Development-Setup.html)
    * [ Installing the latest ROS 2 development ](Latest-Development-Setup.html)
    * [ Maintaining a source checkout of ROS 2 ](Maintaining-a-Source-Checkout.html)
    * [ Pre-release Testing ](Prerelease-Testing.html)
    * [ Installing DDS implementations ](DDS-Implementations.html)
      * [ Installing Connext security plugins ](DDS-Implementations/Install-Connext-Security-Plugins.html)
      * [ Installing University or Evaluation versions of RTI Connext DDS ](DDS-Implementations/Install-Connext-University-Eval.html)
      * [ Working with Eclipse Cyclone DDS ](DDS-Implementations/Working-with-Eclipse-CycloneDDS.html)
  * [ Tutorials ](../Tutorials.html)
    * [ Configuring your ROS 2 environment ](../Tutorials/Configuring-ROS2-Environment.html)
    * [ Introducing turtlesim and rqt ](../Tutorials/Turtlesim/Introducing-Turtlesim.html)
    * [ Understanding ROS 2 nodes ](../Tutorials/Understanding-ROS2-Nodes.html)
    * [ Understanding ROS 2 topics ](../Tutorials/Topics/Understanding-ROS2-Topics.html)
    * [ Understanding ROS 2 services ](../Tutorials/Services/Understanding-ROS2-Services.html)
    * [ Understanding ROS 2 parameters ](../Tutorials/Parameters/Understanding-ROS2-Parameters.html)
    * [ Understanding ROS 2 actions ](../Tutorials/Understanding-ROS2-Actions.html)
    * [ Using rqt_console ](../Tutorials/Rqt-Console/Using-Rqt-Console.html)
    * [ Creating a launch file ](../Tutorials/Launch-Files/Creating-Launch-Files.html)
    * [ Recording and playing back data ](../Tutorials/Ros2bag/Recording-And-Playing-Back-Data.html)
    * [ Creating a workspace ](../Tutorials/Workspace/Creating-A-Workspace.html)
    * [ Creating your first ROS 2 package ](../Tutorials/Creating-Your-First-ROS2-Package.html)
    * [ Writing a simple publisher and subscriber (C++) ](../Tutorials/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html)
    * [ Writing a simple publisher and subscriber (Python) ](../Tutorials/Writing-A-Simple-Py-Publisher-And-Subscriber.html)
    * [ Writing a simple service and client (C++) ](../Tutorials/Writing-A-Simple-Cpp-Service-And-Client.html)
    * [ Writing a simple service and client (Python) ](../Tutorials/Writing-A-Simple-Py-Service-And-Client.html)
    * [ Creating custom ROS 2 msg and srv files ](../Tutorials/Custom-ROS2-Interfaces.html)
    * [ Expanding on ROS 2 interfaces ](../Tutorials/Single-Package-Define-And-Use-Interface.html)
    * [ Using parameters in a class (C++) ](../Tutorials/Using-Parameters-In-A-Class-CPP.html)
    * [ Using parameters in a class (Python) ](../Tutorials/Using-Parameters-In-A-Class-Python.html)
    * [ Getting started with ros2doctor ](../Tutorials/Getting-Started-With-Ros2doctor.html)
    * [ Creating an action ](../Tutorials/Actions/Creating-an-Action.html)
    * [ Writing an action server and client (C++) ](../Tutorials/Actions/Writing-a-Cpp-Action-Server-Client.html)


[ ![@felixendres](https://avatars.githubusercontent.com/u/6112784?s=80&v=4)
](/felixendres)


##  #  Video Streaming


  ///
  /// comLinkName: The link associated with the center of mass of the vehicle.
  /// That is, the origin of the center of mass may not be on this link, but
  /// this link and the center of mass frame have a fixed transform. Almost
  /// always this should be the base_link of the vehicle. This is a required
  /// parameter.
  ///
  /// velocityGain (x, y, z): Proportional gain on linear velocity.
  /// attitudeGain (roll, pitch, yaw): Proportional gain on attitude. This
  /// parameter is scaled by the inverse of the inertia matrix so two vehicles
  /// with different inertial characteristics may have the same gain if other
  /// parameters, such as the forceConstant, are kept the same. This is a
  /// required parameter.
  ///
  /// angularRateGain (roll, pitch, yaw): Proportional gain on angular velocity.
  /// Even though only the yaw angle velocity is controlled, proper gain values
  /// for roll and pitch velocities must be specified. This parameter is scaled
  /// by the inverse of the inertia matrix so two vehicles with different
  /// inertial characteristics may have the same gain if other parameters, such
  /// as the forceConstant, are kept the same. This is a required parameter.
  ///
  /// maxLinearAcceleration (x, y, z): Maximum limit on linear acceleration.
  /// The default value is DBL_MAX.
  ///
  /// maximumLinearVelocity (x, y, z): Maximum commanded linear velocity. The
  /// default value is DBL_MAX.
  /// maximumAngularVelocity (roll, pitch, yaw): Maximum commanded angular
  /// velocity. The default value is DBL_MAX.
  ///
  /// linearVelocityNoiseMean (x, y, z): Mean of Gaussian noise on linear
  /// velocity values obtained from simulation. The default value is (0, 0, 0).
  ///
  /// linearVelocityNoiseStdDev (x, y, z): Standard deviation of Gaussian noise
  /// on linear values obtained from simulation. A value of 0 implies noise is
  /// NOT applied to the component. The default value is (0, 0, 0).
  ///
  /// angularVelocityNoiseMean (roll, pitch, yaw): Mean of Gaussian noise on
  /// angular velocity values obtained from simulation. The default value is (0,
  /// 0, 0).
  ///


gz topic -e -t "/model/x3/odometry"


Listen to odometry:


To simulate wind speed, add this plugin to your world file and replace `
SET_YOUR_WIND_SPEED ` with the desired speed:


To hover


      <plugin filename="gz-sim-multicopter-motor-model-system"
        name="gz::sim::systems::MulticopterMotorModel">
        <robotNamespace>X4</robotNamespace>
        <jointName>rotor_0_joint</jointName>
        <linkName>rotor_0</linkName>
        <turningDirection>ccw</turningDirection>
        <timeConstantUp>0.0182</timeConstantUp>
        <timeConstantDown>0.0182</timeConstantDown>
        <maxRotVelocity>1000.0</maxRotVelocity>
        <motorConstant>1.269e-05</motorConstant>
        <momentConstant>0.016754</momentConstant>
        <commandSubTopic>command/motor_speed</commandSubTopic>
        <actuator_number>0</actuator_number>
        <rotorDragCoefficient>2.0673e-04</rotorDragCoefficient>
        <rotorDragCoefficient>0</rotorDragCoefficient>
        <rollingMomentCoefficient>0</rollingMomentCoefficient>
        <motorSpeedPubTopic>motor_speed/0</motorSpeedPubTopic>
        <rotorVelocitySlowdownSim>2</rotorVelocitySlowdownSim>
        <motorType>velocity</motorType>
      </plugin>
      <plugin filename="gz-sim-multicopter-motor-model-system"
        name="gz::sim::systems::MulticopterMotorModel">
        <robotNamespace>X4</robotNamespace>
        <jointName>rotor_1_joint</jointName>
        <linkName>rotor_1</linkName>
        <turningDirection>cw</turningDirection>
        <timeConstantUp>0.0182</timeConstantUp>
        <timeConstantDown>0.0182</timeConstantDown>
        <maxRotVelocity>1000.0</maxRotVelocity>
        <motorConstant>1.269e-05</motorConstant>
        <momentConstant>0.016754</momentConstant>
        <commandSubTopic>command/motor_speed</commandSubTopic>
        <actuator_number>1</actuator_number>
        <rotorDragCoefficient>2.0673e-04</rotorDragCoefficient>
        <rotorDragCoefficient>0</rotorDragCoefficient>
        <rollingMomentCoefficient>0</rollingMomentCoefficient>
        <motorSpeedPubTopic>motor_speed/1</motorSpeedPubTopic>
        <rotorVelocitySlowdownSim>2</rotorVelocitySlowdownSim>
        <motorType>velocity</motorType>
      </plugin>


You can also specify the full path to a world to load using the `
PX4_SITL_WORLD ` environment variable. This is useful if testing a new world
that is not yet included with PX4.


This approach significantly reduces the debug cycle time because simulator
(e.g. Gazebo) is always running in background and you only re-run the px4
process which is very light.


add a comment
1 AnswerSort by »oldestnewestmost voted
0
answered Mar 23 '18


First time here? Check out the FAQ!


_Gstreamer 1.0_ is required for video streaming. The required dependencies
should already have been  installed when you set up Gazebo  (they are included
in the standard PX4 installation scripts/instructions for macOS and Ubuntu
Linux).


Docs  Docs


  * Starting PX4 and Gazebo separately  so that you can keep Gazebo running and only re-launch PX4 when needed (quicker than restarting both).
  * Run the simulation in  Headless Mode  , which does not start the Gazebo UI (this uses fewer resources and is much faster).


The console will print out status as PX4 loads the airframe-specific
initialisation and parameter files, waits for (and connects to) the simulator.
Once there is an INFO print that [ecl/EKF] is ` commencing GPS fusion ` the
vehicle is ready to arm.


[ Simulate Failsafes ](/v1.12/en/simulation/failsafes.html) explains how to
trigger safety failsafes like GPS failure and battery drain.


###  #  Using a Joystick


This can cause difficulty when using a distance sensor. If there are
unexpected results we recommend you change the model in **iris.model** from `
uneven_ground ` to ` asphalt_plane ` .


    ______  __   __    ___
    | ___ \ \ \ / /   /   |
    | |_/ /  \ V /   / /| |
    |  __/   /   \  / /_| |
    | |     / /^\ \ \___  |
    \_|     \/   \/     |_/
    px4 starting.
    INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
    INFO  [param] selected parameter default file eeprom/parameters_10016
    [param] Loaded: eeprom/parameters_10016
    INFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
    INFO  [simulator] Waiting for simulator to connect on TCP port 4560
    Gazebo multi-robot simulator, version 9.0.0
    Copyright (C) 2012 Open Source Robotics Foundation.
    Released under the Apache 2 License.
    http://gazebosim.org
    ...
    INFO  [ecl/EKF] 5188000: commencing GPS fusion


PX4  PX4


    <include>
      <uri>
        https://fuel.gazebosim.org/1.0/OpenRobotics/models/X3 UAV/4
      </uri>
      <plugin
        filename="gz-sim-multicopter-motor-model-system"
        name="gz::sim::systems::MulticopterMotorModel">
        <robotNamespace>X3</robotNamespace>
        <jointName>X3/rotor_0_joint</jointName>
        <linkName>X3/rotor_0</linkName>
        <turningDirection>ccw</turningDirection>
        <timeConstantUp>0.0125</timeConstantUp>
        <timeConstantDown>0.025</timeConstantDown>
        <maxRotVelocity>800.0</maxRotVelocity>
        <motorConstant>8.54858e-06</motorConstant>
        <momentConstant>0.016</momentConstant>
        <commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
        <actuator_number>0</actuator_number>
        <rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
        <rollingMomentCoefficient>1e-06</rollingMomentCoefficient>
        <motorSpeedPubTopic>motor_speed/0</motorSpeedPubTopic>
        <rotorVelocitySlowdownSim>10</rotorVelocitySlowdownSim>
        <motorType>velocity</motorType>
      </plugin>
      <plugin
        filename="gz-sim-multicopter-motor-model-system"
        name="gz::sim::systems::MulticopterMotorModel">
        <robotNamespace>X3</robotNamespace>
        <jointName>X3/rotor_1_joint</jointName>
        <linkName>X3/rotor_1</linkName>
        <turningDirection>ccw</turningDirection>
        <timeConstantUp>0.0125</timeConstantUp>
        <timeConstantDown>0.025</timeConstantDown>
        <maxRotVelocity>800.0</maxRotVelocity>
        <motorConstant>8.54858e-06</motorConstant>
        <momentConstant>0.016</momentConstant>
        <commandSubTopic>gazebo/command/motor_speed</commandSubTopic>
        <actuator_number>1</actuator_number>
        <rotorDragCoefficient>8.06428e-05</rotorDragCoefficient>
        <rollingMomentCoefficient>1e-06</rollingMomentCoefficient>


###  #  Simulating Sensor/Hardware Failure


The SDF files are not overwritten on subsequent builds.


Streaming can be paused/restarted using the Gazebo UI _Video ON/OFF_ button..


Run a simulation by starting PX4 SITL and gazebo with the airframe
configuration to load (multicopters, planes, VTOL, optical flow and multi-
vehicle simulations are supported).


###  #  Prerequisites


Note


Vehicle  |  Command
---|---
[ Quadrotor ](/v1.12/en/simulation/gazebo_vehicles.html#quadrotor) |  ` make
px4_sitl gazebo `
[ Quadrotor with Optical Flow
](/v1.12/en/simulation/gazebo_vehicles.html#quadrotor_optical_flow) |  ` make
px4_sitl gazebo_iris_opt_flow `
[ 3DR Solo (Quadrotor) ](/v1.12/en/simulation/gazebo_vehicles.html#3dr_solo) |
` make px4_sitl gazebo_solo `
[ Typhoon H480 (Hexrotor)
](/v1.12/en/simulation/gazebo_vehicles.html#typhoon_h480) (supports video
streaming)  |  ` make px4_sitl gazebo_typhoon_h480 `
[ Standard Plane ](/v1.12/en/simulation/gazebo_vehicles.html#standard_plane) |
` make px4_sitl gazebo_plane `
[ Standard Plane (with catapult launch)
](/v1.12/en/simulation/gazebo_vehicles.html#standard_plane_catapult) |  ` make
px4_sitl gazebo_plane_catapult `
[ Standard VTOL ](/v1.12/en/simulation/gazebo_vehicles.html#standard_vtol) |
` make px4_sitl gazebo_standard_vtol `
[ Tailsitter VTOL ](/v1.12/en/simulation/gazebo_vehicles.html#tailsitter_vtol)
|  ` make px4_sitl gazebo_tailsitter `
[ Ackerman vehicle (UGV/Rover)
](/v1.12/en/simulation/gazebo_vehicles.html#ugv) |  ` make px4_sitl
gazebo_rover `
[ HippoCampus TUHH (UUV: Unmanned Underwater Vehicle)
](/v1.12/en/simulation/gazebo_vehicles.html#uuv) |  ` make px4_sitl
gazebo_uuv_hippocampus `
[ Boat (USV: Unmanned Surface Vehicle)
](/v1.12/en/simulation/gazebo_vehicles.html#usv) |  ` make px4_sitl
gazebo_boat `
[ Cloudship (Airship) ](/v1.12/en/simulation/gazebo_vehicles.html#airship) |
` make px4_sitl gazebo_cloudship `

Note


For the full list of build targets run ` make px4_sitl list_vmd_make_targets `
(and filter on those that start with ` gazebo_ ` ).


    private: Eigen::VectorXd rotorVelocities;
    /// \brief Velocity controller
    private: std::unique_ptr<multicopter_control::LeeVelocityController>
                 velocityController;
    /// \brief Noise parameters read from SDF
    private: multicopter_control::NoiseParameters noiseParameters;
    /// \brief Current command velocity. This velocity is a reference velocity
    /// that the controller will try to maintain. A command of zeros must be
    /// given to stop the vehicle.
    private: std::optional<msgs::Twist> cmdVelMsg;
    /// \brief Maximum commanded linear velocity
    private: math::Vector3d maximumLinearVelocity;
    /// \brief Maximum commanded angular velocity
    private: math::Vector3d maximumAngularVelocity;
    /// \brief Mutex for cmdVelMsg
    private: std::mutex cmdVelMsgMutex;
    /// \brief Rotor velocities message. This is here so we don't allocate
    /// memory every time we publish a message.
    private: msgs::Actuators rotorVelocitiesMsg;
    /// \brief Whether the system has been initialized with valid parameters
    private: bool initialized{false};
    /// \brief Whether the controller is active
    private: std::atomic<bool> controllerActive{true};
  };
  }
}
}
}
#endif


#  #  Gazebo Simulation


The video below shows that the location of the environment is aligned with the
gazebo world:


![QGC Video Streaming Settings for
Gazebo](/v1.12/assets/img/qgc_gazebo_video_stream_udp.47655229.png)


<?xml version="1.0" ?>
<!--
  Multicopter velocity controller demo


To simulate a plane with this camera:


  /// angularVelocityNoiseStdDev (roll, pitch, yaw): Standard deviation of
  /// gaussian noise on angular velocity values obtained from simulation. A
  /// value of 0 implies noise is NOT applied to the component. The default
  /// value is (0, 0, 0).
  ///
  /// rotorConfiguration: This contains a list of `<rotor>` elements for each
  /// rotor in the vehicle. This is a required parameter.
  ///
  ///    rotor: Contains information about a rotor in the vehicle. All the
  ///    elements of `<rotor>` are required parameters.
  ///
  ///      jointName: The name of the joint associated with this rotor.
  ///
  ///      forceConstant: A constant that multiplies with the square of the
  ///      rotor's velocity to compute its thrust.
  ///
  ///      momentConstant: A constant the multiplies with the rotor's thrust to
  ///      compute its moment.
  ///
  ///      direction: Direction of rotation of the rotor. +1 is counterclockwise
  ///      and -1 is clockwise.
  ///
  /// # Examples
  /// See examples/worlds/quadcopter.sdf for a demonstration.
  ///
  class MulticopterVelocityControl
      : public System,
        public ISystemConfigure,
        public ISystemPreUpdate
  {
    /// \brief Constructor
    public: MulticopterVelocityControl() = default;
    // Documentation inherited
    public: void Configure(const Entity &_entity,
                           const std::shared_ptr<const sdf::Element> &_sdf,
                           EntityComponentManager &_ecm,
                           EventManager &_eventMgr) override;
    // Documentation inherited
    public: void PreUpdate(
                const gz::sim::UpdateInfo &_info,


Quadcopter with depth camera


For more information see: [ Simulation > Run Simulation Faster than Realtime
](/v1.12/en/simulation/#simulation_speed) .


  * [ Website  (opens new window)  ](https://px4.io/)
  * [ Support  ](https://docs.px4.io/main/en/contribute/support.html)
  * [ Autopilot Source Code  (opens new window)  ](https://github.com/PX4/PX4-Autopilot)
  * [ Docs Source Code  (opens new window)  ](https://github.com/PX4/PX4-user_guide)


    * If it is present, GPS is enabled. You can disable it by deleting the line: ` <gpsNoise>true</gpsNoise> `
    * If it is not preset GPS is disabled. You can enable it by adding the ` gpsNoise ` element to the ` gps_plugin ` section (as shown above).