├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── catkin ├── create_catkin_tools_ws.bash ├── create_deb_files_for_ros_packages.md ├── package_template │ ├── CMakeLists.txt │ └── package.xml ├── update_eclipse_projects_catkin.sh └── update_eclipse_projects_catkin_tools.sh ├── clion ├── clion_with_ros.txt ├── code_templates │ ├── C File Header.txt │ ├── C Header File.h │ ├── C Source File.cpp │ ├── C++ Class Header.h │ ├── C++ Class.cpp │ └── code_templates.txt └── coding_style │ ├── Default.txt │ ├── Default.xml │ └── ros_coding_style.txt ├── debugging_profiling ├── gdb_overview.txt ├── profiling.txt └── roslaunch_prefixes.txt ├── diagnostics └── diagnostic_tools.md ├── eclipse ├── code_templates │ ├── C++ file comment.txt │ ├── C++ header.h │ ├── C++ source.cpp │ └── notes.txt ├── eclipse_cmake.sh ├── eclipse_plugins.txt ├── eclipse_shortcuts.txt ├── eclipse_with_ros.pptx └── eclipse_with_ros.txt ├── git └── commands.txt ├── hg └── commands.txt ├── package.xml ├── python ├── libraries.md └── library_template │ ├── library_name │ ├── __init__.py │ └── submodule_name.py │ ├── requirements.txt │ └── setup.py ├── ros └── .rosrc ├── ubuntu ├── clock_syncronization.md ├── console_logging.md ├── disks.txt ├── hw_monitoring.md ├── hw_stress_test.md ├── iptables.txt ├── libraries.md ├── mdadm_raid.md ├── network.txt ├── scripts │ └── kill_script.bash ├── ubuntu_20_04_lts.md ├── ubuntu_useful_commands.txt ├── udev_rules.md ├── virtual_monitor.md └── virtual_monitor_with_nvidia_gpu.md └── video └── ffmpeg.txt /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | bin/ 3 | lib/ 4 | msg_gen/ 5 | srv_gen/ 6 | msg/*Action.msg 7 | msg/*ActionFeedback.msg 8 | msg/*ActionGoal.msg 9 | msg/*ActionResult.msg 10 | msg/*Feedback.msg 11 | msg/*Goal.msg 12 | msg/*Result.msg 13 | msg/_*.py 14 | 15 | # Generated by dynamic reconfigure 16 | *.cfgc 17 | /cfg/cpp/ 18 | /cfg/*.py 19 | 20 | # Ignore generated docs 21 | *.dox 22 | *.wikidoc 23 | 24 | # eclipse stuff 25 | .project 26 | .cproject 27 | 28 | # qcreator stuff 29 | CMakeLists.txt.user 30 | 31 | srv/_*.py 32 | *.pcd 33 | *.pyc 34 | qtcreator-* 35 | *.user 36 | 37 | /planning/cfg 38 | /planning/docs 39 | /planning/src 40 | 41 | *~ 42 | 43 | # Emacs 44 | .#* 45 | 46 | # Catkin custom files 47 | CATKIN_IGNORE 48 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(ros_development_tools) 3 | 4 | find_package(catkin REQUIRED) 5 | 6 | catkin_package() 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Carlos Miguel Correia da Costa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ros_development_tools 2 | 3 | Collection of tools and guides targeted for developing ROS nodes 4 | -------------------------------------------------------------------------------- /catkin/create_catkin_tools_ws.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | catkin_ws_dir=${1:-'catkin_ws'} 4 | ros_version=${2:-"$(rosversion -d)"} 5 | extend_ws=${3:-"/opt/ros/$ros_version"} 6 | 7 | echo -e "\n\n\n\n" 8 | echo "####################################################################################################" 9 | echo "##### Creating catkin workspace in [$catkin_ws_dir] using [$ros_version] and extending [$extend_ws]" 10 | echo "####################################################################################################" 11 | 12 | function AddProfile { 13 | catkin config --profile $1 -x _$1 --cmake-args -DCMAKE_BUILD_TYPE=$2 14 | catkin profile set $1 15 | catkin config --extend $3 16 | catkin config --append-args --cmake-args -DCMAKE_CXX_FLAGS="-Wall -W -Wno-unused-parameter -Werror=return-type" 17 | } 18 | 19 | 20 | mkdir -p "$HOME/${catkin_ws_dir}/src" 21 | cd "$HOME/${catkin_ws_dir}" 22 | source "${extend_ws}/setup.bash" 23 | 24 | catkin config --init --no-install --extend ${extend_ws} 25 | AddProfile debug Debug ${extend_ws} 26 | AddProfile release_with_debug_info RelWithDebInfo ${extend_ws} 27 | AddProfile release Release ${extend_ws} 28 | 29 | 30 | 31 | echo -e "\n\n" 32 | echo "----------------------------------------------------------------------------------------------------" 33 | echo ">>>>> catkin workspace initialized" 34 | echo "----------------------------------------------------------------------------------------------------" 35 | -------------------------------------------------------------------------------- /catkin/create_deb_files_for_ros_packages.md: -------------------------------------------------------------------------------- 1 | # Generation of .deb files for ROS packages 2 | 3 | There are several ways to generate deb files for a ROS package: 4 | * [bloom](http://wiki.ros.org/bloom) 5 | * [https://answers.ros.org/question/173804/generate-deb-from-ros-package/?answer=173845#post-id-173845](https://answers.ros.org/question/173804/generate-deb-from-ros-package/?answer=173845#post-id-173845) 6 | * [CheckInstall](https://wiki.debian.org/CheckInstall) 7 | * [dpkg-buildpackage](http://manpages.ubuntu.com/manpages/precise/man1/dpkg-buildpackage.1.html) 8 | * [CPack](https://cmake.org/cmake/help/v3.0/module/CPack.html) 9 | 10 | 11 | ## Bloom 12 | 13 | Install bloom: 14 | ``` 15 | sudo apt-get install python-bloom 16 | sudo apt-get install fakeroot 17 | sudo apt-get install dpkg-dev debhelper 18 | ``` 19 | 20 | * For public release using the ROS build farm, read [this tutorial](http://wiki.ros.org/bloom/Tutorials/FirstTimeRelease) 21 | 22 | * For generating .deb files for packages that have dependencies to packages that are not on the official rosdep lists, read the [rosdep documentation](http://docs.ros.org/independent/api/rosdep/html/contributing_rules.html) and [this readme file](https://github.com/mikeferguson/buildbot-ros/blob/master/documentation/private_repositories.md), that overall state that you need to: 23 | * Create a yaml file (in the workspace containing the packages, for example) specifying the local packages. Example of yaml content: 24 | ``` 25 | package_name: 26 | ubuntu: [ros-kinetic-package-name] 27 | ``` 28 | * Create a file in the rosdep sources folder: 29 | ``` 30 | sudo nano /etc/ros/rosdep/sources.list.d/10-local.list 31 | ``` 32 | * Add to this file the absolute path of the .yaml file created earlier. Example: 33 | ``` 34 | yaml file:///absolute_path_to_local_rosdep_file_list.yaml 35 | ``` 36 | * Update the rosdep: 37 | ``` 38 | rosdep update 39 | ``` 40 | * Check if the new rosdep packages lists are being correctly found using: 41 | ``` 42 | rosdep resolve package_name 43 | ``` 44 | 45 | 46 | ### Generate .deb file 47 | 48 | * Setup the ROS environment variables by sourcing the setup.bash script from your catkin_ws 49 | * cd into the src package folder (where the CMakeLists.txt and package.xml are located) 50 | ``` 51 | cd package_src_folder 52 | ``` 53 | * Check if your package.xml dependencies are in the rosdep database using: 54 | ``` 55 | rosdep update 56 | rosdep check --from-paths . --ignore-src --rosdistro="$(rosversion -d)" 57 | ``` 58 | You can also use: 59 | ``` 60 | rosdep db | grep package_name 61 | ``` 62 | * Generate the configuration files using: 63 | ``` 64 | bloom-generate rosdebian --ros-distro $(rosversion -d) 65 | ``` 66 | * Generate .deb file with [-O2 optimizations](http://wiki.ros.org/bloom/Tutorials/ChangeBuildFlags) 67 | ``` 68 | fakeroot debian/rules binary 69 | ``` 70 | * For speeding up the compilation, you can specify how many CPU cores will be used by the make program, using: 71 | ``` 72 | export DEB_BUILD_OPTIONS="parallel=`nproc`" 73 | ``` 74 | * Then, instead of using the default rules script above, use: 75 | ``` 76 | fakeroot debian/rules "binary --parallel" 77 | ``` 78 | 79 | * The deb file will be added to the package parent directory 80 | 81 | 82 | ### Install .deb file 83 | ``` 84 | sudo dpkg -i path_to_package.deb 85 | ``` 86 | 87 | Be aware that if you install pure CMake packages that were packaged as ROS packages and were installed into /opt/ros, they will override the system packages with the same name and version after you source the ROS setup.bash. 88 | 89 | This approach can be useful for development purposes (project forks for example), in which the system installation of a package remains untouched (PCL for example) and a development version is built and prereleased as a ROS package for making it easier to install by end users. 90 | 91 | However, this should be used with care, because if certain packages are expecting an oficial library .so and then at run time they find an .so that does not have a [compatible ABI](https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html) (because the ROS setup.bash changed the [LD_LIBRARY_PATH](http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html)) and the .so of the fork in /opt/ros was loaded instead of the one at /usr/lib), the program will terminate. 92 | 93 | Check the tutorial at [ubuntu/libraries.md](../ubuntu/libraries.md) for more information. 94 | 95 | 96 | ### Uninstall .deb file 97 | 98 | If later on you need to remove the .deb package, you can find its full name using: 99 | ``` 100 | apt-cache search partial-package-name 101 | ``` 102 | And remove it with: 103 | ``` 104 | sudo apt purge package-name 105 | # or 106 | sudo dpkg --purge package-name 107 | ``` 108 | 109 | Alternatively you can use the [Synaptic GUI](https://help.ubuntu.com/stable/ubuntu-help/addremove-install-synaptic.html.en). 110 | 111 | 112 | ### Update package list 113 | ``` 114 | rospack profile 115 | ``` 116 | 117 | 118 | ### Notes about pre-release steps 119 | 120 | For allowing the end users to know which commit was used to generate each .deb file, you should: 121 | * Modify the [package.xml version tag](https://www.ros.org/reps/rep-0140.html#version) of each package following the [semantic versioning](https://semver.org/) approach 122 | * Check [this tutorial](http://wiki.ros.org/bloom/Tutorials/ReleaseCatkinPackage) if you want to release your package into the ROS build farm 123 | * Create a changelog and commit any remaining changes to each package git repository 124 | * Create a release tag in the git repository of each package 125 | 126 | 127 | ### Notes about compilation of .deb files with dependencies to other .deb files 128 | 129 | For making sure that the packages for which you are generating .deb files are compiling and linking to the same library versions of other packages that have associated .deb files, you should follow this approach: 130 | * Create a list with the packages for which you want to generate .deb files 131 | * Check their dependencies using: 132 | * [rqt_dep](http://wiki.ros.org/rqt_dep) 133 | * [rosdep](https://docs.ros.org/independent/api/rosdep/html/commands.html): 134 | ``` 135 | rosdep keys package_name_1 package_name_2 package_name_3 136 | ``` 137 | * Sort the packages in the proper order for following their compilation dependencies. For automating this step you can use [catkin tools](https://catkin-tools.readthedocs.io/en/latest/verbs/catkin_build.html#previewing-the-build): 138 | ``` 139 | catkin build --dry-run package_name_1 package_name_2 package_name_3 140 | ``` 141 | * Create the rosdep .yaml file specifying the configurations for all the packages that you want to generate .deb files 142 | * Add the .yaml file to the rosdep sources list (check instructions above) 143 | * Then, do the following for each package: 144 | * cd package_folder 145 | * git checkout release_tag 146 | * source /opt/ros/$(rosversion -d)/setup.bash 147 | * rospack profile 148 | * Generate the .deb file using the instructions above 149 | * Install the .deb file using "sudo dpkg -i path_to_package.deb" 150 | -------------------------------------------------------------------------------- /catkin/package_template/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(package_template) 3 | 4 | 5 | ####################################################################################################################### 6 | ## flags 7 | ####################################################################################################################### 8 | 9 | # remove logging (ROSCONSOLE_SEVERITY_NONE=5) 10 | # set(ROS_COMPILE_FLAGS "-DROSCONSOLE_MIN_SEVERITY=5 ${ROS_COMPILE_FLAGS}") 11 | 12 | set(${PROJECT_NAME}_CATKIN_COMPONENTS 13 | roscpp 14 | rosconsole 15 | ) 16 | 17 | 18 | 19 | ####################################################################################################################### 20 | ## packages 21 | ####################################################################################################################### 22 | 23 | find_package(catkin REQUIRED COMPONENTS ${${PROJECT_NAME}_CATKIN_COMPONENTS}) 24 | 25 | 26 | 27 | 28 | ####################################################################################################################### 29 | ## catkin specific configuration 30 | ####################################################################################################################### 31 | 32 | catkin_package( 33 | INCLUDE_DIRS 34 | include 35 | LIBRARIES 36 | # package_template 37 | CATKIN_DEPENDS 38 | ${${PROJECT_NAME}_CATKIN_COMPONENTS} 39 | DEPENDS 40 | ) 41 | 42 | 43 | 44 | ####################################################################################################################### 45 | ## build 46 | ####################################################################################################################### 47 | 48 | #============================================================================== 49 | # includes 50 | #============================================================================== 51 | 52 | include_directories( 53 | include 54 | ${catkin_INCLUDE_DIRS} 55 | ) 56 | 57 | 58 | 59 | #============================================================================== 60 | # libraries 61 | #============================================================================== 62 | 63 | #add_library(package_template 64 | # src/package_template.cpp 65 | #) 66 | 67 | 68 | 69 | #============================================================================== 70 | # executables 71 | #============================================================================== 72 | 73 | #add_executable(package_template_node 74 | # src/package_template_node.cpp 75 | #) 76 | 77 | 78 | 79 | #============================================================================== 80 | # library link 81 | #============================================================================== 82 | 83 | #target_link_libraries(package_template 84 | # ${catkin_LIBRARIES} 85 | #) 86 | 87 | 88 | 89 | #============================================================================== 90 | # executables link 91 | #============================================================================== 92 | 93 | #target_link_libraries(package_template_node 94 | # package_template 95 | # ${catkin_LIBRARIES} 96 | #) 97 | -------------------------------------------------------------------------------- /catkin/package_template/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | package_template 4 | 1.0.0 5 | Package description 6 | Carlos Miguel Correia da Costa 7 | Carlos Miguel Correia da Costa 8 | BSD 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | catkin 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | roscpp 31 | rosconsole 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | roscpp 40 | rosconsole 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /catkin/update_eclipse_projects_catkin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "\n\n\n\n" 4 | echo "####################################################################################################" 5 | echo "##### Updating eclipse projects for catkin workspace" 6 | echo "####################################################################################################" 7 | 8 | cd ~/catkin_ws 9 | catkin_make --force-cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 10 | 11 | 12 | echo "\n\n" 13 | echo "----------------------------------------------------------------------------------------------------" 14 | echo ">>>>> Eclipse catkin_ws projects in ~/catkin_ws/build" 15 | echo "----------------------------------------------------------------------------------------------------" 16 | -------------------------------------------------------------------------------- /catkin/update_eclipse_projects_catkin_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | catkin_ws_dir=${1:-'catkin_ws'} 4 | build_type=${2:-'Release'} # Debug | Release | MinSizeRel | RelWithDebInfo 5 | make_args=${3:-'-j8'} 6 | 7 | echo "\n\n\n\n" 8 | echo "####################################################################################################" 9 | echo "##### Updating eclipse projects for [${catkin_ws_dir}] workspace using [${build_type}] configuration" 10 | echo "####################################################################################################" 11 | 12 | 13 | cd "$HOME/${catkin_ws_dir}" 14 | catkin build --force-cmake --cmake-args -DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=${make_args} -G"Eclipse CDT4 - Unix Makefiles" # -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE 15 | #catkin build --force-cmake --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 -G"Eclipse CDT4 - Unix Makefiles" 16 | #catkin_make --force-cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 17 | 18 | 19 | #cd ~/${catkin_ws_dir}/build 20 | #cmake ../src/ -DCATKIN_DEVEL_SPACE=../devel -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=${make_args} --force-cmake -G"Eclipse CDT4 - Unix Makefiles" 21 | 22 | 23 | echo "\n\n" 24 | echo "----------------------------------------------------------------------------------------------------" 25 | echo ">>>>> Eclipse catkin_ws projects in $HOME/${catkin_ws_dir}/build" 26 | echo "----------------------------------------------------------------------------------------------------" 27 | -------------------------------------------------------------------------------- /clion/clion_with_ros.txt: -------------------------------------------------------------------------------- 1 | http://wiki.ros.org/IDEs#CLion 2 | https://www.jetbrains.com/help/clion/ros-setup-tutorial.html 3 | https://www.jetbrains.com/help/clion/attaching-to-local-process.html 4 | https://github.com/duckietown/hatchery 5 | -------------------------------------------------------------------------------- /clion/code_templates/C File Header.txt: -------------------------------------------------------------------------------- 1 | /**\file ${HEADER_FILENAME} 2 | * \brief Description... 3 | * 4 | * @version 1.0 5 | * @author Carlos Miguel Correia da Costa 6 | */ 7 | -------------------------------------------------------------------------------- /clion/code_templates/C Header File.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #parse("C File Header.h") 4 | 5 | 6 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 7 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 8 | 9 | 10 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 11 | // std includes 12 | 13 | // external libs includes 14 | 15 | // project includes 16 | 17 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 18 | 19 | 20 | 21 | namespace ${PROJECT_NAME} { 22 | 23 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 24 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /clion/code_templates/C Source File.cpp: -------------------------------------------------------------------------------- 1 | #parse("C File Header.h") 2 | 3 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 4 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 5 | 6 | 7 | namespace ${PROJECT_NAME} { 8 | 9 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 10 | 11 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <-functions> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 12 | 13 | } 14 | -------------------------------------------------------------------------------- /clion/code_templates/C++ Class Header.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #parse("C File Header.h") 4 | 5 | 6 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 7 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 8 | 9 | 10 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 11 | // std includes 12 | 13 | // external libs includes 14 | 15 | // project includes 16 | 17 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 18 | 19 | 20 | 21 | namespace ${PROJECT_NAME} { 22 | 23 | // |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ${NAME} ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 24 | /** 25 | * \brief Description... 26 | */ 27 | class ${NAME} { 28 | // ========================================================================== ============================================================================ 29 | public: 30 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 31 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 32 | 33 | 34 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 35 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 36 | 37 | 38 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 39 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 40 | 41 | 42 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 43 | 44 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 45 | 46 | 47 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 48 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 49 | 50 | 51 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 52 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 53 | 54 | 55 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 56 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 57 | // ============================================================================ ========================================================================= 58 | 59 | 60 | // ============================================================================ ======================================================================= 61 | protected: 62 | // ============================================================================ ======================================================================= 63 | }; 64 | 65 | } 66 | -------------------------------------------------------------------------------- /clion/code_templates/C++ Class.cpp: -------------------------------------------------------------------------------- 1 | #parse("C File Header.h") 2 | 3 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 4 | #[[#include]]# <${PROJECT_NAME}/${HEADER_FILENAME}> 5 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 6 | 7 | 8 | namespace ${PROJECT_NAME} { 9 | 10 | // =============================================================================== ============================================================================ 11 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 12 | 13 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 14 | 15 | 16 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 17 | 18 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <-functions> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 19 | // =============================================================================== =========================================================================== 20 | 21 | 22 | // =============================================================================== ======================================================================== 23 | // =============================================================================== ======================================================================== 24 | 25 | } 26 | -------------------------------------------------------------------------------- /clion/code_templates/code_templates.txt: -------------------------------------------------------------------------------- 1 | CLion -> File -> Settings -> Editor -> File and Code Templates -> [Files | Includes] 2 | -------------------------------------------------------------------------------- /clion/coding_style/Default.txt: -------------------------------------------------------------------------------- 1 | CLion -> File -> Settings -> Editor -> Code Style -> C++ -> Gear -> Import Scheme -> XML 2 | 3 | Deviations / improvements in relation to ROS CppStyleGuide: 4 | - Code indentation using tabs instead of 2 spaces 5 | * This way, you can easily change the visible indentation of the code -> some people like 2 spaces, others like 4, ...) 6 | - Function parameters have an underscore prefix (_function_parameter) 7 | * This way it is clear the scope of a variable: 8 | local_stack_variable 9 | _function_parameter 10 | class_member_ 11 | * Support for this will be added in CLion 2019.1 12 | https://blog.jetbrains.com/clion/2019/02/clion-2019-1-eap-naming-conventions/ 13 | - Curly braces on same line as the statement 14 | * Allows more compact code -> less scrolling 15 | - Larger line length wrap (250 instead of 120) 16 | * Programmers usually code on 27+ inches monitors, so larger lines means more compact code -> less scrolling 17 | -------------------------------------------------------------------------------- /clion/coding_style/Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /clion/coding_style/ros_coding_style.txt: -------------------------------------------------------------------------------- 1 | http://wiki.ros.org/CppStyleGuide 2 | https://google.github.io/styleguide/cppguide.html 3 | http://wiki.ros.org/ROS/Patterns/Conventions 4 | http://wiki.ros.org/DevelopersGuide 5 | -------------------------------------------------------------------------------- /debugging_profiling/gdb_overview.txt: -------------------------------------------------------------------------------- 1 | - Add to the node xml tag the option to attach gdb to the node process 2 | (http://wiki.ros.org/roslaunch/Tutorials/Roslaunch%20Nodes%20in%20Valgrind%20or%20GDB) 3 | A -> For having node output in a different terminal 4 | launch-prefix="terminator -mx gdb --args" 5 | B -> For having node output in a different terminal and start without user interaction 6 | launch-prefix="terminator -mx gdb -ex run --args" 7 | C -> For having node output in the same terminal 8 | launch-prefix="gdb --args" 9 | D -> For having node output in the same terminal and start without user interaction 10 | launch-prefix="gdb -ex run --args" 11 | Example: 12 | 13 | 14 | - Debug in GDB 15 | Useful commands 16 | break [file:]function 17 | Set a breakpoint at function (in file) 18 | run [arglist] 19 | Start your program (with arglist, if specified) 20 | bt 21 | Backtrace: display the program stack 22 | print expr 23 | Display the value of an expression 24 | c 25 | Continue running your program (after stopping, e.g. at a breakpoint) 26 | next 27 | Execute next program line (after stopping); step over any function calls in the line 28 | edit [file:]function 29 | look at the program line where it is presently stopped 30 | list [file:]function 31 | type the text of the program in the vicinity of where it is presently stopped 32 | step 33 | Execute next program line (after stopping); step into any function calls in the line 34 | info breakpoints 35 | List breakpoints 36 | info break 37 | List breakpoint numbers. 38 | info break breakpoint-number 39 | List info about specific breakpoint. 40 | info watchpoints 41 | List watchpoints 42 | info registers 43 | List registers in use 44 | info threads 45 | List threads in use 46 | help [name] 47 | Show information about GDB command name, or general information about using GDB 48 | kill 49 | Stop debugging 50 | quit 51 | Exit from GDB 52 | -------------------------------------------------------------------------------- /debugging_profiling/profiling.txt: -------------------------------------------------------------------------------- 1 | http://wiki.ros.org/DevelopersGuide 2 | 3 | ROS profilling: 4 | http://projects.csail.mit.edu/pr2/wiki/index.php?title=Profiling_Code_in_ROS 5 | 6 | 7 | Profilers: 8 | https://perf.wiki.kernel.org/index.php/Tutorial 9 | http://oprofile.sourceforge.net/about/ 10 | http://valgrind.org/info/tools.html 11 | https://sourceware.org/binutils/docs/gprof/ 12 | http://www.embeddedprofiler.com/Profilers_Comparison 13 | https://github.com/carlosmccosta/robot_localization_tools/blob/hydro-devel/tools/process_monitor.sh 14 | 15 | 16 | Qt: 17 | https://wiki.qt.io/Profiling_and_Memory_Checking_Tools 18 | http://doc.qt.io/qtcreator/creator-cache-profiler.html 19 | http://doc.qt.io/qtcreator/creator-analyze-mode.html 20 | http://doc.qt.io/qtcreator/creator-cpu-usage-analyzer.html 21 | 22 | 23 | Eclipse: 24 | http://wiki.eclipse.org/Linux_Tools_Project/PERF/User_Guide 25 | http://wiki.eclipse.org/Linux_Tools_Project/Profiling/User_Guide 26 | https://wiki.eclipse.org/Linux_Tools_Project/GProf/User_Guide 27 | https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Developer_Guide/profiling.html 28 | https://www.eclipsecon.org/2013/sites/eclipsecon.org.2013/files/eclipsecon_profiling_tutorial.pdf 29 | -------------------------------------------------------------------------------- /debugging_profiling/roslaunch_prefixes.txt: -------------------------------------------------------------------------------- 1 | ##################################################################################################################################################### 2 | # Setup 3 | ##################################################################################################################################################### 4 | 5 | sudo apt-get install gdb gdbserver oprofile valgrind 6 | sudo apt-get install linux-tools-`uname -r` # perf 7 | 8 | 9 | 10 | ##################################################################################################################################################### 11 | # Running ROS node within gdb or valgrind (http://wiki.ros.org/roslaunch/Tutorials/Roslaunch%20Nodes%20in%20Valgrind%20or%20GDB) 12 | ##################################################################################################################################################### 13 | 14 | *************************************************************************************************** 15 | // Attach gdbserver to ROS node 16 | // Allows remote debugging 17 | // -> http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_debug_a_remote_application.3F 18 | // -> http://doc.qt.io/qtcreator/creator-debugger-operating-modes.html 19 | launch-prefix="gdbserver localhost:1337" 20 | 21 | 22 | 23 | *************************************************************************************************** 24 | // Attach gdb to ROS node 25 | launch-prefix="terminator -mx gdb -ex run --args" 26 | 27 | 28 | 29 | *************************************************************************************************** 30 | // Attach perf to ROS node 31 | // Output in ~/.ros/ 32 | // Compile node with -DCMAKE_BUILD_TYPE=RelWithDebInfo for easier results analysis 33 | // add -fno-omit-frame-pointer to CXXFLAGS if you need to record call graphs 34 | catkin config --append-args --cmake-args -DCMAKE_CXX_FLAGS="-fno-omit-frame-pointer" 35 | if you already have -DCMAKE_CXX_FLAGS defined use the command bellow to remove existing configuration (and add the existing flags to the command above) 36 | catkin config --remove-args -DCMAKE_CXX_FLAGS="..." 37 | 38 | # light profiling 39 | launch-prefix="perf record --verbose --output=perf.out.node_name.data --" 40 | 41 | # profiling with call stack calls 42 | launch-prefix="perf record -g --output=perf.out.node_name.data --" 43 | 44 | # profiling with detailed call stack calls 45 | launch-prefix="perf record -g --call-graph dwarf --output=perf.out.node_name.data --" 46 | 47 | # verbose profiling 48 | launch-prefix="perf record --verbose -g --call-graph dwarf --output=perf.out.node_name.data --" 49 | 50 | # setup required if used with --all-cpus flag (system wide profiling) 51 | sudo su 52 | echo 0 > /proc/sys/kernel/kptr_restrict 53 | echo -1 > /proc/sys/kernel/perf_event_paranoid 54 | 55 | 56 | -------------------------- 57 | // Analyse profile results 58 | 59 | # For light profiling 60 | perf report --show-nr-samples --verbose --input=perf.out.node_name.data 61 | 62 | # With call graph 63 | perf report --show-nr-samples --verbose --show-total-period -g 'graph,0.5,callee' --input=perf.out.node_name.data 64 | perf report --show-nr-samples --verbose --show-total-period -g 'fractal,0.5,callee' --input=perf.out.node_name.data 65 | 66 | # For CSV output 67 | perf report --show-nr-samples --verbose --field-separator=, --show-total-period --show-info --group --demangle --stdio --input=perf.out.node_name.data > perf.out.node_name.data.csv 68 | 69 | # Source code with profilling info 70 | perf annotate --source --input=perf.out.node_name.data [function/symbol name to annotate] 71 | 72 | # TUI Shortcuts 73 | a -> show timers alonside code (annotate) 74 | 75 | 76 | 77 | *************************************************************************************************** 78 | // Attach operf to ROS node 79 | // Output in ~/.ros/ 80 | // Use to see profile results 81 | launch-prefix="operf --callgraph --lazy-conversion" 82 | 83 | -------------------------- 84 | // Analyse profile results 85 | 86 | # Report with call graph 87 | opreport --debug-info --demangle smart --callgraph --global-percent --output-file oprofile_report.txt 88 | 89 | # Source code with profilling info 90 | opannotate --source --demangle smart --output-dir oprofile_annotate 91 | 92 | 93 | 94 | *************************************************************************************************** 95 | // Attach callgrind to ROS node for profilling 96 | // Output file in ~/.ros/ Can be opened with http://kcachegrind.sourceforge.net/html/Home.html 97 | launch-prefix="terminator -mx valgrind --tool=callgrind --callgrind-out-file=callgrind.out.node_name.%p" 98 | 99 | 100 | 101 | *************************************************************************************************** 102 | // Attach massif to ROS node to monitor memory usage 103 | // Output file in ~/.ros/ 104 | launch-prefix="terminator -mx valgrind --tool=massif --heap=yes --stacks=yes --massif-out-file=massif.out.node_name.%p" 105 | 106 | 107 | 108 | *************************************************************************************************** 109 | // Attach memcheck to ROS node to check for memory leaks 110 | // Output file in ~/.ros/ 111 | launch-prefix="terminator -mx valgrind --tool=memcheck --leak-check=full --show-reachable=yes -v --track-origins=yes --log-file=memcheck.out.node_name.%p" 112 | 113 | 114 | 115 | ----------------------------------------------------------------------------------------------------------------------------------------------------- 116 | // To execute the nodes in a different window, prepend terminator -mx to the launch prefixes commands 117 | // Example: 118 | // Attach gdb to ROS node in a different console window 119 | launch-prefix="terminator -mx gdb -ex run --args" 120 | 121 | // Run ROS node in different window to isolate its output from the other nodes 122 | launch-prefix="terminator -mx" 123 | -------------------------------------------------------------------------------- /diagnostics/diagnostic_tools.md: -------------------------------------------------------------------------------- 1 | # Diagnostic tools 2 | 3 | List of [diagnostic tools](https://www.trentonsystems.com/blog/list-of-computer-stress-test-software). 4 | 5 | 6 | ## RAM 7 | 8 | Create a bootable usb with [memtest](https://www.memtest86.com/) for checking if RAM is [working properly](https://www.memtest86.com/troubleshooting.htm). 9 | 10 | 11 | ## Disks 12 | 13 | Perform a low level format of the hard drive before usage and check for the SMART data diagnostics and bad blocks 14 | 15 | * Linux 16 | * [GParted](https://gparted.org/) 17 | * [GnomeDisks](https://help.gnome.org/users/gnome-help/stable/disk-check.html.en) 18 | * [badblocks](https://wiki.archlinux.org/index.php/Badblocks) 19 | * Windows 20 | * [EaseUS Partition Master](https://www.easeus.com/partition-manager/epm-free.html) 21 | * [CrystalDiskInfo](https://crystalmark.info/en/software/crystaldiskinfo/crystaldiskinfo-smart-information/) 22 | 23 | 24 | ## CPU 25 | 26 | Perform a stress test on the CPU. 27 | 28 | * Linux: 29 | * [stress-ng](https://wiki.ubuntu.com/Kernel/Reference/stress-ng) 30 | * [System profiler and benchmark](https://github.com/lpereira/hardinfo) 31 | * Windows: 32 | * [Intel® Processor Diagnostic Tool](https://www.intel.com/content/www/us/en/support/articles/000005567/processors.html) 33 | * [Intel® Extreme Tuning Utility](https://downloadcenter.intel.com/download/24075/Intel-Extreme-Tuning-Utility-Intel-XTU-) 34 | 35 | 36 | ## GPU 37 | 38 | Perform a stress test on the GPU. 39 | * [Unigine benchmark](https://benchmark.unigine.com) 40 | 41 | 42 | ## System monitoring 43 | 44 | * Linux 45 | * [psensor](http://wpitchoune.net/psensor) 46 | * [htop](https://github.com/hishamhm/htop) 47 | * [Monitorix](https://www.monitorix.org) 48 | * Windows 49 | * [Open Hardware Monitor](https://openhardwaremonitor.org) 50 | * [HWMonitor](https://www.cpuid.com/softwares/hwmonitor.html) 51 | * [OCCT](https://www.ocbase.com) 52 | -------------------------------------------------------------------------------- /eclipse/code_templates/C++ file comment.txt: -------------------------------------------------------------------------------- 1 | /**\file ${file_name} 2 | * \brief Description... 3 | * 4 | * @version 1.0 5 | * @author ${user} 6 | */ 7 | -------------------------------------------------------------------------------- /eclipse/code_templates/C++ header.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | ${filecomment} 4 | 5 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 6 | ${includes} 7 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 8 | 9 | 10 | 11 | ${namespace_begin} 12 | // ############################################################################## ${type_name} ############################################################################# 13 | /** 14 | * \brief Description... 15 | */ 16 | class ${type_name} { 17 | // ======================================================================== =========================================================================== 18 | public: 19 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 20 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 21 | 22 | 23 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 24 | ${declarations} 25 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 26 | 27 | 28 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30 | 31 | 32 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 33 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 34 | 35 | 36 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 37 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 38 | // ======================================================================== =========================================================================== 39 | 40 | 41 | // ======================================================================== ======================================================================== 42 | protected: 43 | // ======================================================================== ======================================================================== 44 | }; 45 | 46 | ${namespace_end} 47 | -------------------------------------------------------------------------------- /eclipse/code_templates/C++ source.cpp: -------------------------------------------------------------------------------- 1 | ${filecomment} 2 | 3 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 4 | ${includes} 5 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 6 | 7 | 8 | ${namespace_begin} 9 | 10 | 11 | // ============================================================================= ============================================================================ 12 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 13 | ${declarations} 14 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 15 | 16 | 17 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 18 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 19 | // ============================================================================= =========================================================================== 20 | 21 | 22 | // ============================================================================= ======================================================================= 23 | // ============================================================================= ======================================================================= 24 | 25 | ${namespace_end} 26 | -------------------------------------------------------------------------------- /eclipse/code_templates/notes.txt: -------------------------------------------------------------------------------- 1 | ######################################################################################################################## 2 | # »»»»» Eclipse code templates for C++ 3 | ######################################################################################################################## 4 | 5 | Eclipse code templates allow automatic insertion of file / class / function layouts. 6 | It is useful to keep the programming style consistent. 7 | 8 | 9 | ########## 10 | # To change C++ code templates in eclipse 11 | Window -> Preferences -> C/C++ -> Code Style -> Code Templates 12 | 13 | 14 | »»»»» [C++ file comment.txt] 15 | Comments -> Files 16 | 17 | »»»»» [C++ header.h] 18 | Files -> C++ Header File -> Default C++ header template 19 | 20 | »»»»» [C++ source.cpp] 21 | Files -> C++ Source File -> Default C++ source template 22 | 23 | 24 | ########## 25 | # To change C++ naming style for variables, functions, classes, files... 26 | Window -> Preferences -> C/C++ -> Code Style -> Name Style 27 | 28 | 29 | ======================================================================================================================== 30 | # »»»»» Useful links 31 | ======================================================================================================================== 32 | 33 | http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml 34 | 35 | http://wiki.ros.org/CppStyleGuide 36 | http://wiki.ros.org/ROS/Patterns/Conventions 37 | http://wiki.ros.org/DevelopersGuide 38 | http://wiki.ros.org/IDEs 39 | 40 | http://jbohren.com/articles/gentle-catkin-intro/ 41 | http://jbohren.com/articles/modular-ros-packages/ -------------------------------------------------------------------------------- /eclipse/eclipse_cmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | build_dir=${1:-"$HOME/catkin_ws/build"} 4 | source_dir=${2:-"$HOME/catkin_ws/src"} 5 | build_type=${3:-'Release'} # Debug | Release | MinSizeRel | RelWithDebInfo 6 | eclipse_version=${4:-'4.6'} 7 | make_args=${5:-'-j8'} 8 | 9 | cd "${build_dir}" 10 | cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=${make_args} -DCMAKE_ECLIPSE_VERSION=${eclipse_version} "${source_dir}" 11 | -------------------------------------------------------------------------------- /eclipse/eclipse_plugins.txt: -------------------------------------------------------------------------------- 1 | ======================================================================================================================== 2 | # »»»»» Notes 3 | ======================================================================================================================== 4 | --> Plugins in eclipse can either be installed by: 5 | - Searching in the marketplace 6 | - Help -> Eclipse Marketplace 7 | - Using external repositories 8 | - Help -> Install New Software -> Select repository or add a new one 9 | 10 | --> For ROS development is recommended to use the package 11 | Eclipse IDE for C/C++ Developers 12 | from http://www.eclipse.org/downloads/ 13 | 14 | 15 | 16 | ######################################################################################################################## 17 | # »»»»» GDB stl pretty printers 18 | ######################################################################################################################## 19 | 20 | »»»»» For pretty printing stl containers when debugging with gdb 21 | Info: 22 | https://sourceware.org/gdb/wiki/STLSupport 23 | http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_inspect_the_contents_of_STL_containers.3F 24 | 25 | # Checkout python modules for gdb pretty printing 26 | cd ~/ 27 | mkdir gdb_pretty_printers 28 | cd gdb_pretty_printers 29 | svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python 30 | 31 | # Create a file named .gdbinit in home folder with the following content and change the username from /home/username to your home folder 32 | python 33 | import sys 34 | sys.path.insert(0, '/home/username/gdb_pretty_printers/python') 35 | from libstdcxx.v6.printers import register_libstdcxx_printers 36 | register_libstdcxx_printers (None) 37 | end 38 | 39 | 40 | Then in eclipse go to Window -> Preferences -> C/C++ -> Debug -> GDB 41 | Change the GDB command file to /home/username/.gdbinit 42 | and make sure the pretty printing section is enabled (has a check in "Enable pretty printers in variable/expression tree") 43 | 44 | This will have effect in all new debug configurations. For the ones already created, 45 | it is necessary to go to the Debugger tab of the run / debug configuration and replace the GDB command file to the new one 46 | (from .gdbinit to /home/username/.gdbinit) 47 | 48 | 49 | 50 | ######################################################################################################################## 51 | # »»»»» Plugins from eclipse repositories 52 | ######################################################################################################################## 53 | 54 | CDT Main Features 55 | CDT Optional Features 56 | Collaboration 57 | Subversive SVN 58 | EGit 59 | General Purpose Tools 60 | Local Terminal 61 | Memory Analyzer 62 | Linux Tools 63 | Mobile and Device Development 64 | Programming Languages 65 | C/C++ Development Tools 66 | C/C++ Development Tools SDK 67 | C/C++ Unit Testing Support 68 | Code Recommenders Developer Tools 69 | Eclipse XML Editors and Tools 70 | 71 | 72 | 73 | ######################################################################################################################## 74 | # »»»»» Plugins from external repositories 75 | ######################################################################################################################## 76 | 77 | »»»»» For correctly print ansi colored text in the console (for example to see ros console messages with correct color - debug / info / warn / error ...) 78 | Info: 79 | http://mihai-nita.net/java/#ePluginAEC 80 | Install url: 81 | http://www.mihai-nita.net/eclipse 82 | 83 | 84 | »»»»» For editing cmake files 85 | Info: 86 | http://cmakeed.sourceforge.net/ 87 | Install url: 88 | http://cmakeed.sourceforge.net/eclipse/ 89 | 90 | 91 | »»»»» For editing yaml scripts 92 | Info: 93 | https://code.google.com/p/yedit/ 94 | Install url: 95 | http://dadacoalition.org/yedit 96 | 97 | 98 | »»»»» For installing python support and parsing 99 | Info: 100 | http://pydev.org/ 101 | Install url: 102 | http://pydev.org/updates 103 | 104 | 105 | »»»»» For editing shell scripts 106 | Info: 107 | http://sourceforge.net/apps/trac/shelled/ 108 | Install url: 109 | http://sourceforge.net/projects/shelled/files/shelled/update/ 110 | 111 | 112 | »»»»» For changing source code editor color themes 113 | Info: 114 | http://eclipsecolorthemes.org/ 115 | Venture Eclipse Color Theme: 116 | http://eclipsecolorthemes.org/?view=theme&id=1878 117 | Install url: 118 | http://eclipse-color-theme.github.com/update 119 | 120 | 121 | »»»»» For customizing eclipse layout and windows theme 122 | Info: 123 | https://github.com/jeeeyul/eclipse-themes 124 | Install url: 125 | http://jeeeyul.github.io/update/ 126 | 127 | 128 | »»»»» For dark eclipse theme 129 | Info: 130 | https://github.com/guari/eclipse-ui-theme 131 | Install url: 132 | https://raw.github.com/guari/eclipse-ui-theme/master/com.github.eclipseuitheme.themes.updatesite 133 | -------------------------------------------------------------------------------- /eclipse/eclipse_shortcuts.txt: -------------------------------------------------------------------------------- 1 | ======================================================================================================================== 2 | # »»»»» Notes 3 | ======================================================================================================================== 4 | --> Shortcuts can be changed in Window -> Preferences -> General -> Keys 5 | 6 | 7 | 8 | ######################################################################################################################## 9 | # »»»»» C / C++ 10 | ######################################################################################################################## 11 | 12 | -> Content assist 13 | Ctrl + Space 14 | 15 | -> Context information 16 | Shift + Ctrl + Space 17 | 18 | -> Find file in project 19 | Ctrl + Shift + R 20 | 21 | -> Build all 22 | Ctrl + B 23 | 24 | -> Build project (custom) 25 | Alt + X 26 | 27 | -> Clean project (custom) 28 | Alt + C 29 | 30 | -> Run last configuration 31 | Ctrl + F11 32 | 33 | -> Debug last configuration 34 | F11 35 | 36 | -> Close file 37 | Ctrl + W 38 | 39 | -> Close all files 40 | Shift + Ctrl + W 41 | 42 | -> Find and replace 43 | Ctrl + F 44 | 45 | -> Find file 46 | Ctrl + H 47 | 48 | -> Find text in workspace 49 | Ctrl + Atl + G 50 | 51 | -> Comment / Uncomment 52 | Ctrl + / (Ctrl + 7, not NumPad) 53 | 54 | -> Add block comment 55 | Shift + Ctrl + / 56 | 57 | -> Remove block comment 58 | Shift + Ctrl + \ 59 | 60 | -> Format 61 | Shift + Ctrl + F 62 | 63 | -> Indent line 64 | Ctrl + I 65 | 66 | -> Open quick hierarchy 67 | Ctrl + T 68 | 69 | -> Open call hierarchy 70 | Ctrl + Alt + H 71 | 72 | -> Rename 73 | Shift + Alt + R 74 | 75 | -> Show outline 76 | Ctrl + O 77 | 78 | -> Toogle source / header 79 | Ctrl + Tab 80 | 81 | -> Go to line 82 | Ctrl + L 83 | 84 | -> Go to last edit location 85 | Ctrl + Q 86 | 87 | -> Go to next file 88 | Ctrl + PageUp 89 | 90 | -> Go to previous file 91 | Ctrl + PageDown 92 | 93 | -> View properties 94 | Ctrl + Enter 95 | 96 | 97 | ######################################################################################################################## 98 | # »»»»» Debugging 99 | ######################################################################################################################## 100 | 101 | -> Resume 102 | F8 103 | 104 | -> Step into 105 | F5 106 | 107 | -> Step over 108 | F6 109 | 110 | -> Step return 111 | F7 112 | 113 | -> Run to line 114 | Ctrl + R 115 | 116 | -> Terminate 117 | Ctrl + F2 -------------------------------------------------------------------------------- /eclipse/eclipse_with_ros.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlosmccosta/ros_development_tools/a0787427fd2398861339936a9637df5c4e4e45c2/eclipse/eclipse_with_ros.pptx -------------------------------------------------------------------------------- /eclipse/eclipse_with_ros.txt: -------------------------------------------------------------------------------- 1 | ######################################################################################################################## 2 | # »»»»» Using eclipse with ROS 3 | ######################################################################################################################## 4 | 5 | # http://wiki.ros.org/IDEs 6 | # http://answers.ros.org/question/52013/catkin-and-eclipse/ 7 | 8 | 9 | 10 | ######################################################################################################################## 11 | # »»»»» eclipse launcher 12 | ######################################################################################################################## 13 | 14 | # create ubuntu launcher for eclipse in folder /home/username/.local/share/applications 15 | gnome-desktop-item-edit --create-new ~/.local/share/applications/ 16 | 17 | and change Exec in the eclipse.desktop file to 18 | Exec=bash -i -c "eclipse" 19 | 20 | 21 | # or start eclipse from console to import ~/.bashrc environment variables 22 | 23 | 24 | 25 | ######################################################################################################################## 26 | # »»»»» Create eclipse .project and .cproject files 27 | ######################################################################################################################## 28 | 29 | # =========================================================== 30 | # »»»»» Note 31 | # =========================================================== 32 | 33 | The instructions in this sections must be repeated every time a CMakeLists.txt is changed, 34 | in order to update the .project and .cproject files. 35 | After executing then again, it is necessary to either restart eclipse or refresh the eclipse project by doing 36 | Project Explorer -> Right click in project -> Refresh 37 | 38 | When using catkin, make sure you run catkin_make before proceeding. 39 | 40 | 41 | # ----------------------------------------------------------- 42 | # >>>> Option 1 -> rosbuild 43 | # ----------------------------------------------------------- 44 | # +++ create .project and .cproject in a folder with a CMakeLists.txt 45 | make eclipse-project 46 | 47 | # +++ create .project and .cproject in a folder with a multiple ros packages 48 | rosmake --target=eclipse-project --specified-only * 49 | 50 | 51 | # ----------------------------------------------------------- 52 | # >>>>> Option 2 -> catkin out of source (recommended) 53 | # ----------------------------------------------------------- 54 | 55 | # +++ create out of source .cproject (will be created in catkin build/ folder) 56 | cd ~/catkin_ws 57 | catkin_make --force-cmake -G"Eclipse CDT4 - Unix Makefiles" 58 | 59 | # or for release builds with debug info 60 | catkin_make --force-cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 61 | 62 | # Since catkin uses a global workspace for all projects, if you want vcs support in eclipse, 63 | you have to create a c++ project in the same directory where you have the .git folder (or equivalent), 64 | in order to eclipse be able to track file changes. 65 | 66 | 67 | # ----------------------------------------------------------- 68 | # >>>>> Option 3 -> using cmake-gui generator 69 | # ----------------------------------------------------------- 70 | 71 | cmake-gui allows to inspect and change cmake project configurations using a GUI. 72 | Either start cmake-gui and specify the source and build directory (they should be siblings to work properly in eclipse) 73 | or go to the directory in the command line and type cmake-gui . (and select the build directory) 74 | Important: cmake-gui should be launched from the terminal in order to access the ros environment variables in the ~/.bashrc 75 | Then click in configure -> select "Eclipse CDT4 - Unix Makefiles" -> "Use default native compilers" -> Finish 76 | Correct any paths and libs and select the build type (CMAKE_BUILD_TYPE) 77 | - Coverage : w/ debug symbols, w/o optimization, w/ code-coverage 78 | - Debug : w/ debug symbols, w/o optimization 79 | - Release : w/o debug symbols, w/ optimization 80 | - RelWithDebInfo : w/ debug symbols, w/ optimization 81 | - MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries 82 | For projects with version control: 83 | - Click in advanced and mark the check box CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT 84 | - Configure the project again 85 | - See section bellow about VCS 86 | Then click in generate 87 | Eclipse project files should now be inside the build folder (and source folder if you checked CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT) 88 | 89 | 90 | 91 | # ----------------------------------------------------------- 92 | # >>>>> Option 4 -> using cmake generator directly 93 | # ----------------------------------------------------------- 94 | 95 | To create out of source builds (recommended), run the commands bellow in a build folder 96 | (that should be a sibling of the source folder to work properly in eclipse) 97 | For example if the CMakeLists.txt is in the current source folder, then 98 | mkdir -p ../build_eclipse 99 | cd ../build_eclipse 100 | 101 | # +++ create .project and .cproject in a package with a CMakeLists.txt 102 | cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE ../src_folder 103 | 104 | # or for release builds with debug info 105 | cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 ../src_folder 106 | 107 | # example for a package using catkin with a CMakeLists.txt in ~/catkin_ws/src/package_name 108 | cd ~/catkin_ws/build/package_name 109 | cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 ~/catkin_ws/src/package_name 110 | 111 | 112 | 113 | # =========================================================== 114 | # »»»»» VCS (Version Control System) 115 | # =========================================================== 116 | 117 | The option -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE will tell cmake to create an extra project to edit the source code 118 | (allowing the eclipse to track the changes using the VCS). 119 | For building the package, the build project or rosmake can be used. 120 | If the project in the source directory doesn't automatically configure the VCS, then 121 | Project properties -> Team -> Share project -> Select your VCS -> Use or create repository 122 | -> Select the directory with the VCS data (it will probably be the repository at the current directory - Project in . ) -> Finish 123 | 124 | More info: 125 | http://www.cmake.org/Wiki/Eclipse_CDT4_Generator 126 | https://secure.mash-project.eu/wiki/index.php/CMake:_Getting_Started 127 | 128 | 129 | 130 | 131 | ######################################################################################################################## 132 | # »»»»» Import eclipse project files from ~/catkin_ws/build 133 | ######################################################################################################################## 134 | 135 | File --> Import --> General --> Existing Projects into Workspace 136 | 137 | 138 | 139 | ######################################################################################################################## 140 | # »»»»» Debug 141 | ######################################################################################################################## 142 | 143 | Eclipse supports debugging using GDB. 144 | 145 | ########## 146 | # Reverse debugging 147 | 148 | Besides normal forward debugging, it also supports reverse debugging (going back in code execution). 149 | To activate this option it is necessary to customize the Debug perspective. 150 | Debug perspective -> Window -> Customize perspective -> Command Groups Availability 151 | -> Select "Reverse Debugging" in Available command groups 152 | You may consider activating "Enable Reverse Debugging at startup" in your debug configurations launch (tab Debugger) 153 | But be warned, it "dramatically reduces the performance of execution". 154 | As such it is recommended to only activate it at runtime, when it is necessary. 155 | Info: 156 | http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_do_Reverse_Debugging.3F 157 | 158 | 159 | ########## 160 | # Multiprocess debugging 161 | 162 | Eclipse also supports debugging (and attach debugging) multiple processes. 163 | Info: 164 | http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_use_multi-process_debugging.3F 165 | 166 | 167 | ########## 168 | # Tracepoints 169 | 170 | When debugging realtime applications, stopping the process to analyze its state may have adverse affects. 171 | As such, eclipse has tracepoints, that provide a way to collect program state without stopping the process. 172 | Info: 173 | http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_trace_my_application_using_C.2FC.2B.2B_Tracepoints.3F 174 | 175 | 176 | 177 | # ====================================================================================================================== 178 | # To debug nodes with parameters / arguments / remaps it is necessary to either 179 | A -> Pass then via command line inside eclipse (in arguments section of run / debug configurations) 180 | B -> Attach eclipse gdb to running process 181 | 182 | 183 | ########## 184 | # Option A (eclipse) - Start process in eclipse and pass parameters and remaps in the eclipse arguments section of run / debug configurations 185 | Ideal when the node has few or no parameters / remaps. 186 | Allows to start the node from inside eclipse. 187 | 188 | - Project -> Debug as -> Debug configurations 189 | - Create new "C/C++ Application" debug configuration 190 | - Select the location of node in ~/catkin_ws/devel/lib 191 | - Make sure the project path is correct and roscore is running 192 | - Debug process in eclipse 193 | - Project -> Debug as -> Select the name of the configuration that you gave previously 194 | -> Resume -> F8 195 | -> Step into -> F5 196 | -> Step over -> F6 197 | -> Step return -> F7 198 | -> Run to line -> Ctrl + R 199 | -> Terminate -> Ctrl + F2 200 | 201 | Info: 202 | http://wiki.ros.org/Remapping%20Arguments 203 | http://wiki.ros.org/roslaunch/Commandline%20Tools 204 | 205 | -> Pass remaps using syntax: 206 | originalTopicName:=newTopicName 207 | 208 | -> Pass parameters using syntax: 209 | _param:=value 210 | 211 | -> Change node name using syntax: 212 | __name:=newName 213 | 214 | 215 | 216 | ########## 217 | # Option B (eclipse) - Attach to running process 218 | Recommended when the node has a lot of parameters / remaps, and as such, 219 | it is better to start the node within the launch file and attach the eclipse to the gdbserver that was started with the node. 220 | 221 | # Edit file 10-ptrace.conf in /etc/sysctl.d to allow eclipse to attach to other processes and then reboot (to this change take effect) 222 | (or start eclipse as root with "gksu eclipse" -> not recommended because it will change the owner of the files that eclipse touches) 223 | kernel.yama.ptrace_scope = 0 224 | Info: 225 | http://wiki.eclipse.org/CDT/User/FAQ#I_cannot_attach_to_a_process_on_Ubuntu 226 | https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace_Protection 227 | 228 | Then: 229 | - Create the breakpoints in eclipse C/C++ editor (they can also be added at runtime when debugging) 230 | - Add to the node xml tag the option to attach gdbserver to the node process 231 | Example: 232 | - Node output in same terminal 233 | 234 | - Node output in different terminal 235 | 236 | - Project -> Debug as -> Debug configurations 237 | - Create new "C/C++ Remote Application" debug configuration 238 | - Select the location of node binary in ~/catkin_ws/devel/lib 239 | - In the Debugger tab and Connection sub-tab 240 | - Enter the port number in which the gdbserver will be running (in the previous example was 1337) 241 | - In the lower part of the window where says "Using GSB (DSF) Automatic Remote Debugging Launcher" 242 | - Click "Select another..." 243 | - Check "Use configuration specific settings" 244 | - Select "GDB (DSF) Manual Remote Debugging Launcher" 245 | - Click apply to save debug configuration 246 | - Make sure the project associated to the node (and that has the node source code) is correct 247 | - Run roslaunch file 248 | - Launch eclipse debugger and attach it to the node process 249 | - Project -> Debug as -> Select the name of the configuration that you given previously 250 | - Debug process in eclipse 251 | -> Resume -> F8 252 | -> Step into -> F5 253 | -> Step over -> F6 254 | -> Step return -> F7 255 | -> Run to line -> Ctrl + R 256 | -> Terminate -> Ctrl + F2 257 | 258 | 259 | 260 | ########## 261 | # Option C (use GDB directly) 262 | Only recommended for "advanced" programmers 263 | 264 | - Add to the node xml tag the option to attach gdb to the node process 265 | (http://wiki.ros.org/roslaunch/Tutorials/Roslaunch%20Nodes%20in%20Valgrind%20or%20GDB) 266 | A -> For having node output in a different terminal 267 | launch-prefix="xterm -e gdb --args" 268 | B -> For having node output in a different terminal and start without user interaction 269 | launch-prefix="xterm -e gdb -ex run --args" 270 | C -> For having node output in the same terminal 271 | launch-prefix="gdb --args" 272 | D -> For having node output in the same terminal and start without user interaction 273 | launch-prefix="gdb -ex run --args" 274 | Example: 275 | 276 | 277 | - Debug in GDB 278 | Useful commands 279 | break [file:]function 280 | Set a breakpoint at function (in file) 281 | run [arglist] 282 | Start your program (with arglist, if specified) 283 | bt 284 | Backtrace: display the program stack 285 | print expr 286 | Display the value of an expression 287 | c 288 | Continue running your program (after stopping, e.g. at a breakpoint) 289 | next 290 | Execute next program line (after stopping); step over any function calls in the line 291 | edit [file:]function 292 | look at the program line where it is presently stopped 293 | list [file:]function 294 | type the text of the program in the vicinity of where it is presently stopped 295 | step 296 | Execute next program line (after stopping); step into any function calls in the line 297 | info breakpoints 298 | List breakpoints 299 | info break 300 | List breakpoint numbers. 301 | info break breakpoint-number 302 | List info about specific breakpoint. 303 | info watchpoints 304 | List watchpoints 305 | info registers 306 | List registers in use 307 | info threads 308 | List threads in use 309 | help [name] 310 | Show information about GDB command name, or general information about using GDB 311 | kill 312 | Stop debugging 313 | quit 314 | Exit from GDB 315 | 316 | 317 | 318 | 319 | ######################################################################################################################## 320 | # »»»»» Unit testing 321 | ######################################################################################################################## 322 | 323 | Eclipse provides integration with several unit testing frameworks, namely Boost.Test, QT Test and Google Testing Framework (gtest) 324 | Info: 325 | http://wiki.eclipse.org/CDT/User/FAQ#C.2FC.2B.2B_Unit_Testing_Support 326 | 327 | 328 | 329 | 330 | ######################################################################################################################## 331 | # »»»»» Other useful tools 332 | ######################################################################################################################## 333 | 334 | Besides debugging, eclipse also as integration with: 335 | -> Valgrind 336 | - Useful to catch memory leaks, segmentation faults, analyze cache and heap usage, detect thread problems 337 | -> GProf | Perf | OProfile | SystemTap 338 | - Code profilers, useful to monitor and analyze program performance, see which functions are consuming more resources... 339 | -> GCov 340 | - Coverage tools, useful to see which parts of the code were executed during an execution session (also useful when doing unit testing) 341 | -> GDB tracepoint analysis | LTTng tracing toolkit and kernel analysis 342 | - Useful to analyze program execution flow 343 | 344 | 345 | 346 | 347 | ######################################################################################################################## 348 | # »»»»» Common problems 349 | ######################################################################################################################## 350 | 351 | # Fix std includes in eclipse 352 | - Project Properties --> C/C++ General --> Preprocessor Include Paths, Macros, etc. --> Providers tab 353 | - Check CDT GCC Built-in Compiler Settings 354 | 355 | # Fix other includes 356 | - Project -> Index -> Re-resolve Unresolved Includes 357 | - Project -> Index -> Rebuild 358 | -------------------------------------------------------------------------------- /git/commands.txt: -------------------------------------------------------------------------------- 1 | ---------------------------------------------- 2 | -- configs 3 | 4 | git config --global user.name "Your Name" 5 | git config --global user.email you@yourdomain.com 6 | git config --global branch.autosetuprebase true 7 | git config --global pull.rebase true 8 | git config --global rebase.autostash true 9 | git config --global merge.tool meld 10 | git config --global diff.tool meld 11 | 12 | 13 | 14 | ---------------------------------------------- 15 | -- ignore chmod changes 16 | 17 | git config --global core.filemode false 18 | 19 | 20 | 21 | ---------------------------------------------- 22 | -- list_status_of_folder_with_repositories 23 | 24 | find -L . -maxdepth 1 -mindepth 1 -type d -exec sh -c "(echo {} && cd {} && git status -s && echo)" \; 25 | 26 | 27 | 28 | ---------------------------------------------- 29 | -- remove commited files last commit 30 | 31 | git reset HEAD^ -- file_with_path 32 | git commit --amend -m "Message" 33 | #git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch filename' --prune-empty -f -- --all 34 | git reflog expire --expire=now --all 35 | git gc --prune=now 36 | git gc --aggressive --prune=now 37 | 38 | 39 | 40 | --------------------------------------------- 41 | -- remove last commit 42 | 43 | git reset --hard HEAD~1 44 | git push origin HEAD --force 45 | 46 | 47 | 48 | --------------------------------------------- 49 | -- stash uncommited changes 50 | 51 | git stash save "name" 52 | git stash list 53 | git stash pop/apply stash@{n} 54 | 55 | 56 | 57 | --------------------------------------------- 58 | -- fix conflicts 59 | 60 | git mergetool 61 | git rebase --continue 62 | 63 | # list conflict files 64 | git diff --name-only --diff-filter=U 65 | 66 | 67 | 68 | --------------------------------------------- 69 | -- duplicate branch 70 | 71 | git checkout -b new_branch old_branch 72 | 73 | 74 | 75 | --------------------------------------------- 76 | -- compare checkout branch 77 | 78 | git difftool --dir-diff other_branch 79 | git difftool -d stash@{0} 80 | 81 | 82 | 83 | --------------------------------------------- 84 | -- clone github organization 85 | 86 | USER=Itseez;PAGE=1; curl "https://api.github.com/users/$USER/repos?page=$PAGE&per_page=100" | grep -e 'git_url*' | cut -d \" -f 4 | xargs -L1 git clone 87 | 88 | 89 | 90 | --------------------------------------------- 91 | -- sync branch / fork 92 | 93 | git checkout master 94 | git fetch upstream 95 | git rebase upstream/master 96 | git checkout branch 97 | git merge/rebase master 98 | -------------------------------------------------------------------------------- /hg/commands.txt: -------------------------------------------------------------------------------- 1 | ----------------------------------- 2 | -- upstream pull 3 | hg pull 4 | hg update 5 | 6 | 7 | 8 | ----------------------------------- 9 | -- rebase 10 | hg up feature-branch 11 | hg rebase --dest default --keepbranches 12 | 13 | # For pushing commits that were already on the remote, they must be marked as draft 14 | hg phase --draft --force id_of_oldest_commit_that_was_changed 15 | hg push --force 16 | 17 | # After the rebase + force push, there will be one head in the local repository but two on bitbucket (the one before and the one after the rebase) 18 | # To avoid multiple heads in a branch and have the latest one being used in a pull request 19 | # A - Clone the remote repository and close the old head 20 | hg clone ... 21 | hg up feature-branch 22 | hg heads . 23 | hg up id_of_head_before_rebase 24 | hg commit --close-branch -m "Closing this head" 25 | hg heads . 26 | hg up id_of_head_after_rebase 27 | hg push --force 28 | 29 | # B - Use bitbucket strip in repository settings (not recommended since it will delete the old commits) 30 | 31 | # After closing the old head and editing the pull request, the latest head will be used for the PR 32 | 33 | 34 | 35 | ----------------------------------- 36 | -- delete commits 37 | # add to .hgrc 38 | [extensions] 39 | strip = 40 | mq = 41 | 42 | # remove commit 43 | hg strip commit 44 | 45 | 46 | 47 | ----------------------------------- 48 | -- remove last commit of a given branch 49 | hg strip my_pruned_branch 50 | 51 | 52 | 53 | ----------------------------------- 54 | -- edit last commit author 55 | hg phase --draft --force . 56 | hg ci --amend --user "Carlos Costa " -X "**" 57 | hg push -f 58 | 59 | 60 | 61 | ----------------------------------- 62 | -- move commits 63 | tortoise hg 64 | create branch 65 | select commits -> graft to local 66 | strip base commit from the original branch 67 | 68 | 69 | 70 | ----------------------------------- 71 | -- compare branches 72 | hg extdiff -p meld -r branch1:branch2 73 | 74 | 75 | 76 | ----------------------------------- 77 | -- check which branch is checked out 78 | hg identify -b 79 | 80 | 81 | 82 | ----------------------------------- 83 | -- list branches 84 | hg branches --active 85 | 86 | 87 | 88 | ----------------------------------- 89 | -- list last commits 90 | hg log --limit 5 91 | 92 | 93 | ----------------------------------- 94 | -- list heads in current branch 95 | hg heads . 96 | 97 | 98 | ----------------------------------- 99 | -- stash uncommitted changes 100 | hg shelve --name 101 | 102 | -- view shelve 103 | hg shelve -l 104 | 105 | -- show shelve diff 106 | hg shelve -l shelve_name 107 | 108 | -- apply shelve 109 | hg unshelve --keep shelve_name 110 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ros_development_tools 5 | 1.0.0 6 | Collection of tools and guides targeted for developing ROS nodes 7 | Carlos Miguel Correia da Costa 8 | Carlos Miguel Correia da Costa 9 | BSD 10 | 11 | catkin 12 | 13 | 14 | -------------------------------------------------------------------------------- /python/libraries.md: -------------------------------------------------------------------------------- 1 | # Generation of requirements.txt 2 | 3 | ``` 4 | pip3 install pipreqs 5 | cd [library_folder] 6 | pipreqs . 7 | ``` 8 | 9 | 10 | # Compilation 11 | 12 | ``` 13 | cd [library_folder] 14 | python setup.py bdist_wheel 15 | pip3 install --force-reinstall --upgrade dist/[wheel_file_name].whl 16 | ``` 17 | -------------------------------------------------------------------------------- /python/library_template/library_name/__init__.py: -------------------------------------------------------------------------------- 1 | from .submodule_name import * 2 | -------------------------------------------------------------------------------- /python/library_template/library_name/submodule_name.py: -------------------------------------------------------------------------------- 1 | class ClassName: 2 | def __init__(self) -> None: 3 | pass 4 | -------------------------------------------------------------------------------- /python/library_template/requirements.txt: -------------------------------------------------------------------------------- 1 | setuptools==45.2.0 2 | -------------------------------------------------------------------------------- /python/library_template/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import find_packages, setup 2 | 3 | setup( 4 | name='library_name', 5 | packages=find_packages(), 6 | version='1.0.0', 7 | description='library_name', 8 | author='Name', 9 | author_email='email', 10 | license='MIT', 11 | install_requires=[''], 12 | ) 13 | -------------------------------------------------------------------------------- /ros/.rosrc: -------------------------------------------------------------------------------- 1 | 2 | ####################################################################################################################### 3 | # ROS 4 | ####################################################################################################################### 5 | 6 | 7 | # 8 | #export ROS_MASTER_URI=http://localhost:11311 9 | #export ROS_HOSTNAME=localhost 10 | # 11 | 12 | 13 | # 14 | #export ROS_MASTER_URI=http://172.16.13.37:11311 15 | #export ROS_IP=172.16.13.47 16 | #export ROS_IP=`ifconfig wlan0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'` 17 | # 18 | 19 | 20 | # 21 | source /opt/ros/jade/setup.bash 22 | # 23 | 24 | 25 | # 26 | catkin_ws_dir='catkin_ws' 27 | source $HOME/${catkin_ws_dir}/devel/setup.bash 28 | alias ctkmake='catkin_make -C $HOME/${catkin_ws_dir}' 29 | alias kk='catkin build -w $HOME/${catkin_ws_dir} --continue-on-failure --summarize --verbose' 30 | source /usr/etc/bash_completion.d/catkin_tools-completion.bash 31 | # 32 | 33 | 34 | # 35 | export ROSCONSOLE_FORMAT='[${severity}] [${node}] [${time}]: ${message} | ${file}:${function}:${line}' 36 | export ROSCONSOLE_CONFIG_FILE='$HOME/.ros/config/rosconsole.config' 37 | export ROS_PARALLEL_JOBS='-j8 -l8' 38 | # 39 | -------------------------------------------------------------------------------- /ubuntu/clock_syncronization.md: -------------------------------------------------------------------------------- 1 | # Install chrony 2 | 3 | ``` 4 | sudo apt-get install chrony -y 5 | ``` 6 | 7 | Check chrony configuration [documentation](https://chrony.tuxfamily.org/doc/3.5/chrony.conf.html) and [FAQ](https://chrony.tuxfamily.org/faq.html). 8 | 9 | 10 | 11 | # Enable chrony daemon at boot 12 | 13 | ``` 14 | sudo systemctl enable chronyd 15 | ``` 16 | or 17 | ``` 18 | sudo systemctl enable /lib/systemd/system/chrony.service 19 | ``` 20 | 21 | After reboot, if the chronyd is dead (sudo systemctl status chrony), disable systemd-timesyncd: 22 | ``` 23 | sudo systemctl disable systemd-timesyncd 24 | ``` 25 | or 26 | ``` 27 | sudo systemctl disable /lib/systemd/system/systemd-timesyncd 28 | ``` 29 | 30 | 31 | 32 | # Configure the master /etc/chrony/chrony.conf 33 | 34 | Setup the reference clocks for the server: 35 | ``` 36 | pool ntp.ubuntu.com iburst maxsources 4 37 | pool 0.ubuntu.pool.ntp.org iburst maxsources 1 38 | pool 1.ubuntu.pool.ntp.org iburst maxsources 1 39 | pool 2.ubuntu.pool.ntp.org iburst maxsources 2 40 | ``` 41 | 42 | Setup the drift file location: 43 | ``` 44 | driftfile /var/lib/chrony/chrony.drift 45 | ``` 46 | 47 | Setup the clock drift correction on chrony daemon startup (if the drift is higher than 1 second, a clock step will be performed): 48 | ``` 49 | # initstepslew step_threshold_seconds [hostname] 50 | initstepslew 1 51 | ``` 52 | 53 | If your master is on a closed network without internet, you can use your clients clocks for making sure that on boot the master clock is not started incorrectly. Change the line above to: 54 | ``` 55 | initstepslew 1 client1_ip client2_ip client3_ip 56 | ``` 57 | 58 | Setup the clock drift correction during runtime, to perform a step when the drift is higher than 1 second: 59 | ``` 60 | # makestep step_threshold_seconds limit_of_steps 61 | makestep 1 -1 62 | ``` 63 | 64 | If your master and clients are on a closed local network and the master usually has no connection to the internet, set the master state as synchronized using 65 | ``` 66 | local stratum 8 # change stratum from 10 to 8 67 | ``` 68 | 69 | For allowing manual time change using chronyc settime command, add: 70 | ``` 71 | manual 72 | ``` 73 | 74 | 75 | If your server will have ntpd clients, add the broadcast configurations and allow clients in the specified subnet to connect to the master: 76 | ``` 77 | # broadcast interval_seconds address [port] 78 | broadcast 10 192.168.255.255 79 | # allow [all] [subnet] 80 | allow 192.168/16 81 | ``` 82 | 83 | Enable rtcsync for copying the system time to the rtc hardware clock: 84 | ``` 85 | rtcsync 86 | ``` 87 | 88 | 89 | 90 | # Configure the clients /etc/chrony/chrony.conf 91 | 92 | Add master to top of servers list and comment the default servers: 93 | ``` 94 | # server hostname [option] 95 | server master_ip iburst 96 | # allow [all] [subnet] 97 | allow master_ip 98 | ``` 99 | 100 | Configure clock drift correction: 101 | ``` 102 | # initstepslew step_threshold_seconds [hostname] 103 | initstepslew 1 master_ip 104 | # makestep step_threshold_seconds limit_of_steps 105 | makestep 1 -1 106 | ``` 107 | 108 | For allowing manual time change using chronyc settime command, add: 109 | ``` 110 | manual 111 | ``` 112 | 113 | Enable rtcsync for copying the system time to the rtc hardware clock: 114 | ``` 115 | rtcsync 116 | ``` 117 | 118 | 119 | 120 | # FAQ 121 | 122 | ## Restart chrony 123 | ``` 124 | sudo /etc/init.d/chrony restart 125 | ``` 126 | or 127 | ``` 128 | sudo systemctl restart chrony 129 | ``` 130 | 131 | 132 | ## Check chrony daemon status 133 | 134 | ``` 135 | sudo systemctl status chrony 136 | ``` 137 | 138 | 139 | ## Force chrony time update without slew 140 | ``` 141 | sudo chronyc -a makestep 142 | ``` 143 | 144 | 145 | ## Check chrony synchronization status 146 | ``` 147 | chronyc tracking 148 | ``` 149 | 150 | 151 | ## Check chrony clients connected to the master server 152 | ``` 153 | chronyc clients 154 | ``` 155 | 156 | 157 | ## Check in the chrony clients, their time sources (servers) 158 | ``` 159 | chronyc sources -v 160 | chronyc sourcestats -v 161 | ``` 162 | 163 | 164 | ## Check system time: 165 | ``` 166 | date 167 | ``` 168 | or 169 | ``` 170 | timedatectl status 171 | ``` 172 | or 173 | ``` 174 | sudo hwclock --show 175 | ``` 176 | 177 | 178 | ## Manual set system date: 179 | ``` 180 | sudo date --set "yyyymmdd hh:mm:ss" 181 | ``` 182 | or, from a remote pc 183 | ``` 184 | sudo date --set "`ssh user@server_ip date --rfc-3339="ns"`" 185 | ``` 186 | -------------------------------------------------------------------------------- /ubuntu/console_logging.md: -------------------------------------------------------------------------------- 1 | # Save console output 2 | 3 | ## Install expect for having unbuffer command 4 | ``` 5 | sudo apt-get install expect 6 | ``` 7 | 8 | 9 | ## Save log to file (stdout and stderr) 10 | ``` 11 | unbuffer [command] &> file.log 12 | ``` 13 | 14 | 15 | ## Save log to file (stdout and stderr) while also viewing the output in the console 16 | ``` 17 | unbuffer [command] |& tee file.log 18 | ``` 19 | -------------------------------------------------------------------------------- /ubuntu/disks.txt: -------------------------------------------------------------------------------- 1 | # List disks 2 | sudo fdisk -l 3 | lsblk 4 | 5 | 6 | # Scan partition for damaged blocks 7 | sudo badblocks -svn /dev/nvme0n1pX > /tmp/bad-blocks.txt 8 | 9 | 10 | # Tell OS to not use the bad blocks 11 | sudo e2fsck -l /tmp/bad-blocks.txt /dev/nvme0n1pX 12 | 13 | Disks have spare blocks that are swapped automatically by the disk firmware. 14 | As such, badblocks may report 0 bad blocks in the last scan, but the drive may have detected and replaced many bad blocks. 15 | For checking that, its necessary to analyze the the available_spare and percentage_used fields reported by the drive using the nvme or smartctl commands. 16 | 17 | 18 | # Check NVME 19 | 20 | sudo apt-get install nvme-cli 21 | sudo nvme smart-log /dev/nvme0 22 | sudo nvme error-log /dev/nvme0 23 | 24 | https://www.nvmetools.com/post/nvme-health 25 | 26 | The wear level is given by the percentage_used. 27 | Percentage of replacement blocks is given in available_spare. 28 | When reaching below available_spare_threshold, the ssh is close to failure. 29 | 30 | 31 | # Check smart data 32 | https://help.ubuntu.com/community/Smartmontools 33 | sudo apt install smartmontools 34 | udo apt install gsmartcontrol 35 | 36 | sudo smartctl -i /dev/sda # check smart data capability 37 | sudo smartctl -s /dev/sda # enable smart data 38 | sudo smartctl -a /dev/sda # view smart data 39 | sudo smartctl -c /dev/sda # check how long the test takes 40 | sudo smartctl -t long /dev/sda # test drive 41 | 42 | 43 | # For forcing the EXT4 filesystem check at every boot: 44 | https://www.baeldung.com/linux/force-file-system-check-every-boot 45 | 46 | Edit the /etc/fstab file and make sure the partitions you want to check have the fs_passno with number 1 or 2. 47 | 48 | Example (fs_passno is the last number): 49 | UUID=2e5d42e1-c6d4-4120-b14d-dd712061f957 / ext4 errors=remount-ro 0 1 50 | 51 | Edit the parameter GRUB_CMDLINE_LINUX_DEFAULT in file /etc/default/grub and add at the end the fsck options: 52 | sudo nano /etc/default/grub 53 | GRUB_CMDLINE_LINUX_DEFAULT="quiet splash fsck.mode=force fsck.repair=yes" 54 | 55 | Then, 56 | sudo update-grub 57 | 58 | Alternative to using the grub parameters: 59 | sudo tune2fs -c 1 /dev/nvme0 60 | 61 | 62 | # Check fsck log 63 | sudo more /run/initramfs/fsck.log 64 | journalctl -u systemd-fsck* 65 | 66 | 67 | # Check ext4 partition (make sure it is not mounted first) 68 | unmount /dev/nvme0n1pX 69 | e2fsck -vf /dev/nvme0n1pX 70 | 71 | 72 | # Check fat32 (make sure it is not mounted first) 73 | sudo dosfsck -w -r -l -a -v -t /dev/nvme0n1pX 74 | 75 | 76 | # Check root partitions 77 | 1 - Run: 78 | shutdown -Fr now 79 | 2 - Create the file: 80 | touch /forcefsck 81 | 3 - During the grub boot go to advanced options, start in recovery mode and then run fsck 82 | 83 | 84 | # Find files with names containing invalid Windows characters: 85 | find . -name '*[<>:"/\\|?*%]*' -o -name '*[ \.]' -o -name '[ ]*' 86 | find . | grep -P "[\x00-\x1F]" 87 | 88 | # Find files with characters not typical for Portuguese language 89 | find . | grep -P "[^\x20\x28\x29\x2b-\x39\x41-\x5a\x5f\x61-\x7a\xba\xc0-\xc3\xc7-\xca\xcc-\xce\xd2-\xd5\xd9-\xdb\xe0-\xe3\xe7-\xea\xec-\xee\xf2-\xf5\xf9-\xfb]" 90 | 91 | # Find duplicate files without taking into consideration the character case 92 | find . | sort -f | uniq -i -d 93 | 94 | 95 | # Find symbolic links 96 | find . -type l 97 | 98 | 99 | # Find hard links and their original files 100 | find . -links +1 101 | 102 | 103 | # Find all files associated with a hard link 104 | find . -samefile /path/to/file 105 | 106 | 107 | # Find files with more than a given path size 108 | find -regextype posix-extended -regex '.{242,}' 109 | 110 | # Find files with more than a given filename size 111 | find | egrep '/[^/]{242,}$' 112 | 113 | 114 | # Sort file paths in file by their length 115 | cat paths.txt | awk '{ print length, $0 }' | sort -n | cut -d" " -f2- > paths_sorted.txt 116 | 117 | 118 | # Hash folder 119 | find /path/to/dir/ -type f -exec sha512sum {} \; | sha512sum 120 | 121 | 122 | # Count files recursively 123 | find /path/to/dir/ -type f | wc -l 124 | -------------------------------------------------------------------------------- /ubuntu/hw_monitoring.md: -------------------------------------------------------------------------------- 1 | # HW monitoring 2 | 3 | 4 | ## lm-sensors 5 | 6 | Install: 7 | 8 | ``` 9 | sudo apt install lm-sensors 10 | sudo sensors-detect 11 | ``` 12 | 13 | Run: 14 | 15 | ``` 16 | watch -n 1 sensors 17 | ``` 18 | 19 | 20 | ## s-tui 21 | 22 | Install: 23 | 24 | ``` 25 | sudo apt install stress s-tui 26 | ``` 27 | 28 | Run: 29 | 30 | ``` 31 | s-tui 32 | ``` 33 | 34 | 35 | ## nvidia 36 | 37 | ``` 38 | watch -n 1 nvidia-smi 39 | nvidia-smi --loop-ms=1000 --format=csv --query-gpu=power.draw 40 | nvidia-smi --loop-ms=1000 --format=csv --query-gpu=index,timestamp,power.draw,temperature.gpu,clocks.sm,clocks.mem,clocks.gr,utilization.gpu,utilization.memory,memory.used 41 | ``` 42 | 43 | Also, there is the GUI, with `PowerMizer` and `Thermal settings` tabs: 44 | 45 | ``` 46 | nvidia-settings 47 | ``` 48 | 49 | 50 | ## cpu-x 51 | 52 | Install: 53 | 54 | ``` 55 | sudo apt install cpu-x 56 | ``` 57 | 58 | Run: 59 | 60 | ``` 61 | sudo cpu-x 62 | ``` 63 | 64 | 65 | ## turbostat (CPU) 66 | 67 | Install: 68 | 69 | ``` 70 | sudo apt install linux-tools-common 71 | sudo apt install linux-tools-5.15.0-88-generic 72 | sudo apt install linux-cloud-tools-5.15.0-88-generic 73 | sudo apt install linux-tools-generic 74 | sudo apt install linux-cloud-tools-generic 75 | sudo apt install gawk 76 | sudo snap install ttyplot 77 | ``` 78 | 79 | Run: 80 | 81 | ``` 82 | sudo turbostat 83 | sudo turbostat --Summary --quiet --show Busy%,Avg_MHz,PkgTmp,PkgWatt --interval 1 84 | sudo turbostat --Summary --quiet --show PkgWatt --interval 1 | gawk '{ printf("%.2f\n" , $1); fflush(); }' | ttyplot -s 100 -t "Turbostat - CPU Power (watts)" -u "watts" 85 | ``` 86 | 87 | 88 | ## powertop 89 | 90 | Install: 91 | 92 | ``` 93 | sudo apt install powertop 94 | ``` 95 | 96 | Run: 97 | 98 | ``` 99 | sudo powertop 100 | ``` 101 | 102 | 103 | ## htop 104 | 105 | Install: 106 | 107 | ``` 108 | sudo apt install htop 109 | ``` 110 | 111 | Run: 112 | 113 | ``` 114 | htop 115 | ``` 116 | -------------------------------------------------------------------------------- /ubuntu/hw_stress_test.md: -------------------------------------------------------------------------------- 1 | # HW stress test 2 | 3 | 4 | ## CPU 5 | 6 | Install: 7 | 8 | ``` 9 | sudo apt install stress 10 | ``` 11 | 12 | Run: 13 | 14 | ``` 15 | stress --cpu $(nproc) --timeout 180 16 | ``` 17 | 18 | 19 | ## GPU 20 | 21 | Install: 22 | 23 | ``` 24 | sudo apt install glmark2 25 | ``` 26 | 27 | Run: 28 | 29 | ``` 30 | glmark2 --annotate --show-all-options --fullscreen 31 | ``` 32 | -------------------------------------------------------------------------------- /ubuntu/iptables.txt: -------------------------------------------------------------------------------- 1 | # Flush All Rules, Delete All Chains, and Accept All 2 | 3 | sudo iptables -P INPUT ACCEPT 4 | sudo iptables -P FORWARD ACCEPT 5 | sudo iptables -P OUTPUT ACCEPT 6 | sudo iptables -t nat -F 7 | sudo iptables -t mangle -F 8 | sudo iptables -F 9 | sudo iptables -X 10 | 11 | 12 | # Allow forwarding 13 | 14 | Change in edit /etc/sysctl.conf 15 | net.ipv4.ip_forward = 1 16 | 17 | sudo iptables -A FORWARD -i eth0 -j ACCEPT 18 | sudo iptables -A FORWARD -o eth0 -j ACCEPT 19 | 20 | 21 | # Persitent routing (/etc/network/interfaces) 22 | 23 | up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254 24 | down route del -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254 25 | -------------------------------------------------------------------------------- /ubuntu/libraries.md: -------------------------------------------------------------------------------- 1 | # Library paths 2 | 3 | The paths that the dynamic linker searches are specifyed in the `/etc/ld.so.conf` file, which includes the configuration files present in the `/etc/ld.so.conf.d` directory. 4 | The dynamic linker can also rely on paths specified in the [LD_LIBRARY_PATH](http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html) environment variable. 5 | 6 | The .so shared libraries are selected according to the order of the files in `/etc/ld.so.conf` 7 | After changing this file, it is necessary to run `sudo ldconfig` to rebuild the .so cache. 8 | 9 | For checking what libraries are available to the dynamic linker, use: 10 | ``` 11 | sudo ldconfig -p 12 | sudo ldconfig -v 13 | ``` 14 | 15 | 16 | # Dependencies 17 | 18 | For checking which libraries are associated with a given binary or .so file, use: 19 | ``` 20 | ldd path_to_file 21 | # or 22 | readelf -d path_to_file 23 | ``` 24 | 25 | For checking the symbol table of a .so file, use: 26 | ``` 27 | readelf -Ws path_to_file | c++filt 28 | # or 29 | objdump -t path_to_file | c++filt 30 | ``` 31 | -------------------------------------------------------------------------------- /ubuntu/mdadm_raid.md: -------------------------------------------------------------------------------- 1 | # Install Ubuntu with RAID 0 or 1 with two 1 TB SSD disks 2 | 3 | - Start Ubuntu live usb in safe graphics. 4 | - Select try Ubuntu. 5 | - Open a terminal. 6 | 7 | 8 | ## Create partitions 9 | 10 | - Use gparted or sgdisk to create the partitions on both disks. 11 | 12 | - For RAID 0: 13 | ``` 14 | Disk 0 15 | - EFI - FAT32 - 2.00 GB -> nvme0n1p1 16 | - ROOT0 - EXT4 - 300.00 GB -> nvme0n1p2 17 | - HOME0 - EXT4 - 592.25 GB -> nvme0n1p3 18 | 19 | Disk 1 20 | - BOOT - EXT4 - 2.00 GB -> nvme1n1p1 21 | - ROOT1 - EXT4 - 300.00 GB -> nvme1n1p2 22 | - HOME1 - EXT4 - 592.25 GB -> nvme1n1p3 23 | ``` 24 | 25 | - For RAID 1: 26 | ``` 27 | Disk 0 28 | - EFI - FAT32 - 2.00 GB -> nvme0n1p1 29 | - ROOT0 - EXT4 - 300.00 GB -> nvme0n1p2 30 | - HOME0 - EXT4 - 592.25 GB -> nvme0n1p3 31 | 32 | Disk 1 33 | - EFI - FAT32 - 2.00 GB -> nvme1n1p1 34 | - ROOT1 - EXT4 - 300.00 GB -> nvme1n1p2 35 | - HOME1 - EXT4 - 592.25 GB -> nvme1n1p3 36 | ``` 37 | 38 | 39 | ## Create raid array for the 2 root partitions 40 | 41 | ``` 42 | sudo -s 43 | apt update 44 | apt install mdadm 45 | apt install grub-efi-amd64 # For RAID 1 only and with secure boot disabled 46 | apt install grub-efi-amd64-signed # For RAID 1 only and with secure boot enabled 47 | ``` 48 | 49 | - For RAID 0 (`--level=0`): 50 | - Merges both disks into one. 51 | - Duplicates space and increases performance of read and write by around 2x. 52 | 53 | ``` 54 | mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/nvme0n1p2 /dev/nvme1n1p2 55 | mdadm --create /dev/md1 --level=0 --raid-devices=2 /dev/nvme0n1p3 /dev/nvme1n1p3 56 | mdadm --create /dev/md2 --level=0 --raid-devices=2 /dev/nvme0n1p4 /dev/nvme1n1p4 57 | ``` 58 | 59 | - For RAID 1 (`--level=1`): 60 | - Duplicates data across both disks, which allows a read performance of around 2x. 61 | - Increases reliability (if one disks fails the system will still boot and work using the other disk). 62 | 63 | ``` 64 | mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/nvme0n1p2 /dev/nvme1n1p2 65 | mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/nvme0n1p3 /dev/nvme1n1p3 66 | mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/nvme0n1p4 /dev/nvme1n1p4 67 | ``` 68 | 69 | - Check RAID status, and wait while it is resyncing. 70 | ``` 71 | mdadm --detail /dev/md0 72 | mdadm --detail /dev/md1 73 | mdadm --detail /dev/md2 74 | watch cat /proc/mdstat 75 | ``` 76 | 77 | 78 | ## Install ubuntu 79 | 80 | - Select `Something else`. 81 | - Create the root and home partitions within `/dev/md0` and format them to EXT4 with the `/` and `/home` mount points. 82 | - Configure the `/boot` in `nvme1n1p1` # For RAID 0 only. 83 | - Configure the `EFI` in nvme0n1p1. 84 | - Select the boot loader to use `Disk 0 (/dev/nvme0n1)`. 85 | - After install, select `Continue testing`. 86 | 87 | 88 | ## Install mdadm into the md_root filesystem 89 | 90 | - Check the state of md_root: 91 | ``` 92 | watch cat /proc/mdstat 93 | ``` 94 | 95 | If `State : clean, resyncing`, wait until resync is done (will change to `State : clean`) 96 | 97 | - Check partitions: 98 | ``` 99 | lsblk 100 | ``` 101 | 102 | - Install mdadm: 103 | ``` 104 | sudo -s 105 | mount /dev/md0p1 /mnt 106 | mount /dev/nvme1n1p1 /mnt/boot # For RAID 0 only 107 | mount -o bind /dev /mnt/dev 108 | mount -o bind /dev/pts /mnt/dev/pts 109 | mount -o bind /sys /mnt/sys 110 | mount -o bind /proc /mnt/proc 111 | cat /etc/resolv.conf >> /mnt/etc/resolv.conf 112 | chroot /mnt 113 | apt install mdadm 114 | apt install grub-efi-amd64 # For RAID 1 only 115 | apt install efibootmgr # For RAID 1 only 116 | ``` 117 | 118 | - Add raid kernel module: 119 | ``` 120 | echo raid0 >> /etc/modules # For RAID 0 only 121 | echo raid1 >> /etc/modules # For RAID 1 only 122 | ``` 123 | 124 | - Change quick_boot and quiet_boot to 0: 125 | ``` 126 | sudo nano /etc/grub.d/10_linux 127 | ``` 128 | 129 | 130 | - Add a premount wait script: 131 | ``` 132 | sudo nano /usr/share/initramfs-tools/scripts/local-premount/wait_for_mdadm 133 | ``` 134 | 135 | ``` 136 | #!/bin/sh 137 | echo 138 | echo "Sleeping for 60 seconds while udevd and mdadm settle down" 139 | sleep 60 140 | echo "Done sleeping" 141 | ``` 142 | 143 | ``` 144 | chmod a+x /usr/share/initramfs-tools/scripts/local-premount/wait_for_mdadm 145 | ``` 146 | 147 | - Wait until the disks finish resyncing: 148 | ``` 149 | watch cat /proc/mdstat 150 | ``` 151 | 152 | ``` 153 | update-initramfs -u 154 | update-grub 155 | ``` 156 | 157 | 158 | ## Clone EFI partition (for RAID 1 only) 159 | 160 | ``` 161 | sudo dd if=/dev/nvme0n1p1 of=/dev/nvme1n1p1 162 | ``` 163 | 164 | - Take note of the path after FILE from the output from command below (default: \EFI\UBUNTU\SHIMX64.EFI): 165 | ``` 166 | sudo efibootmgr -v 167 | ``` 168 | 169 | - Paste the path from above into commands below to add the boot entries of both disks: 170 | ``` 171 | sudo efibootmgr -c -g -d nvme0n1p2 -L "Ubuntu - Disk 0" -l '\EFI\UBUNTU\SHIMX64.EFI' 172 | sudo efibootmgr -c -g -d nvme1n1p2 -L "Ubuntu - Disk 1" -l '\EFI\UBUNTU\SHIMX64.EFI' 173 | ``` 174 | 175 | - Check that the EFI partition from both disks are in the boot list (to ensure that if one disk fails, it will boot from the other disk): 176 | ``` 177 | sudo efibootmgr -v 178 | ``` 179 | 180 | - Wait until the disks finish resyncing: 181 | ``` 182 | watch cat /proc/mdstat 183 | ``` 184 | 185 | - Reboot. 186 | 187 | - Go into the BIOS / UEFI and check that both disks appear in the boot list. 188 | - Make the first disk as the default boot. 189 | 190 | - If the grub is updated, or any change is made to a EFI partition, it is necessary to clone the EFI partition from the first disk into the second disk again. For automating this, create the script: 191 | 192 | ``` 193 | sudo nano /etc/grub.d/90_efi_dd 194 | #!/bin/sh 195 | sudo dd if=/dev/nvme0n1p1 of=/dev/nvme1n1p1 196 | if [ $? -eq 0 ]; then 197 | sudo sh -c "date > /var/log/journal/last_date_of_successful_efi_dd_from_nvme0n1p1_to_nvme1n1p1" 198 | else 199 | sudo sh -c "date > /var/log/journal/last_date_of_failed_efi_dd_from_nvme0n1p1_to_nvme1n1p1" 200 | fi 201 | ``` 202 | 203 | 204 | ## Filesystem check at boot 205 | 206 | https://www.baeldung.com/linux/force-file-system-check-every-boot 207 | 208 | Edit the `/etc/fstab` file and make sure the partitions you want to check have the `fs_passno` with number 1 or 2. 209 | 210 | Example (fs_passno is the last number): 211 | ``` 212 | UUID=2e5d42e1-c6d4-4120-b14d-dd712061f957 / ext4 errors=remount-ro 0 1 213 | ``` 214 | 215 | Edit the parameter `GRUB_CMDLINE_LINUX_DEFAULT` in file `/etc/default/grub` and add at the end the fsck options: 216 | ``` 217 | sudo nano /etc/default/grub 218 | GRUB_CMDLINE_LINUX_DEFAULT="fsck.mode=force fsck.repair=yes" 219 | ``` 220 | 221 | Then, 222 | ``` 223 | sudo update-grub 224 | ``` 225 | 226 | Alternative to using the grub parameters: 227 | ``` 228 | sudo tune2fs -c 1 /dev/md0p1 229 | ``` 230 | 231 | Check fsck logs with: 232 | ``` 233 | sudo more /run/initramfs/fsck.log 234 | journalctl -u systemd-fsck* 235 | ``` 236 | 237 | 238 | ## NVIDIA 239 | 240 | If you boot with a black screen, you need to disable the loading of the nvidia driver at boot. 241 | 242 | Press left shift during boot to go to the grub menu, then press `E` and add `nomodeset` in the line starting with `linux` at the end and before `$vt_handoff` 243 | Then press `Ctrl+X` to proceed with the boot without the loading of the nvidia driver. 244 | 245 | Switch to a terminal, `Ctrl + Alt + F1`, then remove the nvidia drivers installed by default with: 246 | 247 | ``` 248 | sudo apt-get --purge remove cuda-* nvidia-* gds-tools-* libcublas-* libcufft-* libcufile-* libcurand-* libcusolver-* libcusparse-* libnpp-* libnvidia-* libnvjitlink-* libnvjpeg-* nsight* nvidia-* libnvidia-* libcudnn8* 249 | sudo apt-get --purge remove "*cublas*" "*cufft*" "*curand*" "*cusolver*" "*cusparse*" "*npp*" "*nvjpeg*" "cuda*" "nsight*" 250 | sudo apt-get autoremove 251 | sudo apt-get autoclean 252 | sudo rm -rf /usr/local/cuda* 253 | sudo dpkg -r cuda 254 | sudo dpkg -r $(dpkg -l | grep '^ii cudnn' | awk '{print $2}') 255 | ``` 256 | 257 | After reboot, install the latest supported nvidia driver: 258 | ``` 259 | sudo apt install linux-modules-nvidia-535-$(uname -r) -y 260 | sudo apt install nvidia-driver-535 -y 261 | sudo reboot 262 | ``` 263 | 264 | For installing CUDA: 265 | - Add the nvidia PPA: 266 | - https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#network-repo-installation-for-ubuntu 267 | - Check the maximum cuda toolkit version supported by the driver using: 268 | - `nvidia-smi` 269 | - Then, install the version of the cuda toolkit you need, for example: 270 | - `sudo apt install cuda-toolkit-11-8` 271 | 272 | 273 | ## Power button 274 | 275 | - To disable the popup when clicking on the NUC power button: 276 | ``` 277 | gsettings set org.gnome.SessionManager logout-prompt false 278 | gsettings set org.gnome.settings-daemon.plugins.power button-power 'shutdown' 279 | ``` 280 | 281 | 282 | ## More information 283 | 284 | - https://askubuntu.com/questions/660023/how-to-install-ubuntu-14-04-16-04-64-bit-with-a-dual-boot-raid-1-partition-on-an 285 | - https://askubuntu.com/questions/1299978/install-ubuntu-20-04-desktop-with-raid-1-and-lvm-on-machine-with-uefi-bios 286 | - https://forum.level1techs.com/t/how-to-install-ubuntu-20-04-to-linux-me-raid/154105 287 | - https://gist.github.com/umpirsky/6ee1f870e759815333c8 288 | - https://raid.wiki.kernel.org/index.php/Why_RAID%3F#Swapping_on_RAID 289 | - https://raid.wiki.kernel.org/index.php/A_guide_to_mdadm 290 | -------------------------------------------------------------------------------- /ubuntu/network.txt: -------------------------------------------------------------------------------- 1 | # connect 2 | nmcli connection up [name] 3 | 4 | # check connections configurations 5 | nmcli device show 6 | 7 | # check networks interfaces 8 | ifconfig 9 | 10 | # check routing 11 | route -n 12 | 13 | # set interface priority 14 | sudo ifmetric wlan0 50 15 | -------------------------------------------------------------------------------- /ubuntu/scripts/kill_script.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sleep_sigterm="${2:-7}" 4 | sleep_sigkill="${3:-6}" 5 | 6 | #find_script_process_id_and_parent_group_id () { ps ax o pid,pgid,cmd | grep $1 | awk '!/grep|kill_script/'; } 7 | 8 | find_script_parent_group_id () { ps ax o pid,pgid,cmd | grep $1 | awk '!/grep|kill_script/' | grep -v grep | awk '{ print $2 }' | sort -n | uniq; } 9 | 10 | kill_script () 11 | { 12 | if [ -n "$1" ]; then 13 | local sleep_before_sigterm="${2:-7}" 14 | local sleep_before_sigkill="${3:-6}" 15 | group_ids=$(find_script_parent_group_id $1) 16 | printf "\nGroup IDs found for script name [%s] -> [%s]\n" "$1" "$group_ids" 17 | if [ -n "$group_ids" ]; then 18 | for group_id in $group_ids; do 19 | printf "Sending SIGINT to processes with group ID [%s]\n" "$group_id" 20 | kill -INT -$group_id 21 | done 22 | if [ "$sleep_before_sigterm" -gt 0 ]; then 23 | printf "\n\nWaiting for %s seconds before escalating to SIGTERM...\n" "$sleep_before_sigterm" 24 | sleep $sleep_before_sigterm 25 | printf "Escalating to SIGTERM for shutting down unresponsive processes\n" 26 | for group_id in $group_ids; do 27 | printf "Sending SIGTERM to processes with group ID [%s]\n" "$group_id" 28 | kill -TERM -$group_id 29 | done 30 | fi 31 | if [ "$sleep_before_sigkill" -gt 0 ]; then 32 | printf "\n\nWaiting for %s seconds before escalating to SIGKILL...\n" "$sleep_before_sigkill" 33 | sleep $sleep_before_sigkill 34 | printf "Escalating to SIGKILL for shutting down unresponsive processes\n" 35 | for group_id in $group_ids; do 36 | printf "Sending SIGKILL to processes with group ID [%s]\n" "$group_id" 37 | kill -KILL -$group_id 38 | done 39 | fi 40 | fi 41 | else 42 | echo "Missing script name" 43 | fi 44 | } 45 | 46 | kill_script "$1" "$sleep_sigterm" "$sleep_sigkill" 47 | 48 | exit 0 49 | -------------------------------------------------------------------------------- /ubuntu/ubuntu_20_04_lts.md: -------------------------------------------------------------------------------- 1 | ## Install Ubuntu 2 | 3 | - Disable secure boot in uefi and then boot Ubuntu usb drive and select `Install (safe graphics)`. 4 | - Select to not install updates during the installation process, to avoid installing the nvidia drivers. 5 | - After install, in the grub menu, select `Advanced` and then chose one of the `(safe graphics)` option from either the latest kernel or a known stable kernel version, such as `5.15.0.67` (version in the `ubuntu-20.04.6-desktop-amd64.iso`). Then select `Resume` to boot ubuntu in safe graphics. 6 | - Alternatively, select the kernel without the `(safe graphics)`, then press the key `e` and add at the end of the `GRUB_CMDLINE_LINUX_DEFAULT` the argument `nomodeset` 7 | - If grub does not show up, press `Ctrl + Alt + Del` or `Alt + Ptr Scn + B` to reboot and keep pressing the `ESC` key until it shows the `grub>` terminal. Then type `exit` and press enter to go to the grub menu. 8 | 9 | 10 | ## Update Ubuntu 11 | ``` 12 | sudo apt update 13 | sudo apt dist-upgrade 14 | snap-store --quit 15 | snap refresh 16 | ``` 17 | 18 | 19 | ## Install SSH 20 | ``` 21 | sudo apt install openssh-server 22 | sudo ufw allow ssh 23 | sudo systemctl status ssh 24 | ``` 25 | 26 | 27 | ## ssh-copy-id 28 | 29 | For remotely accessing the new formatted PC with `ssh` without having to retype the password every time, you can copy your ssh public key to the new PC. 30 | ``` 31 | ssh-copy-id user@host 32 | ``` 33 | 34 | 35 | ## Install common apps 36 | ``` 37 | sudo apt install terminator -y 38 | sudo apt install git -y 39 | sudo apt install build-essential -y 40 | sudo apt install synaptic -y 41 | ``` 42 | 43 | 44 | ## Change quick_boot and quiet_boot to 0: 45 | ``` 46 | sudo nano /etc/grub.d/10_linux 47 | ``` 48 | ``` 49 | quiet_boot="0" 50 | quick_boot="0" 51 | ``` 52 | 53 | 54 | ## Add save of grub boot order and fsck 55 | ``` 56 | sudo nano /etc/default/grub 57 | ``` 58 | ``` 59 | GRUB_DEFAULT=saved 60 | GRUB_SAVEDEFAULT=true 61 | GRUB_TIMEOUT_STYLE=menu 62 | GRUB_TIMEOUT=10 63 | GRUB_CMDLINE_LINUX_DEFAULT="fsck.mode=force fsck.repair=yes" 64 | ``` 65 | ``` 66 | sudo update-grub 67 | ``` 68 | 69 | 70 | ## Install other kernel versions if necessary 71 | 72 | 5.15.0-67 kernel version (default from `ubuntu-20.04.6-desktop-amd64.iso`) 73 | ``` 74 | sudo apt install linux-image-5.15.0-67-generic -y 75 | sudo apt install linux-headers-5.15.0-67-generic -y 76 | sudo apt install linux-modules-5.15.0-67-generic -y 77 | sudo apt install linux-modules-extra-5.15.0-67-generic -y 78 | sudo apt install linux-hwe-5.15-tools-5.15.0-67 -y 79 | ``` 80 | 81 | 82 | 5.15.0-92 kernel version 83 | ``` 84 | sudo apt install linux-image-5.15.0-92-generic -y 85 | sudo apt install linux-headers-5.15.0-92-generic -y 86 | sudo apt install linux-modules-5.15.0-92-generic -y 87 | sudo apt install linux-modules-extra-5.15.0-92-generic -y 88 | sudo apt install linux-hwe-5.15-tools-5.15.0-92 -y 89 | sudo apt install linux-modules-nvidia-535-5.15.0-92-generic -y 90 | ``` 91 | 92 | 93 | Latest kernel version 94 | ``` 95 | sudo apt install linux-image-$(uname -r) -y 96 | sudo apt install linux-headers-$(uname -r) -y 97 | sudo apt install linux-modules-$(uname -r) -y 98 | sudo apt install linux-modules-extra-$(uname -r) -y 99 | sudo apt install linux-hwe-5.15-tools-$(uname -r | sed 's/-generic//') -y 100 | sudo apt install linux-modules-nvidia-535-$(uname -r) -y 101 | ``` 102 | 103 | 104 | ## 5.15 kernel sources and docs 105 | ``` 106 | sudo apt install linux-hwe-5.15-source-5.15.0 linux-doc -y 107 | ``` 108 | 109 | 110 | ## nvidia driver 111 | ``` 112 | sudo apt install nvidia-driver-535 -y 113 | ``` 114 | 115 | 116 | ## Reboot and select kernel version 117 | - Reboot and then in grub, select Advanced and then choose the kernel version 5.15.0.92 or other stable kernel version. 118 | - With the `GRUB_DEFAULT=saved` from above, it will remember the boot entry in the next boot. 119 | 120 | 121 | ## cuda 122 | 123 | Check which cuda version your nvidia driver supports 124 | ``` 125 | nvidia-smi 126 | ``` 127 | 128 | Check you gpu settings and enable ECC 129 | ``` 130 | nvidia-settings 131 | ``` 132 | 133 | 134 | ### Default cuda version (10.1) 135 | ``` 136 | sudo apt install nvidia-cuda-toolkit -y 137 | ``` 138 | 139 | ### Other versions of cuda 140 | - https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#ubuntu 141 | ``` 142 | sudo apt install linux-headers-$(uname -r) 143 | sudo apt-key del 7fa2af80 144 | cd 145 | wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.1-1_all.deb 146 | sudo dpkg -i cuda-keyring_1.1-1_all.deb 147 | sudo apt update 148 | sudo apt install cuda-toolkit-11-8 149 | sudo apt install nvidia-gds-11-8 150 | sudo reboot 151 | ``` 152 | 153 | Add to `.bashrc` 154 | ``` 155 | export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}} 156 | export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} 157 | ``` 158 | 159 | Check version of cuda: 160 | ``` 161 | nvcc --version 162 | ``` 163 | 164 | 165 | ## Cleanup 166 | ``` 167 | sudo apt autopurge 168 | sudo apt autoclean 169 | sudo reboot 170 | ``` 171 | 172 | 173 | ## Check RAM ECC 174 | 175 | Check if your RAM ECC is working: 176 | ``` 177 | sudo lshw -class memory 178 | sudo lshw -class memory | grep ecc 179 | ``` 180 | 181 | Expected output: 182 | ``` 183 | capabilities: ecc 184 | configuration: errordetection=ecc 185 | ``` 186 | 187 | If you have ECC RAM, the `Total Width` should be greater than the `Data Width`: 188 | ``` 189 | sudo dmidecode --type memory 190 | ``` 191 | 192 | 193 | ## Check fsck logs 194 | ``` 195 | journalctl -u systemd-fsck* 196 | ``` 197 | 198 | 199 | ## Power button 200 | 201 | - To disable the popup when clicking on the NUC power button: 202 | ``` 203 | gsettings set org.gnome.SessionManager logout-prompt false 204 | gsettings set org.gnome.settings-daemon.plugins.power button-power 'shutdown' 205 | ``` 206 | -------------------------------------------------------------------------------- /ubuntu/ubuntu_useful_commands.txt: -------------------------------------------------------------------------------- 1 | # shutdown 2 | gnome-session-quit --power-off 3 | 4 | 5 | # monitor 6 | gnome-system-monitor 7 | 8 | 9 | # status 10 | indicator-multiload 11 | 12 | 13 | # remove .svn 14 | find . -depth -name .svn -exec rm -fr {} \; 15 | 16 | 17 | # force update from unauthenticated servers 18 | sudo apt-get update && sudo apt-get upgrade --allow-unauthenticated 19 | 20 | 21 | # download directory from apache server 22 | wget --mirror --convert-links --no-parent http://path/to/dir 23 | 24 | 25 | # add application .desktop launcher to app default list 26 | -> append %F to end of Exec command 27 | 28 | 29 | # clock update daemon (https://help.ubuntu.com/12.04/serverguide/NTP.html) 30 | sudo apt-get install ntp -y 31 | sudo /etc/init.d/ntp reload 32 | 33 | 34 | # clock update 35 | sudo sh -c "echo 'ntpdate ntp.ubuntu.com' > /etc/cron.daily/ntpdate" 36 | sudo chmod 755 /etc/cron.daily/ntpdate 37 | 38 | 39 | # add ssh key to remote server 40 | cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys' 41 | 42 | # change permissions 43 | find . -type d -exec chmod 755 {} ";" 44 | 45 | -------------------------------------------------------------------------------- /ubuntu/udev_rules.md: -------------------------------------------------------------------------------- 1 | # udev rules 2 | 3 | [udev rules tutorial](http://hackaday.com/2009/09/18/how-to-write-udev-rules) 4 | 5 | - Find unique info 6 | ``` 7 | udevadm info -q all -n /dev/ttyUSB0 8 | udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0) 9 | ``` 10 | 11 | - Add a rule to /etc/udev/rules.d/ with the name ending in .rules 12 | ``` 13 | sudo nano /etc/udev/rules.d/device_name.rules 14 | ``` 15 | 16 | - Add the rule content 17 | ``` 18 | SUBSYSTEM=="tty", ATTRS{idProduct}=="ffee", ATTRS{idVendor}=="04d8", ATTRS{serial}=="00010571", MODE:="0666", SYMLINK+="device_name" 19 | ``` 20 | 21 | - Restart udev and then replug the device 22 | ``` 23 | sudo service udev restart 24 | sudo /etc/init.d/udev restart 25 | sudo udevadm control --reload-rules && udevadm trigger 26 | ``` 27 | -------------------------------------------------------------------------------- /ubuntu/virtual_monitor.md: -------------------------------------------------------------------------------- 1 | # Virtual monitor for Ubuntu 2 | 3 | For running a headless server without a monitor connected, it is necessary to enable a virtual monitor (otherwise the monitor will be all black in the remote desktop window). 4 | 5 | 6 | ## Disable wayland 7 | 8 | - Uncomment `WaylandEnable=false` in file `/etc/gdm3/custom.conf` 9 | - Reboot 10 | 11 | 12 | ## Install the dummy monitor driver 13 | 14 | ``` 15 | sudo apt install xserver-xorg-video-dummy 16 | ``` 17 | 18 | 19 | ## Generate the modeline for the virtual monitor 20 | 21 | ``` 22 | cvt [resolution_width] [resolution_height] [refresh_rate_hz] 23 | ``` 24 | 25 | For example: 26 | 27 | ``` 28 | cvt 1920 1080 60 29 | ``` 30 | 31 | Which outputs: 32 | 33 | ``` 34 | # 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz 35 | Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync 36 | ``` 37 | 38 | 39 | ## Create a new xorg.conf 40 | 41 | ``` 42 | sudo nano /etc/X11/xorg.conf 43 | ``` 44 | 45 | Paste the following, while updating with your respective `Modeline` information: 46 | 47 | ``` 48 | Section "Monitor" 49 | Identifier "Monitor0" 50 | HorizSync 28.0-80.0 51 | VertRefresh 48.0-75.0 52 | # 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz 53 | Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync 54 | EndSection 55 | Section "Device" 56 | Identifier "Card0" 57 | Option "VirtualHeads" "1" 58 | Driver "dummy" 59 | VideoRam 1024000 60 | EndSection 61 | Section "Screen" 62 | DefaultDepth 24 63 | Identifier "Screen0" 64 | Device "Card0" 65 | Monitor "Monitor0" 66 | SubSection "Display" 67 | Depth 24 68 | Modes "1920x1080_60.00" 69 | EndSubSection 70 | EndSection 71 | ``` 72 | 73 | 74 | ## Restart the X server 75 | 76 | ``` 77 | sudo systemctl restart gdm 78 | ``` 79 | 80 | 81 | ## Manually turning on and off the virtual monitor 82 | 83 | - When a monitor is connected, disable the virtual monitor and restart X: 84 | 85 | ``` 86 | sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf0 87 | sudo systemctl restart gdm 88 | ``` 89 | 90 | - When no monitor is connected, enable the virtual monitor and restart X: 91 | 92 | ``` 93 | sudo mv /etc/X11/xorg.conf0 /etc/X11/xorg.conf 94 | sudo systemctl restart gdm 95 | ``` 96 | 97 | 98 | ## Starting GUI programs in ssh terminal 99 | 100 | Before starting GUI programs remotely in a ssh command line, run (or add to .bashrc): 101 | 102 | ``` 103 | export DISPLAY=:0 104 | xhost +local: 105 | ``` 106 | 107 | 108 | ## Remote desktop GUIs 109 | 110 | For connecting to the headless server, several GUI clients are available: 111 | 112 | - [AnyDesk](https://anydesk.com/) 113 | - [TeamViewer](https://www.teamviewer.com) 114 | - [NoMachine](https://www.nomachine.com) 115 | - [Remmina](https://remmina.org/) 116 | * Requires the activation of desktop sharing in the remote server 117 | * https://help.ubuntu.com/stable/ubuntu-help/sharing-desktop.html.en 118 | * Or the setup of a vncserver 119 | * https://help.ubuntu.com/community/VNC/Servers 120 | 121 | 122 | 123 | ## More information 124 | 125 | - https://techoverflow.net/2019/02/23/how-to-run-x-server-using-xserver-xorg-video-dummy-driver-on-ubuntu 126 | -------------------------------------------------------------------------------- /ubuntu/virtual_monitor_with_nvidia_gpu.md: -------------------------------------------------------------------------------- 1 | # Virtual monitor for Ubuntu using nvidia GPU 2 | 3 | For running a headless server without a monitor connected, it is necessary to enable a virtual monitor (otherwise the monitor will be all black in the remote desktop window). 4 | 5 | 6 | ## Disable wayland 7 | 8 | - Uncomment `WaylandEnable=false` in file `/etc/gdm3/custom.conf` 9 | - Reboot 10 | 11 | 12 | ## Create a new xorg.conf file 13 | 14 | - Open `nvidia-settings` in a terminal 15 | - Go to tab `X Server Display Configuration` 16 | - Click in `Save to X Configuration file` 17 | 18 | 19 | ## Save the EDID file 20 | 21 | - Connect monitor for which you want to capture EDID file 22 | - Open `nvidia-settings` in a terminal 23 | - Inside the GPU 0 tree, go to your monitor (for example `DP-0 - (BenQ LCD)`) 24 | - Click in `Acquire EDID...` 25 | - Save the file to folder `/etc/X11` 26 | 27 | 28 | ## Add custom EDID to xorg.conf 29 | 30 | - Within `Section "Screen"` and above `SubSection "Display"`, paste the options below, changing `U` to the port in which you had your monitor connected (for example, in the previous step, it was DP-0 -> U=0) 31 | 32 | ``` 33 | sudo nano /etc/X11/xorg.conf 34 | ``` 35 | 36 | ``` 37 | Option "ConnectedMonitor" "DFP-U" 38 | Option "CustomEDID" "DFP-U:/etc/X11/edid.bin" 39 | Option "IgnoreEDID" "false" 40 | Option "UseEDID" "true" 41 | ``` 42 | 43 | 44 | ## Restart gdm from ssh 45 | 46 | ``` 47 | sudo systemctl restart gdm 48 | ``` 49 | 50 | 51 | ## Disconnect the monitor for which you saved the EDID file 52 | 53 | If you need to connect the same monitor in the future, you need to use the same `DP/HDMI` port. 54 | 55 | If you need to connect the monitor in a different port or using a different monitor, you need to backup your `xorg.conf` and provide an empty or default `xorg.conf` without the custom `EDID` file. 56 | 57 | 58 | ## Manually turning on and off the virtual monitor 59 | 60 | - For connecting a different monitor, disable the virtual monitor and restart X: 61 | 62 | ``` 63 | sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf_backup 64 | sudo systemctl restart gdm 65 | ``` 66 | 67 | - When no monitor is connected, enable the virtual monitor and restart X: 68 | 69 | ``` 70 | sudo mv /etc/X11/xorg.conf_backup /etc/X11/xorg.conf 71 | sudo systemctl restart gdm 72 | ``` 73 | 74 | 75 | ## Starting GUI programs in ssh terminal 76 | 77 | Before starting GUI programs remotely in a ssh command line, run (or add to .bashrc): 78 | 79 | ``` 80 | export DISPLAY=:0 81 | xhost +local: 82 | ``` 83 | 84 | 85 | ## Remote desktop GUIs 86 | 87 | For connecting to the headless server, several GUI clients are available: 88 | 89 | - [AnyDesk](https://anydesk.com/) 90 | - [TeamViewer](https://www.teamviewer.com) 91 | - [NoMachine](https://www.nomachine.com) 92 | - [Remmina](https://remmina.org/) 93 | * Requires the activation of desktop sharing in the remote server 94 | * https://help.ubuntu.com/stable/ubuntu-help/sharing-desktop.html.en 95 | * Or the setup of a vncserver 96 | * https://help.ubuntu.com/community/VNC/Servers 97 | 98 | 99 | ## More information 100 | 101 | - https://nvidia.custhelp.com/app/answers/detail/a_id/3571/~/managing-a-display-edid-on-linux 102 | - https://kodi.wiki/view/Archive:Creating_and_using_edid.bin_via_xorg.conf 103 | - https://download.nvidia.com/XFree86/Linux-x86_64/460.67/README/xconfigoptions.html 104 | - https://unix.stackexchange.com/questions/559918/how-to-add-virtual-monitor-with-nvidia-proprietary-driver 105 | - https://superuser.com/questions/1278256/x-server-on-nvidia-card-with-no-screen 106 | -------------------------------------------------------------------------------- /video/ffmpeg.txt: -------------------------------------------------------------------------------- 1 | # Merge videos left and right 2 | ffmpeg -i left.mp4 -i right.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[v]" -map "[v]" output.mp4 3 | --------------------------------------------------------------------------------