Skip to content

Maik13579/ros-docker-base-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

ROS-DOCKER-BASE-IMAGE

A docker image for ros.

Build

Image name will be ros-base-image and the tag is the ros distro.

Example: ros-base-image:noetic

build all

docker-compose -f docker/build.yml build

ROS Noetic

docker-compose -f docker/build.yml build ros

ROS2 Humble

docker-compose -f docker/build.yml build ros2

Commands for .bashrc

A few commands to put in your ~/.bashrc file

export ROS_IP=127.0.0.1
export ROS_HOSTNAME=127.0.0.1
export ROS_MASTER_URI=http://127.0.0.1:11311

export ROS_DOMAIN_ID=11

ros(){
    CURRENT_DIR=$(pwd)
    docker run --rm -it \
    --privileged \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY \
    -e ROS_MASTER_URI\
    -e ROS_IP\
    -e ROS_HOSTNAME\
    --net=host \
    -v ${CURRENT_DIR}:${CURRENT_DIR} \
    ros-base-image:noetic \
    bash -c \
        "echo 'source /opt/ros/noetic/setup.bash' >> /root/.bashrc &&\
        cd ${CURRENT_DIR}
        bash"
}

roscore(){
    docker run --rm -it \
    --privileged \
    --name roscore \
    --net=host \
    -e ROS_MASTER_URI\
    -e ROS_IP\
    -e ROS_HOSTNAME\
    -e WAIT_FOR_ROSCORE=0\
    ros-base-image:noetic \
    roscore
}

ros2(){
    CURRENT_DIR=$(pwd)
    if [ -n "$1" ]; then
        export ROS_DOMAIN_ID=$1
    fi
    docker run --rm -it \
    --privileged \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -v /dev/shm:/dev/shm \
    -e DISPLAY \
    -e ROS_DOMAIN_ID\
    --net=host \
    -v ${CURRENT_DIR}:${CURRENT_DIR} \
    ros-base-image:humble \
    bash -c \
        "echo 'source /opt/ros/humble/setup.bash' >> /root/.bashrc &&\
        cd ${CURRENT_DIR}
        bash"
}

rviz(){
    docker run --rm -it \
    --privileged \
    --name rviz \
    --net=host \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY \
    -e ROS_MASTER_URI \
    -e ROS_IP \
    -e ROS_HOSTNAME \
    -v $HOME/.config/rviz:/opt/ros/noetic/share/rviz/config \
    ros-base-image:noetic \
    rviz
}

rviz2(){
    if [ -n "$1" ]; then
        export ROS_DOMAIN_ID=$1
    fi
    docker run --rm -it \
    --privileged \
    --name rviz2 \
    --net=host \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -v /dev/shm:/dev/shm \
    -e DISPLAY \
    -e ROS_DOMAIN_ID \
    -v $HOME/.config/rviz2:/root/.rviz2 \
    ros-base-image:humble \
    rviz2
}

About

ros base image for docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published