Skip to content

Commit

Permalink
Updated devcontainers.
Browse files Browse the repository at this point in the history
  • Loading branch information
samyarsadat committed Aug 27, 2024
1 parent eec37c9 commit 86729a7
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 65 deletions.
11 changes: 11 additions & 0 deletions Source Code/pico_ws/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ RUN apt-get update \
&& apt-get install -y python3-pip \
&& rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean

# Install OpenSSH Server
#RUN apt-get update \
# && apt-get install -y python3-pip openssh-server \
# && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean

# Set the SSH server port to 44
#RUN sed -i "s/#Port 22/Port 44/" /etc/ssh/sshd_config

# Set a password for the nonroot user
#RUN echo "${USERNAME}:nonroot" | chpasswd

# Pico setup
COPY install_pico.sh /pico_setup.sh
RUN export NONROOT_USERNAME=${USERNAME} \
Expand Down
2 changes: 1 addition & 1 deletion Source Code/pico_ws/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


{
"name": "MicroROS Workspace",
"name": "MicroROS Workspace (Remote)",
"remoteUser": "nonroot",
"overrideCommand": true,
"postCreateCommand": "/devcon_post_create.sh",
Expand Down
93 changes: 35 additions & 58 deletions Source Code/pico_ws/.devcontainer/install_pico.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,78 +29,55 @@ cd $OUTDIR
GITHUB_PREFIX="https://github.com/raspberrypi/"
GITHUB_SUFFIX=".git"
SDK_BRANCH="1.5.1"
PICOTOOL_BRANCH="1.1.2"

echo "" >> ~/.bashrc
echo "" >> /home/$NONROOT_USERNAME/.bashrc

for REPO in sdk examples extras playground
do
DEST="$OUTDIR/pico-$REPO"

if [ -d $DEST ]; then
echo "$DEST already exists so skipping"
else
REPO_URL="${GITHUB_PREFIX}pico-${REPO}${GITHUB_SUFFIX}"
echo "Cloning $REPO_URL"
git clone -b $SDK_BRANCH $REPO_URL

# Any submodules
cd $DEST
git submodule update --init
cd $OUTDIR

# Define PICO_SDK_PATH in .bashrc
VARNAME="PICO_${REPO^^}_PATH"
echo "Adding $VARNAME to .bashrc"
echo "export $VARNAME=$DEST" >> ~/.bashrc
echo "export $VARNAME=$DEST" >> /home/$NONROOT_USERNAME/.bashrc
export ${VARNAME}=$DEST
fi
done
DEST="$OUTDIR/pico-sdk"

cd $OUTDIR
if [ -d $DEST ]; then
echo "$DEST already exists so skipping"
else
REPO_URL="${GITHUB_PREFIX}pico-sdk${GITHUB_SUFFIX}"
echo "Cloning $REPO_URL"
git clone -b $SDK_BRANCH $REPO_URL

# Pick up new variables we just defined
source ~/.bashrc
# Any submodules
cd $DEST
git submodule update --init
cd $OUTDIR

# Build a couple of examples
cd "$OUTDIR/pico-examples"
mkdir build
cd build
cmake ../ -DCMAKE_BUILD_TYPE=Debug
# Define PICO_SDK_PATH in .bashrc
VARNAME="PICO_SDK_PATH"
echo "Adding $VARNAME to .bashrc"
echo "export $VARNAME=$DEST" >> ~/.bashrc
echo "export $VARNAME=$DEST" >> /home/$NONROOT_USERNAME/.bashrc
export ${VARNAME}=$DEST
fi

for e in blink hello_world
do
echo "Building $e"
cd $e
make -j$JNUM
cd ..
done
# Pick up new variables we just defined
source ~/.bashrc

cd $OUTDIR

# Picoprobe and picotool
for REPO in picoprobe picotool
do
DEST="$OUTDIR/$REPO"
REPO_URL="${GITHUB_PREFIX}${REPO}${GITHUB_SUFFIX}"
git clone $REPO_URL
# Picotool
DEST="$OUTDIR/picotool"
REPO_URL="${GITHUB_PREFIX}picotool${GITHUB_SUFFIX}"
git clone --branch $PICOTOOL_BRANCH $REPO_URL

# Build both
cd $DEST
git submodule update --init
mkdir build
cd build
cmake ../
make -j$JNUM
# Build both
cd $DEST
git submodule update --init
mkdir build
cd build
cmake ../
make -j$JNUM

if [[ "$REPO" == "picotool" ]]; then
echo "Installing picotool to /usr/local/bin/picotool"
cp picotool /usr/local/bin/
fi
echo "Installing picotool to /usr/local/bin/picotool"
cp picotool /usr/local/bin/

cd $OUTDIR
done
cd $OUTDIR

# Build OpenOCD
echo "Building OpenOCD"
Expand Down
2 changes: 1 addition & 1 deletion Source Code/pico_ws/.devcontainer/post_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ echo "-> Installing MicroROS tools..."
sudo apt-get update \
&& rosdep update \
&& cd $HOME/pico_ws/libmicroros \
&& sudo rosdep install --from-paths src --ignore-src -y \
&& rosdep install --from-paths src --ignore-src -y \
&& sudo apt-get autoremove && sudo apt-get autoclean \
&& echo "-> Tools installed!"

Expand Down
3 changes: 3 additions & 0 deletions Source Code/pico_ws/.devcontainer/post_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ cd $HOME/pico_ws/libmicroros/src && colcon build
source $HOME/pico_ws/libmicroros/src/install/local_setup.bash
cd $HOME/pico_ws

#echo "-> Start SSH server..."
#sudo service ssh start

echo "--> post_start.sh done!"
2 changes: 1 addition & 1 deletion Source Code/pico_ws/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Set minimum required version of CMake
cmake_minimum_required(VERSION 3.12)

# Set project name and Pico A/B name suffixes.
# Set project name and Pico name suffixes.
set(PROJ_NAME ROS_Remote)
set(PICO_NAME ${PROJ_NAME}_Pico)

Expand Down
2 changes: 1 addition & 1 deletion Source Code/pico_ws/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The ROS remote project - Firmware CMake config
# The ROS remote project - Firmware CMake config
# (NOTE: THIS IS NOT THE TOP-LEVEL CMAKE FILE!)
# Copyright 2024 Samyar Sadat Akhavi
# Written by Samyar Sadat Akhavi, 2024.
Expand Down
5 changes: 3 additions & 2 deletions Source Code/ros_ws_remote/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


{
"name": "ROS 2 Workspace",
"name": "ROS 2 Workspace (Remote)",
"remoteUser": "nonroot",
"overrideCommand": true,
"postCreateCommand": "/devcon_post_create.sh",
Expand Down Expand Up @@ -57,5 +57,6 @@
"--gpus", "all",
"-v", "/tmp/.X11-unix:/tmp/.X11-unix:rw",
"--env=DISPLAY",
"-v", "/dev:/dev"]
"-v", "/dev:/dev",
"--device-cgroup-rule=c *:* rmw"]
}
2 changes: 1 addition & 1 deletion Source Code/ros_ws_remote/.devcontainer/post_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sudo chown -R nonroot: $HOME/ros_ws/
#sudo apt-get update \
#&& rosdep update \
#&& cd $HOME/pico_ws/libmicroros \
#&& sudo rosdep install --from-paths src --ignore-src -y \
#&& rosdep install --from-paths src --ignore-src -y \
#&& sudo apt-get autoremove && sudo apt-get autoclean \
#&& echo "-> Tools installed!"

Expand Down

0 comments on commit 86729a7

Please sign in to comment.