Skip to content
Snippets Groups Projects
Commit 6d4014fc authored by Montaño Sarria, Andres Felipe's avatar Montaño Sarria, Andres Felipe
Browse files

Initial commit

parent 042bc8f6
No related branches found
No related tags found
No related merge requests found
Showing
with 1259 additions and 0 deletions
Using docker to setup a development environment
===============================================
//:Author: Andres Montaño
//:Email: <andres.montano@tecnalia.com>
:Date: 08.07.2021
:Revision: 0.1
From an Ubuntu 20.04 system
---------------------------
=== 1.- Follow the instructions to get access to the Tecnalia repositories and artifacts:
https://git.code.tecnalia.com/tecnalia_robotics/documentation/-/blob/master/good_practices/development_environment_setup.adoc
.Summary
- Obtain API key for internal repositories
- Configure the Debian repository
[source,bash]
sudo apt-get install apt-transport-https
sudo sh -c "echo 'deb https://USER.NAME@tecnalia.com:API_TOKEN@artifact.tecnalia.com/artifactory/tecnalia-robotics-debian xenial main' >> /etc/apt/sources.list.d/tecnalia.list"
- Install Docker CE
[source,bash]
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker USER_NAME
- Configure the docker registry
[source,bash]
docker login tecnalia-robotics-docker.artifact.tecnalia.com
- Configure Git LFS
[source,bash]
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install
git config --global credential.helper 'cache --timeout=3600'
=== 2.- Build the docker image using the Dockerfile
[source,bash]
docker build -t devenv:melodic <Path_to_Dockerfile> .
for example:
[source,bash]
docker build -t devenv:melodic \
--build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa_TecnaliaUB20)" \
--build-arg USER_API_KEY_ARTIFACTS_TECNALIA="$(cat ~/.ssh/user_api_key_artifacts_tecnalia)" \
-f Dockerfile-devenv .
// docker build -t devenv:melodic --build-arg USER_API_KEY_ARTIFACTS_TECNALIA="$(cat ~/.ssh/user_api_key_artifacts_tecnalia)" -f Devenv.Dockerfile .
// docker build -t devenv:melodic --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa_TecnaliaUB20)" --build-arg USER_API_KEY_ARTIFACTS_TECNALIA="$(cat ~/.ssh/user_api_key_artifacts_tecnalia)" -f ssh.Dockerfile .
=== 3.- Install rocker
https://github.com/osrf/rocker
For Debian systems
[source,bash]
sudo apt-get install python3-rocker
=== 4.- Launch the docker image
[source,bash]
rocker --home --x11 --nvidia --user --git --ssh IMAGE_NAME:IMAGE_TAG <COMAND>
for example:
[source,bash]
rocker --home --x11 --nvidia --user --git --ssh devenv:melodic bash
== Notes and Tricks
=== Windows hosts
NOTE: ON WINDOWS NOT WORKING YET!!! Because Ubuntu installations are not recognized as WSL2 distributions on the Tecnalia laptops.
If you are using Ubuntu 20.04 over a Windows PC with WSL2 you need to install Docker Desktop to have integration between Ubuntu 20.04 and docker
Following this guide:
https://adamtheautomator.com/how-to-set-up-docker-in-wsl-step-by-step/
.Summary
- Download and install Docker Desktop
https://desktop.docker.com/win/stable/amd64/Docker%20Desktop%20Installer.exe
- Add your user to docker-users group
From a PowerShell with admin permissions: net localgroup docker-users DOMAIN\username /add
Where DOMAIN\username = TRI.LAN\Your_CODE
- Configure Docker desktop integration with WSL 2
By default, it should be configured, otherwise, follow the tutorial.
WARNING: Linux version installed from MS-Store must be the one without number, i.e. Numbered version e.g. Ubuntu 20.04 or Ubuntu 18.04 are not supported by WSL2
=== ssh and git
- Check ssh and git permissions to access and download packages from git.code.tecnalia.com
=== useful aliases
- rundoc: Launch a container from the dev image
[source,bash]
function rundoc() {
rocker --home --user --x11 --nvidia --ssh --git --name melodic devenv:melodic bash
}
- dat: Launch a terminal inside the runing container from the dev image
[source,bash]
alias dat="docker exec -it melodic bash"
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/extensions.json
!.vscode/launch.json
!.vscode/c_cpp_properties.json
{
"configurations": [
{
"browse": {
"databaseFilename": "",
"limitSymbolsToIncludedHeaders": true
},
"includePath": [
"/opt/ros/kinetic/include",
"/usr/include/**",
"${workspaceFolder}/../../devel/include",
"${workspaceFolder}/**"
],
"name": "Linux",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
\ No newline at end of file
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"configurations": [
{
"name": "VS_Talker_Node",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/../../devel/lib/hello_vs_code/vs_talker",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/../../",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "VS_Listener_Node",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/../../devel/lib/hello_vs_code/vs_listener",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/../../",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "VS_Listener2_Node",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/../../devel/lib/hello_vs_code/vs_listener2",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/../../",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
\ No newline at end of file
{
"version": "2.0.0",
"tasks": [
{
"label": "ROS: Build Hello_VS_CODE",
"type": "shell",
"command": "catkin_make",
"args": [
"--pkg",
"hello_vs_code",
"-j4",
"-DCMAKE_BUILD_TYPE=Debug"
],
"problemMatcher": "$gcc",
"options": {
"cwd": "${workspaceFolder}/../../"
},
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"revealProblems": "onProblem",
"panel": "new"
}
}
]
}
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2019 MrGnomes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
This diff is collapsed.
VS_Code_ROS/docs/FolderStructure.png

30.2 KiB

VS_Code_ROS/docs/addFolder.png

23.8 KiB

VS_Code_ROS/docs/addWS.png

21.6 KiB

VS_Code_ROS/docs/debugConfigs.png

33.2 KiB

VS_Code_ROS/docs/listenerComp.png

169 KiB

VS_Code_ROS/docs/multiDebug.png

381 KiB

VS_Code_ROS/docs/talkerComp.png

167 KiB

VS_Code_ROS/docs/talkerDebug.png

183 KiB

cmake_minimum_required(VERSION 2.8.3)
project(hello_vs_code)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# std_msgs
# )
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed
## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES hello_vs_code
# CATKIN_DEPENDS roscpp rospy std_msgs
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/hello_vs_code.cpp
# )
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/hello_vs_code_node.cpp)
add_executable(vs_talker src/talker.cpp)
add_executable(vs_listener src/listener.cpp)
add_executable(vs_listener2 src/listener2.cpp)
## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
# ${catkin_LIBRARIES}
# )
target_link_libraries(vs_talker
${catkin_LIBRARIES})
target_link_libraries(vs_listener
${catkin_LIBRARIES})
target_link_libraries(vs_listener2
${catkin_LIBRARIES})
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables and/or libraries for installation
# install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )
## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_hello_vs_code.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
<?xml version="1.0"?>
<package format="2">
<name>hello_vs_code</name>
<version>0.0.0</version>
<description>Simple hello_vs_code package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="MrGonmes@todo.todo">MrGnomes</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<depend>roscpp</depend>
<depend>rospy</depend>
<depend>std_msgs</depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
#include "ros/ros.h"
#include "std_msgs/String.h"
void talkerCallback(const std_msgs::String::ConstPtr& rosMsg)
{
ROS_INFO("I heard: [%s]", rosMsg->data.c_str());
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "listener");
ros::NodeHandle hanlde;
ros::Subscriber talker_sub = hanlde.subscribe("/talker", 1000, talkerCallback);
ros::spin();
return 0;
}
\ No newline at end of file
#include "ros/ros.h"
#include "std_msgs/String.h"
void talkerCallback(const std_msgs::String::ConstPtr& rosMsg)
{
ROS_INFO("I heard: [%s]", rosMsg->data.c_str());
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "listener2");
ros::NodeHandle hanlde;
ros::Subscriber talker_sub = hanlde.subscribe("/talker", 1000, talkerCallback);
ros::spin();
return 0;
}
\ No newline at end of file
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <iostream>
int main(int argc, char **argv)
{
ros::init(argc, argv, "talker");
ros::NodeHandle hanlde;
ros::Publisher talker_pub = hanlde.advertise<std_msgs::String>("/talker", 1000);
ros::Rate loop_rate(10);
int count = 0;
while(ros::ok())
{
std_msgs::String rosMsg;
std::stringstream ss;
ss << "Hello Ros World [" << count << "]";
rosMsg.data = ss.str();
ROS_INFO("%s", rosMsg.data.c_str());
talker_pub.publish(rosMsg);
ros::spinOnce();
loop_rate.sleep();
++count;
}
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment