diff --git a/dockerfiles/extra_libs/humble_plugins.txt b/dockerfiles/extra_libs/humble_plugins.txt new file mode 100644 index 0000000000000000000000000000000000000000..3cb37c3ba79c2223d9155028ff92db10a0c16e43 --- /dev/null +++ b/dockerfiles/extra_libs/humble_plugins.txt @@ -0,0 +1,2 @@ +# list of files and destination folders +librealsense_gazebo_plugin.so /usr/lib/x86_64-linux-gnu/gazebo-11/plugins diff --git a/dockerfiles/extra_libs/librealsense_gazebo_plugin.so b/dockerfiles/extra_libs/librealsense_gazebo_plugin.so new file mode 100755 index 0000000000000000000000000000000000000000..26917074b53ed1328ef820e7dad37043b5be3c53 Binary files /dev/null and b/dockerfiles/extra_libs/librealsense_gazebo_plugin.so differ diff --git a/dotfiles/docker.bck b/dotfiles/docker.bck new file mode 100644 index 0000000000000000000000000000000000000000..29feba47877c6ea5ebd51c485ab96e00f63c28a8 --- /dev/null +++ b/dotfiles/docker.bck @@ -0,0 +1,112 @@ +# docker common commands +export dockerfiles_DIR=~/srcs/development_environment/dockerfiles; + +alias dim="docker images" +alias dpsa="docker ps -a" +alias dps="docker ps" +alias drm="docker rm" +alias drmi="docker rmi" +alias dsp="docker system prune --all" +alias dimp="docker image prune" + +# Build docker image +# usage: dockbuild {noetic, melodic} +function dockbuild(){ + if [ $# -lt 1 ]; then + echo "Usage: dockbuild <ROS_DISTRO> [build_args]" + echo "build_args:" + echo " SHELL - zsh (default) or bash" + return 1 + fi + + cd $dockerfiles_DIR; + + if [ $# -lt 2 ]; then + echo "Building ROS_DISTRO:"$1 "with SHELL_VERISON: zsh" + docker build -t devenv:$1 --build-arg ROS_DISTRO=$1 --build-arg SHELL="zsh" -f devenv.Dockerfile . + else + if [ $2 = "bash" ]; then + echo "Building ROS_DISTRO:"$1 "with SHELL_VERISON:"$2 + docker build -t devenv:$1 --build-arg ROS_DISTRO=$1 --build-arg SHELL=$2 -f devenv.Dockerfile . + else + echo "SHELL_VERISON:"$2 "not supported" + fi + fi +} + +# Run container with rocker +# usage: rundock {noetic, melodic} [{remodel_ws, odin_ws}] [cmd] +# ToDo Add extra parameters by arg +# To share docker --volume /var/run/docker.sock:/var/run/docker.sock:ro +# To share video (usb-cam) --volume /dev/video0:/dev/video0 +function dockrun() { + # Check if the image exist + if [[ "$(docker images -q devenv:$1 2> /dev/null)" == "" ]]; then + # build the image + dockbuild $1 + fi + + # Check if the container exist + if [[ $(docker ps -aq -f name=$1) ]]; then + # Attach to conayiner + docker exec -it $1 bash -c "cd ~/ros/$1/$2 && $ext" + else + # Launch container + cd ~/ros/$1/$2; + rocker --home --ssh --git --user --privileged --nvidia --x11 --network host --name $1 devenv:$1 $3 + fi +} + +# Remove all stoped containers +function drma() { + drm $(docker ps -a -f status=exited -q) +} + + +# Remove all unused or dangling immages +function drmui(){ + drmi $(dim --filter "dangling=true" -q --no-trunc) +} + +# Stop and remove +function dsr() { + docker stop $1; + docker rm $1 +} + +# function runpythonsyntax(){ +# rocker --home --name python_syntax tecnalia-docker-dev.artifact.tecnalia.com/docker:git +# } + +# function runremodel() { +# rocker --x11 --nvidia --privileged --network=host --name remodel_docker --oyr-run-arg " -v iiwa_state_recorder:/home/remodel/iiwa_state_recorder -v /home/andres/test/remodel_shared:/home/remodel/remodel_shared" -- remodel_app:melodic bash -c "'roslaunch remodel_app remodel_app.launch use_sim:=true docker:=true skill_manager:=true collision_detector:=true ui:=true cad:=true joystick:=false'" +# } + +# function docrun() { +# rocker --nvidia --pulse --x11 --volume /dev/video0:/dev/video0 --privileged --oyr-run-arg " -v odin_robot_volume:/root/" --name odin_robot --network host odin_robot:melodic $1 +# } + +# function runodin() { +# rocker --nvidia --pulse --x11 --privileged --volume /dev/video0:/dev/video0 --name odin_melodic --network host devenv:melodic $1 +# } + +#DOCKER +alias dexec='f(){ docker exec -w /root/ --detach-keys="ctrl-@" -e DISPLAY=$DISPLAY -it $1 /bin/bash -c "terminator --no-dbus"; unset -f f; }; f' +alias dexec_nt='f(){ docker exec --detach-keys="ctrl-@" -e DISPLAY=$DISPLAY -it $1 /bin/bash ; unset -f f; }; f' +alias dstart='f(){ docker start $1; dexec $1; unset -f f; }; f' +# Run using same X and .ssh folder +alias drun='f(){ docker run -it -e DISPLAY=$DISPLAY --detach-keys="ctrl-@" -v /tmp/.X11-unix:/tmp/.X11-unix -v ~/.ssh:/root/.ssh:ro -v ~/docker_share/:/root/docker_share/ --net=host --name $2 $1; unset -f f; }; f' +alias drun_nvidia='f(){ docker run -it --name $2 --privileged \ + --net=host \ + --env=NVIDIA_VISIBLE_DEVICES=all \ + --env=NVIDIA_DRIVER_CAPABILITIES=all \ + --env=DISPLAY \ + --env=QT_X11_NO_MITSHM=1 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + --gpus all \ + --device /dev/snd \ + -e NVIDIA_VISIBLE_DEVICES=0 \ + --detach-keys="ctrl-@" \ + -v ~/.ssh:/root/.ssh:ro \ + -v ~/docker_share/:/root/docker_share/ \ + $1 /bin/bash; unset -f f; }; f' diff --git a/dotfiles/ros.bck b/dotfiles/ros.bck new file mode 100644 index 0000000000000000000000000000000000000000..6e28ad5ae79b197e76eef5c76ecd646344987980 --- /dev/null +++ b/dotfiles/ros.bck @@ -0,0 +1,102 @@ +################################################################### +# ROS aliases and functions +################################################################### + +# Define ROS_DISTRO before source ROS on native OS +# if [ -z $ROS_DISTRO ]; then export ROS_DISTRO=noetic; fi +if [[ -z "${ROS_DISTRO}" ]]; then + ROS_DIR=/opt/ros + if [ -d "$ROS_DIR" ]; + then + export ROS_DISTRO=$(basename $(find /opt/ros/* -maxdepth 0 -type d | head -1)) + else + unset ROS_DISTRO + fi +fi + +# Determine shell extension +if [ -z $SHELL ]; then echo "SHELL not set"; else ext=$(basename ${SHELL}); fi + +# Source rosmon +function smon(){ + if [[ -f "/opt/ros/${ROS_DISTRO}/etc/catkin/profile.d/50-rosmon.${ext}" ]]; then + source /opt/ros/${ROS_DISTRO}/etc/catkin/profile.d/50-rosmon.${ext} + fi +} + +# cd to the root of the workspace +function roshome(){ + roscd && cd .. + ROS_HOME=${PWD} +} + +# Source the current workspace +function sourcews(){ + source ./devel/setup.${ext} && smon +} + +# Source the current workspace +function sourceros(){ + source /opt/ros/${ROS_DISTRO}/setup.${ext} && smon + ROS_HOME="/opt/ros/${ROS_DISTRO}/" +} + +# Source the current workspace +function sourcethis(){ + pwd_st=${PWD} + roshome && sourcews + echo "Sourcing: ${ROS_HOME}" + cd ${pwd_st} +} + +# Automatic catkin build +function cb() { + pwd_cb=${PWD} + roshome + catkin build --summarize --cmake-args -DCMAKE_BUILD_TYPE=Release -- "$@" + sourcethis + cd ${pwd_cb} +} + +# Clean workspace (delete the generated folders, then catkin build) +function cbclean(){ + roshome && rm -rf build devel install && catkin build --summarize --cmake-args -DCMAKE_BUILD_TYPE=Release +} + +# Initialize catkin workspace, configure and build it +function cib(){ + catkin init && catkin config --extend /opt/ros/${ROS_DISTRO} && catkin build --summarize --cmake-args -DCMAKE_BUILD_TYPE=Release +} + +# Run ci locally +function runci(){ + # check if exist .rosinstall file + if [ -f ./.rosinstall ]; then + echo ".rosinstall in package" + find ../ -name run_ci -exec bash {} ROS_DISTRO="$@" DOCKER_IMAGE=tecnalia-robotics-docker.artifact.tecnalia.com/flexbotics-base-devel:"$@" UPSTREAM_WORKSPACE=.rosinstall \; + else + echo "No .rosinstall in package" + find ../ -name run_ci -exec bash {} ROS_DISTRO="$@" DOCKER_IMAGE=tecnalia-robotics-docker.artifact.tecnalia.com/flexbotics-base-devel:"$@" \; + fi +} + +# if a new terminal starts in a ws, auto source it (useful for vscode) +if [ -z ${ROS_DISTRO+x} ]; then ; +else + pwd_init=${PWD} + cropped=${PWD#${HOME}/ros/${ROS_DISTRO}/} + WS_name=${cropped%%/*} + WS_path=${HOME}/ros/${ROS_DISTRO}/${WS_name} + FILE=${WS_path}/devel/setup.${ext} + # if PWD belongs to ROS ws then source it + if [[ -f $FILE ]]; then + cd ${WS_path} + source $FILE + cd ${pwd_init} + ROS_HOME=${WS_path} + else + sourceros + fi +fi + +alias sc=sourcethis \ No newline at end of file diff --git a/dotfiles/sysem.bck b/dotfiles/sysem.bck new file mode 100644 index 0000000000000000000000000000000000000000..ec8fc9968968629a68cdb6e5ee3b409ee24a65a4 --- /dev/null +++ b/dotfiles/sysem.bck @@ -0,0 +1,38 @@ +# Determine shell extension +if [ -z $SHELL ]; then + echo "SHELL not set" + export SHELL=/usr/bin/zsh + ext=$(basename ${SHELL}); +else + ext=$(basename ${SHELL}); +fi + +if command -v lsd &> /dev/null +then + # Directories + alias ll='lsd -lh --group-dirs=first' + alias la='lsd -a --group-dirs=first' + alias l='lsd --group-dirs=first' + alias lla='lsd -lha --group-dirs=first' + alias ls='lsd --group-dirs=first' +else + alias ll='ls -lh' + alias la='ls -a' + alias l='ls' + alias lla='ls -lha' + alias ls='ls' +fi + +if command -v bat &> /dev/null +then + # Files + alias cat='bat' +fi + +# Python +if command -v ipython &> /dev/null +then + alias ipy='ipython' +fi + +alias mountT='sudo mount -t cifs //tri.lan/tri /mnt/T --verbose -o username=110343,password=Bageera\#1983,workgroup=TRI.LAN' diff --git a/dotfiles/zshrc.bck b/dotfiles/zshrc.bck new file mode 100644 index 0000000000000000000000000000000000000000..5e93a5a974cff9e19b56e252576edf6e772cfaee --- /dev/null +++ b/dotfiles/zshrc.bck @@ -0,0 +1,86 @@ +# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. +# Initialization code that may require console input (password prompts, [y/n] +# confirmations, etc.) must go above this block; everything else may go below. +if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +fi + +#zmodload zsh/zprof + +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:/usr/local/bin:$PATH + +# Path to your oh-my-zsh installation. +export ZSH=~/.oh-my-zsh + +# Uncomment the following line to display red dots whilst waiting for completion. +COMPLETION_WAITING_DOTS="true" + +source "$HOME/.homesick/repos/homeshick/homeshick.sh" +fpath=($HOME/.homesick/repos/homeshick/completions $fpath) + +source ~/antigen.zsh +antigen use oh-my-zsh + +antigen theme romkatv/powerlevel10k + +antigen bundle docker +antigen bundle git +antigen bundle globalias +antigen bundle last-working-dir +antigen bundle sudo +antigen bundle zsh-users/zsh-history-substring-search +antigen bundle zsh-users/zsh-syntax-highlighting +antigen bundle wfxr/forgit +antigen bundle paulirish/git-open +antigen bundle popstas/zsh-command-time +antigen bundle MichaelAquilina/zsh-auto-notify +antigen bundle MichaelAquilina/zsh-you-should-use +antigen bundle zsh-users/zsh-autosuggestions + +antigen apply + +#ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=0' + +# command-line fuzzy finder +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + +source $HOME/.init_shell + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +#zprof + +export FZF_DEFAULT_COMMAND='rg --files --hidden --follow --no-ignore-vcs' +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +#export FZF_ALT_C_COMMAND="fd -t d --hidden --follow --exclude \".git\" . $HOME" +export FZF_ALT_C_COMMAND="fd -t d --hidden --follow --exclude \".git\" ." + +# Create a cache folder if it isn't exists +if [ ! -d "$HOME/.cache/zsh" ]; then + mkdir -p $HOME/.cache/zsh +fi + +# Define a custom file for compdump +export ZSH_COMPDUMP="$HOME/.cache/zsh/zcompdump-$HOST-$ZSH_VERSION" + +# User configuration + +export EDITOR="code -r" + +# Include dotfiles +source ${HOME}/srcs/development_environment/dotfiles/system.bash +source ${HOME}/srcs/development_environment/dotfiles/git.bash +source ${HOME}/srcs/development_environment/dotfiles/docker.bash +source ${HOME}/srcs/development_environment/dotfiles/ros.bash + +# To add direnv app +# eval "$(direnv hook zsh)" + +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh + +# Finalize Powerlevel10k instant prompt. Should stay at the bottom of ~/.zshrc. +(( ! ${+functions[p10k-instant-prompt-finalize]} )) || p10k-instant-prompt-finalize