ros2-realtime-demo / pendulum

ROS, ROS2, real-time, control, pendulum
Apache License 2.0
132 stars 38 forks source link

installation fails: "ade --rc pendulum_ws/src/pendulum/ade/.aderc start --update --enter" command fails #75

Closed george-DLJ closed 3 years ago

george-DLJ commented 3 years ago

Describe the bug Hello, thanks in first place for building this ROS2 RT example. I followed the installation instructions, but for some reason in the following steps the following command fails:

$ ade --rc pendulum_ws/src/pendulum/ade/.aderc start --update --enter" 

with following error:

OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: chdir to cwd ("/root/ros2_foxy") set in config.json failed: permission denied: unknown
ERROR: Command return non-zero exit code (see above): 126
  docker exec -ti --env COLORFGBG --env TERM -u <myusr> ade bash -li

UPDATE: I found that the error happens on the docker exec due to the -u <myuser> without this parameter the command works. I'm quite new with docker and ade, how can I fix this command? Thank you!

To Reproduce Steps to reproduce the behavior: Followed install instructions installing in user home [...]:

$ cd ~

$ mkdir adehome
$ cd adehome
$ touch .adehome
$ cd ~

$ cd /adehome
$ mkdir -p pendulum_ws/src
$ cd pendulum_ws/src
$ git clone git@github.com:ros2-realtime-demo/pendulum.git
$ cd ~

$ cd adehome
$ ade --rc pendulum_ws/src/pendulum/ade/.aderc start --update --enter

Expected behavior ade docker instance starts

Screenshots

myusr@myusr-ubuntu:~/adehome$ ade --rc pendulum_ws/src/pendulum/ade/.aderc start --update --enter
INFO: Using non-default pendulum_ws/src/pendulum/ade/.aderc configuration file
ade-base-foxy: Pulling from ros2realtimedemo/pendulum
Digest: sha256:17a2da59473d1bcb5dc0f6c5dd79a189078685f4dc2be350c644c0294867c9f4
Status: Image is up to date for ros2realtimedemo/pendulum:ade-base-foxy
docker.io/ros2realtimedemo/pendulum:ade-base-foxy
Starting ade with the following images:
pendulum | n/a | ade-base-foxy | ros2realtimedemo/pendulum:ade-base-foxy
Stopping ade
non-network local connections being added to access control list

Current default time zone: 'Europe/Berlin'
Local time is now:      Tue Apr 13 16:14:38 CEST 2021.
Universal Time is now:  Tue Apr 13 14:14:38 UTC 2021.

Adding user myusr to group video
Adding user myusr to group tracing
ADE startup completed.
Entering ade with following images:
pendulum | n/a | ade-base-foxy | ros2realtimedemo/pendulum:ade-base-foxy
OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: chdir to cwd ("/root/ros2_foxy") set in config.json failed: permission denied: unknown
ERROR: Command return non-zero exit code (see above): 126
  docker exec -ti --env COLORFGBG --env TERM -u myusrthin ade bash -li

Desktop (please complete the following information):

Additional context docker hello-world works installed ade version: 4.2.0

LanderU commented 3 years ago

@george-DLJ, thanks a lot! I'm looking into it!

LanderU commented 3 years ago

@george-DLJ, I'm trying to reproduce the error on my end, for now everything works just fine to me. Could you please try the following?

cd ~/adehome
ade --rc pendulum_ws/src/pendulum/ade/.aderc start --update

Then try to enter with:

ade enter

If this fails use:

ade enter -u root

Thanks!

george-DLJ commented 3 years ago

Thanks @LanderU for your support. I tried the commands and only works when I use ade enter -u root however using that command I enter as root user and cannot do the next steps of the guide. Following I reproduce the commands and their results:

~/adehome$ ade --rc pendulum_ws/src/pendulum/ade/.aderc start --update
INFO: Using non-default pendulum_ws/src/pendulum/ade/.aderc configuration file
ade-base-foxy: Pulling from ros2realtimedemo/pendulum
Digest: sha256:17a2da59473d1bcb5dc0f6c5dd79a189078685f4dc2be350c644c0294867c9f4
Status: Image is up to date for ros2realtimedemo/pendulum:ade-base-foxy
docker.io/ros2realtimedemo/pendulum:ade-base-foxy
Starting ade with the following images:
pendulum | n/a | ade-base-foxy | ros2realtimedemo/pendulum:ade-base-foxy
non-network local connections being added to access control list

Current default time zone: 'Europe/Berlin'
Local time is now:      Sat Apr 17 13:22:13 CEST 2021.
Universal Time is now:  Sat Apr 17 11:22:13 UTC 2021.

Adding user jorge to group video
Adding user jorge to group tracing
ADE startup completed.

ADE has been started, enter or run commands using: ade enter

Then if I try ade enter I get the permission denied error:

$ ~/adehome$ ade enter
Entering ade with following images:
pendulum | n/a | ade-base-foxy | ros2realtimedemo/pendulum:ade-base-foxy
OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: chdir to cwd ("/root/ros2_foxy") set in config.json failed: permission denied: unknown
ERROR: Command return non-zero exit code (see above): 126
  docker exec -ti --env COLORFGBG --env TERM -u jorge ade bash -li

The command ade enter -u root works, but entering as root has other side effects: the _pendulumws folder is missing because it was created under home and not on /home/root/:

$ ~/adehome$ ade enter -u root
Entering ade with following images:
pendulum | n/a | ade-base-foxy | ros2realtimedemo/pendulum:ade-base-foxy
root@ade:~# source /opt/ros/foxy/setup.bash
root@ade:~# cd pendulum_ws
bash: cd: pendulum_ws: No such file or directory
root@ade:~# ls
ros2_foxy

I tried to fix this by switching after entering the docker instance to the in this case jorge but then the colcon build command fails:

root@ade:/home/jorge/pendulum_ws# su jorge
jorge@ade:~/pendulum_ws$ colcon build
Starting >>> pendulum2_msgs
Starting >>> pendulum_utils
--- stderr: pendulum2_msgs                                         
CMake Error: The current CMakeCache.txt directory /home/jorge/pendulum_ws/build/pendulum2_msgs/CMakeCache.txt is different than the directory /home/jorge/adehome/pendulum_ws/build/pendulum2_msgs where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
CMake Error: The source directory "/home/jorge/adehome/pendulum_ws/src/pendulum/pendulum2_msgs" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
make: *** [Makefile:1468: cmake_check_build_system] Error 1
---
Failed   <<< pendulum2_msgs [0.14s, exited with code 2]
Aborted  <<< pendulum_utils [0.12s]

Summary: 0 packages finished [0.37s]
  1 package failed: pendulum2_msgs
  1 package aborted: pendulum_utils
  2 packages had stderr output: pendulum2_msgs pendulum_utils
  6 packages not processed
jorge@ade:~/pendulum_ws$ 

I hope this information helps. I wish I could help or suggest a little bit more, but I 'm still a beginner on Docker and ROS2.

carlossvg commented 3 years ago

@LanderU Any progress with this? We could update the instructions to use https://gitlab.apex.ai/apex.ai-public/ros2-ade. What do you think?

LanderU commented 3 years ago

@carlossvg, since I'm not able to reproduce the error on my environment I'll suggest to use ros2-ade to see if the problem persists.

@george-DLJ, sorry for the silence. Could you please use https://gitlab.apex.ai/apex.ai-public/ros2-ade? You can use https://gitlab.apex.ai/apex.ai-public/ros2-ade/-/blob/master/.aderc-foxy to build this project.

Let me know if you've any question.

george-DLJ commented 3 years ago

thank you @carlossvg and @LanderU for your support. I tried what you suggested. I installed ros2-ade (Foxy) on my ~/adehome/ folder. Now it contains following three directories:

AutowareAuto
pendulum_ws
ros2_foxy 

Were _ros2foxy is where I installed the ros2-ade.

Following I reproduce the steps followed to fix the issue:

  1. used to install https://gitlab.apex.ai/apex.ai-public/ros2-ade. Making the necessary chantes toinstall 'foxy' distribution instead 'rolling':
    1. set up the directory inside ~/ade-home that will contain the ROS 2 source code.
mkdir -p ~/adehome/ros2_foxy/src
cd ~/adehome/ros2_foxy
wget https://gitlab.apex.ai/apex.ai-public/ros2-ade/-/raw/master/.aderc-foxy -O .aderc
2. checked out the ROS 2 sources. (The ade$ prompt shows which lines run inside ADE container):
env ADE_NAME=ros2_foxy ade start --update --enter
ade$ cd ros2_foxy
ade$ wget https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos
ade$ vcs import src < ros2.repos
3. finally I build ROS2 foxy on the container: 
ade$ cd ros2_rolling
ade$ colcon build --symlink-install --merge-install
  1. Then I added the https://gitlab.apex.ai/apex.ai-public/ros2-ade/-/blob/master/.aderc-foxy .aderc-foxy file on pendulum_ws/src/pendulum/ade/.aderc-foxy folder and followed ros2-realtime-demo/pendulum instructions using the new aderc-foxy file instead:
cd adehome
$ ade --rc pendulum_ws/src/pendulum/ade/.aderc-foxy start --update --enter

Now I can get in the ade$ container:

ade$ source /opt/ros/foxy/setup.bash
ade$ colcon build
beacause on the ade$ container the `/opt` folder is empty 
ade$ cd pendulum_ws
ade$ colcon build
ade$ cd ~
ade$ colcon build

I understand, that it is very difficult to find a solution to my issue if you cannot reproduce the problem. I suggest we close the issue. However I still want to try the example without "dockers" and I would appreciate that you publish the "Installation from source" instructions. I found working with docker containers very confusing. Let me know when you update those instructions and I give the pendulum another try! Thanks for your support!

LanderU commented 3 years ago

@george-DLJ, I'll be working on this over the weekend. I'm going to update the repo with the exact instructions to use it.

LanderU commented 3 years ago

@george-DLJ, here are the instructions to use ros2-ade:

mkdir ~/ade-home
cd ~/ade-home
touch .adehome
wget https://gitlab.apex.ai/apex.ai-public/ros2-ade/-/raw/master/.aderc-foxy -O .aderc
ade start --enter
ade$ mkdir -p pendulum_ws/src
ade$ cd pendulum_ws/src/
ade$ git clone -b foxy https://github.com/ros2-realtime-demo/
ade$ cd ~/pendulum_ws
ade$ export ROS_DISTRO=foxy
ade$ sudo apt-get update && rosdep update
ade$ rosdep install -q -y --from-paths . --ignore-src
ade$ source /opt/ros/foxy/setup.bash
ade$ colcon build --merge-install

Hope this helps.

LanderU commented 3 years ago

@carlossvg, if @george-DLJ confirm that previous steps works for him, I'll go ahead and deprecate our ADE configs and use ros2-ade and extend the image automatically for our use case.

george-DLJ commented 3 years ago

sorry guys for the late answer. And thanks for your support!

@LanderU I've tested your new instructions. They work although I had to fix a couple of issues (see below) but I still cannot launch the demo (see the error at the end).

  1. ade$ git clone -b foxy https://github.com/ros2-realtime-demo/ returned repository not found error. The git file is missing. Adding the pendulum.git file to the path solved it:

    ade$ git clone -b foxy https://github.com/ros2-realtime-demo//pendulum.git
  2. Then ade$ rosdep install -q -y --from-paths . --ignore-src returnend following error:

    executing command [sudo -H apt-get install -y -qq ros-foxy-launch-ros]
    E: Unable to locate package ros-foxy-launch-ros
    ERROR: the following rosdeps failed to install
    apt: command [sudo -H apt-get install -y -qq ros-foxy-launch-ros] failed

    I noticed there is an 'invalid signature error' on apt-get that has disabled the access to ros2 repository:

    ade$ sudo apt-get update

    Returned: Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease Hit:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
    Hit:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease
    Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
    Get:5 http://packages.ros.org/ros2/ubuntu focal InRelease [4,670 B] Err:5 http://packages.ros.org/ros2/ubuntu focal InRelease The following signatures were invalid: EXPKEYSIG F42ED6FBAB17C654 Open Robotics info@osrfoundation.org Reading package lists... Done W: GPG error: http://packages.ros.org/ros2/ubuntu focal InRelease: The following signatures were invalid: EXPKEYSIG F42ED6FBAB17C654 Open Robotics info@osrfoundation.org E: The repository 'http://packages.ros.org/ros2/ubuntu focal InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.

    After googling, I found out this issue is related to the recent expiration of the ROS GPG keys (see: https://discourse.ros.org/t/ros-gpg-key-expiration-incident/20669). As described on the article I updated the ROS2 GPG key and could continue:

ade$ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

After update the GPG key I could run the rosdep install ... succesfully:

ade$ rosdep install -q -y --from-paths . --ignore-src
# [...]
executing command [sudo -H apt-get install -y -qq ros-foxy-ament-cmake-gmock]
#All required rosdeps installed successfully
  1. colcon build --merge-install returned following output:
    
    ade$ colcon build --merge-install
    Starting >>> pendulum2_msgs
    Starting >>> pendulum_utils
    Finished <<< pendulum_utils [2.86s]                                    
    Finished <<< pendulum2_msgs [7.30s]                     
    Starting >>> pendulum_controller
    Starting >>> pendulum_driver
    Starting >>> pendulum_state_publisher                             
    Finished <<< pendulum_state_publisher [9.46s]                                
    Finished <<< pendulum_driver [14.4s]                                          
    Finished <<< pendulum_controller [15.6s]                       
    Starting >>> pendulum_demo
    Finished <<< pendulum_demo [4.58s]                      
    Starting >>> pendulum_bringup
    Finished <<< pendulum_bringup [0.96s]                   
    Starting >>> pendulum
    Finished <<< pendulum [0.91s]                   

Summary: 8 packages finished [29.5s]


5. Although I could successfulyl run all commands from @LanderU message, I still cannot launch the demo: 

```bash
ade$ source /opt/ros/foxy/setup.bash
ade$ cd ~/pendulum_ws
ade$ source ./install/setup.bash
ade$ ros2 launch -s pendulum_bringup pendulum_bringup.launch.py
 usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...
ros2: error: argument Call `ros2 <command> -h` for more detailed usage.: invalid choice: 'launch' (choose from 'daemon', 'extension_points', 'extensions', 'pkg', 'run', 'test')

How can I solve this last error?

Thanks again for your support!

carlossvg commented 3 years ago

@george-DLJ @LanderU Hmm, maybe a dependency is missing. I'll take a look and see why your'e getting this error.

Thanks for reporting these issues, this helps us to improve the demo!

LanderU commented 3 years ago

@carlossvg @george-DLJ, I'm investigating this at this moment. I'll update here my findings. BTW, thanks a lot for testing it out @george-DLJ

LanderU commented 3 years ago

@george-DLJ @carlossvg, there is a missing dep, I'll open an PR to fix that. Here the steps recorded on my terminal

https://asciinema.org/a/yFNg30bsLabQIgPU2g2bAx9xi

carlossvg commented 3 years ago

@LanderU Nominated to the best bash awards :) Thanks!

george-DLJ commented 3 years ago

Thank you @LanderU and @carlossvg for the updates and support! After following the steps on @LanderU video now it's running! :)

20210607_rviz_inverted_pendulum_screenshot

Following I reproduce all the steps that worked for me, starting from the scratch. (just in case someone is having the same issues I had):

$ mkdir ~/ade-home
$ cd ~/ade-home
$ touch .adehome
$ wget https://gitlab.apex.ai/apex.ai-public/ros2-ade/-/raw/master/.aderc-foxy -O .aderc
# NOTICE: in my case .aderc-foxy is renamed to .aderc and it is located on path:  ~/ade-home/.aderc
$ source .aderc
$ ade start --update
$ ade enter
ade$ mkdir -p pendulum_ws/src
ade$ cd pendulum_ws/src/
ade$ git clone -b foxy https://github.com/ros2-realtime-demo/
ade$ cd ~/pendulum_ws
ade$ export ROS_DISTRO=foxy
ade$ sudo apt-get update && rosdep update
ade$ cd ~/pendulum_ws
ade$ ls 
# NOTICE: run following delete command only when the folder already contains / build /install /log folders from previous build!
ade$ rm -rf build/ install/ log/ 
# NOTICE: (optional) Check if repository is up to date:
ade$ cd ~/pendulum_ws/src/pendulum
ade$ git diff
# git diff will show nothing if repository contains latest changes.
ade$ cd ~/pendulum_ws/
ade$ rosdep install -q -y --from-paths . --ignore-src --rosdistro foxy
ade$ source /opt/ros/foxy/setup.bash
ade$ colcon build --merge-install
ade$ source install/setup.bash
ade$ ros2 launch pendulum_bringup pendulum_bringup.launch.py rviz:=True
# if everything work properly the rviz should open on a separate window with similar content to the image above. 
# Use CTRL+C to exit rviz.
# Do not forget to exit and stop the container:
ade$  exit
$ ade stop

Best Regards!