Skip to content

Commit

Permalink
Update the iCub user enviroment documentation (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
GiulioRomualdi authored Nov 3, 2023
1 parent 5d91996 commit 2c35de0
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 59 deletions.
26 changes: 14 additions & 12 deletions docs/icub_operating_systems/icubos/user-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,36 @@ the above files must be renamed to `.bashrc_iCub` and saved in the user home dir
## How to setup the enviroment properly

To use the `~/.bashrc_iCub` file to setup the environment, the following lines:
```
#Load the iCub custom bashrc
if [ "$HOME" != "" ]; then
ICUBRC_FILE="${HOME}/.bashrc_iCub"
else
ICUBRC_FILE="/home/icub/.bashrc_iCub"
fi
if [ -f "$ICUBRC_FILE" ]; then
source $ICUBRC_FILE
```bash
if [[ $- == *i* ]] || [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then
#Load the ergoCub custom bashrc
if [ "$HOME" != "" ]; then
ICUBRC_FILE="${HOME}/.bashrc_ergoCub"
else
ICUBRC_FILE="/home/icub/.bashrc_ergoCub"
fi
if [ -f "$ICUBRC_FILE" ]; then
source $ICUBRC_FILE
fi
fi
```
should be added at the beginning of file `~/.bashrc` just _BEFORE_ the following lines:
```
```bash
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
```

The reason why the `.bashrc_iCub` needs to be added at the beginning of `~/.bashrc` is that file must be loaded every time a bash session is started, no matter if the session is interactive or not (this is required when we want to start our programs remotely), and the line of code after `# If not running interactively, don't do anything` make the `~/.bashrc` file exit if executed in a non-interactive shell.
The reason why the `.bashrc_iCub` needs to be added at the beginning of `~/.bashrc` is that file must be loaded every time an interactive or ssh bash sessions are started. The lines of code after `# If not running interactively, don't do anything` make the `~/.bashrc` file exit if executed in a non-interactive shell.

## Required configuration

To customize the above user environment, you ought to manually make some changes:

- The **YARP_ROBOT_NAME** - you must insert your robot name, in the following line and remove the leading "#"
```
```bash
#export YARP_ROBOT_NAME=
```

Expand Down
96 changes: 49 additions & 47 deletions docs/icub_operating_systems/pc104/the-icub-live-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ The following files, available in the root filesystem contains various informati
## iCub startup scripts
Some scripts must to be executed at startup time, so we need to modify the rc.local file as follows

```
```bash
#!/bin/sh
#
# rc.local
Expand Down Expand Up @@ -129,7 +129,7 @@ exit 0

The above scrits only executes the following script in background

```
```bash
#!/bin/sh
sleep 30
for TRIALS in 0 1 2 3 4 5 6 7 8 9 ; do
Expand All @@ -150,7 +150,7 @@ exit 1

This script is used to mount the remote NFS shares _only when the icub-server that exports them is reachable_

```
```bash
#! /bin/bash
# Mount remote filesystems
MOUNTS_FILE="/etc/rciCub.d/mounts.list"
Expand Down Expand Up @@ -303,50 +303,52 @@ And the file `/etc/hosts` is as follows
The SKEL `/etc/skel` files are used to generate the desired user environment for the icub user modifying the following files

### .bashrc
```
#Load the iCub custom bashrc
ICUBRC_FILE="${HOME}/.bashrc_iCub"
if [ -f "$ICUBRC_FILE" ]; then
source $ICUBRC_FILE
fi
.bashrc_iCub
# .bashrc_iCub
# setup the iCub enviroment
if [ "$ICUBRC_FILE_LOADED" ]; then
return
fi
export ICUBRC_FILE_LOADED="true"
if [ "$PS1" ]; then
echo "Setting up yarp and iCub env vars"
fi
# YARP and iCub enviroment variables
export ROBOT_CODE=/usr/local/src/robot
export ICUBcontrib_DIR=$ROBOT_CODE/iCubContrib
export YARP_ROOT=$ROBOT_CODE/yarp
export YARP_DIR=$YARP_ROOT/build
export ICUB_ROOT=${ROBOT_CODE}/icub-main
export ICUB_DIR=${ICUB_ROOT}/build
export icub_firmware_shared_DIR=${ROBOT_CODE}/icub-firmware-shared/build
export YARP_DATA_DIRS=${YARP_DIR}/share/yarp:${ICUB_DIR}/share/iCub:${ICUBcontrib_DIR}/share/ICUBcontrib
export FIRMWARE_BIN=${ROBOT_CODE}/icub-firmware/build
# Set the name of your robot here.
# Please change also the root user password
export YARP_ROBOT_NAME=
if [ "$YARP_ROBOT_NAME" = "" ] && [ -f "${ROBOT_CODE}/yarp_robot_name.txt" ]
then
export YARP_ROBOT_NAME=$( head --lines=1 ${ROBOT_CODE}/yarp_robot_name.txt )
fi
# Set-up optimizations
export CMAKE_BUILD_TYPE=Release
export PATH=$PATH:$ICUB_DIR/bin:$YARP_DIR/bin
# DebugStream customization
export YARP_VERBOSE_OUTPUT=0
export YARP_COLORED_OUTPUT=1
export YARP_TRACE_ENABLE=0
export YARP_FORWARD_LOG_ENABLE=0
# To enable tab completion on yarp port names
if [ -f $YARP_ROOT/scripts/yarp_completion ]; then
source $YARP_ROOT/scripts/yarp_completion
```bash
if [[ $- == *i* ]] || [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then
#Load the iCub custom bashrc
ICUBRC_FILE="${HOME}/.bashrc_iCub"
if [ -f "$ICUBRC_FILE" ]; then
source $ICUBRC_FILE
fi
.bashrc_iCub
# .bashrc_iCub
# setup the iCub enviroment
if [ "$ICUBRC_FILE_LOADED" ]; then
return
fi
export ICUBRC_FILE_LOADED="true"
if [ "$PS1" ]; then
echo "Setting up yarp and iCub env vars"
fi
# YARP and iCub enviroment variables
export ROBOT_CODE=/usr/local/src/robot
export ICUBcontrib_DIR=$ROBOT_CODE/iCubContrib
export YARP_ROOT=$ROBOT_CODE/yarp
export YARP_DIR=$YARP_ROOT/build
export ICUB_ROOT=${ROBOT_CODE}/icub-main
export ICUB_DIR=${ICUB_ROOT}/build
export icub_firmware_shared_DIR=${ROBOT_CODE}/icub-firmware-shared/build
export YARP_DATA_DIRS=${YARP_DIR}/share/yarp:${ICUB_DIR}/share/iCub:${ICUBcontrib_DIR}/share/ICUBcontrib
export FIRMWARE_BIN=${ROBOT_CODE}/icub-firmware/build
# Set the name of your robot here.
# Please change also the root user password
export YARP_ROBOT_NAME=
if [ "$YARP_ROBOT_NAME" = "" ] && [ -f "${ROBOT_CODE}/yarp_robot_name.txt" ]
then
export YARP_ROBOT_NAME=$( head --lines=1 ${ROBOT_CODE}/yarp_robot_name.txt )
fi
# Set-up optimizations
export CMAKE_BUILD_TYPE=Release
export PATH=$PATH:$ICUB_DIR/bin:$YARP_DIR/bin
# DebugStream customization
export YARP_VERBOSE_OUTPUT=0
export YARP_COLORED_OUTPUT=1
export YARP_TRACE_ENABLE=0
export YARP_FORWARD_LOG_ENABLE=0
# To enable tab completion on yarp port names
if [ -f $YARP_ROOT/scripts/yarp_completion ]; then
source $YARP_ROOT/scripts/yarp_completion
fi
fi
```

Expand Down

0 comments on commit 2c35de0

Please sign in to comment.