發表文章

目前顯示的是 2021的文章

How to use pip3 without sudo privileges

圖片
In my case, there are several python3.x version installed in my system before, and I had to type python3.x and sudo pip3 for developing the code every time, which disturbed me.  Here are the methods I tried to solve this problem. Now I am able to type only the python3 command for the newest python3.8 use and pip3 for installing modules without root privileges. python3.x ... -> python3 ... sudo pip3.x install ... -> pip3 install / python3 -m pip install ...  1. Install pip3 locally under /home/$USER/.local/bin/. $ wget https://bootstrap.pypa.io/get-pip.py $ python3 get-pip.py --user 2. Edit ~/.bashrc $ export PATH=$PATH:~/.local/bin $ export PYTHONPATH=$PYTHONPATH:/usr/lib/python3.8/dist-packages $ source ~/.bashrc 3. Delete redundant pip path or error: ModuleNotFoundError: No module named 'pip._vendor.retrying' will be reported. $ sudo rm -r /usr/lib/python3/dist-packages/pip Check: $ python3 --version * Difference between /usr/local and /usr/.local /usr/local is a place

Installing TensorRT on Ubuntu20.04

圖片
1. Install CUDA, cuDNN CUDA: (1) Remove old version sudo apt-get purge nvidia* sudo apt-get autoremove sudo apt-get autoclean sudo rm -rf /usr/local/cuda* (2) Download and install CUDA toolkit 11.3 [1] $ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin $ sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 $ wget https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda-repo-ubuntu2004-11-3-local_11.3.0-465.19.01-1_amd64.deb $ sudo dpkg -i cuda-repo-ubuntu2004-11-3-local_11.3.0-465.19.01-1_amd64.deb $ sudo apt-key add /var/cuda-repo-ubuntu2004-11-3-local/7fa2af80.pub $ sudo apt-get update $ sudo apt-get -y install cuda (3) Check $ cd /usr/local/cuda-11.3/samples/1_Utilities/deviceQuery $ sudo make $ ./deviceQuery ex: cuDNN: (1) Download cuDNN 8.2.1 [2]  (2) Install extract cudnn-11.3-linux-x64-v8.2.1.32.tgz $ cd cuda $ sudo cp cuda/include/cudnn.h /usr/local/cuda-11.3/include/  $ sudo cp cu

Renaming files in linux at once

Problem description: When you have hundreds of files in the folder, and you want to rename them with the same rule... For example, I have images named img0.jpg, img1.jpg, img2.jpg......, and I expect them named img00000.jpg, img00001.jpg, img00002.jpg.  Commands:  $ rename 's/\d+/sprintf("%05d", $&)/e' *.jpg Reference: https://askubuntu.com/questions/473236/renaming-hundreds-of-files-at-once-for-proper-sorting

Prepare a development environment for executing docker image with GPU support

圖片
1. Install Docker Engine [1] $ sudo apt-get remove docker docker-engine docker.io containerd runc $ sudo apt-get update   $ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io 2. Add your account into docker group $ sudo gpasswd -a $USER docker $ sudo reboot 3. Install nvidia-container-runtime [2] $ curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | sudo apt-key add - $ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) $ curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list $ sudo apt update $ sudo apt install nvidia-con

Install GPU driver and CUDA on the ubuntu system

圖片
 1. Check your GPU driver version https://www.nvidia.com/Download/index.aspx ex: Driver 470 is suitable for my note PC (GS65 Stealth 9SE) 2. Open a new terminal $ ubuntu-drivers devices $ sudo apt install nvidia-driver-470 $ sudo apt install nvidia-cuda-toolkit (--fix-missing) $ reboot 3. Check $ nvidia-smi $ nvcc -V

Hardware upgrade & Setup up dual system for msi GS65 Stealth 9SE

圖片
1. Hardware upgrade Memory:  DDR4-2666(PC4-21300) 16GB×2枚 SSD:  インテル®SSD660Pシリーズ SSDPEKNW010T8X1 Before After 2. Setup up dual system (1) Create a USB disk of Ubuntu  Ubuntu image:  https://ubuntu.com/download/desktop Rufus:  https://rufus.ie/zh_TW/ 資料分割配置: GPT 目標系統: UEFI 檔案系統: NTFS  (2) Modify computer configuration and insert the USB Hard Disk, then reboot Fast Startup: Disable Fast Boot: Disable, Boot option: USB Hard Disk Secure Boot: Disable (3) Follow the instruction to install the ubuntu system swap: 48GB ( swap setting ), Logical, Beginning of this space /: the rest of the whole free space, Primary , Beginning of this space, Ext4 *Remember to select the correct bootloader device (4) Use cmd windows to enable grub boot menu ( Run as administrator!!! ) $ bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi Reference: [1]  https://www.cnblogs.com/klchang/p/14322667.html [2]  https://www.youtube.com/watch?v=hT4m71ghD6A [3]  https://www.techiediaries.com/fixing-dual-booting-windows-1

Change docker image storage location to SSD on your NVIDIA Xavier

圖片
1. Install a SSD on the device and give it a mount name [1] 2. Copy docker to the SSD mount folder and add "data-root" parameter in the daemon script. [2] $ sudo service docker stop $ sudo rsync -aP /var/lib/docker/ /path/to/your/docker $ gedit /etc/docker/daemon.json $ sudo mv /var/lib/docker /var/lib/docker.old $ sudo service docker start 3. Pull PyTorch container and run [3] $ docker pull nvcr.io/nvidia/l4t-pytorch:r32.6.1-pth1.9-py3 $ sudo docker run -it --rm --runtime nvidia --network host -v /home/user/project:/location/in/container nvcr.io/nvidia/l4t-pytorch:r32.6.1-pth1.9-py3 Another useful commands:  $ sudo docker info $ sudo docker images $ sudo rmi REPOSITORY:TAG [4] $ cat /etc/nv_tegra_release $ systemctl start docker Reference: [1]  Install Solid State Disk - Jetson AGX Xavier   [2]  https://forums.developer.nvidia.com/t/change-docker-image-storage-location-to-nvme-ssd/156882 [3]  docker pull nvcr.io/nvidia/l4t-pytorch:r32.6.1-pth1.9-py3 [4]  https://docs.docker.

PX4 Flight Log Analysis

圖片
1.  Flight review 2.  pyulog 3. pyFLightAnalysis 4. FlightPLot Reference: [1]  https://logs.px4.io/ [2]  https://github.com/PX4/pyulog [3]  https://github.com/Marxlp/pyFlightAnalysis [4]  https://github.com/PX4/FlightPlot

Steps for recording data for VIO analysis

1. Ground truth: Optitrack system (1) Calibration (2) Set original point (3) Attach reflective ball on the drone and put it in the view of cameras (4) Create a rigid body of the drone Published position is in the topic:   /vrpn_client_node/<rigid body name>/pose 2. Image source: intel realsense r200 $ roscd realsense_camera/ $ cd launch $ roslaunch r200_nodelet_rgbd.launch Published images are in the topic: /camera/rgb/image_raw  /camera/depth/image_raw 3. IMU $ roscd drone_mocap/ $ cd launch $ roslaunch drone_mocap.launch Published IMU datas are in the topic: /mavros/imu/data_raw  /mavros/imu/data *Record:  rosbag record /vrpn_client_node/intelRTF/pose /camera/rgb/image_raw /camera/d epth/image_raw /mavros/imu/data_raw /mavros/imu/data Reference: [1] https://github.com/OsloMet1811/Digital-Twin/tree/master/drone_mocap [2]  https://github.com/intel-aero/meta-intel-aero/wiki/05-Autonomous-drone-programming-with-ROS

Run VIORB and save its result as a .tum output for evo analysis

1. Install VIORB [1] * Solution for the compiling error: " usleep was not declared in this scope " => Add #include <unistd.h> in all the files reported. * Solution for the compiling error: "usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:745:3: error: static assertion failed :" => refer to [2] * Solution for the compiling error about ROS_PACKAGE_PATH : see [3] * Solution for the OpenCV version incompatible issue: modify the written required version in the CMakeLists.txt. (path: ~/LearnVIORB, ~/LearnVIORB/Examples/ROS/ORB_VIO/) 2. Run EuRoC using EuRoC dataset * Modify the desired path in config/euroc.yaml. $ roslaunch testeuroc.launch (~/LearnVIORB/Examples/ROS/ORB_VIO/launch) * Solution for the reported problem " Framebuffer with requested attributes not available " while running:  Reference: [1] https://github.com/jingpang/LearnVIORB [2]  https://www.cnblogs.com/shishiteng/p/5799406.html [3] https://blog.c

Upload a project to github

1. Create a new repository 2. git clone "path of new repository" 3. cd "project name" 4. echo "# project name" >> README.md 5. git init 6. git add README.md 7. move all codes to the path under the project folder 8. git status (optional) 9. git add . 10. git commit -m "first commit" 11. git push / git push --set-upstream origin master *If you got the message: Could not resolve host: github.com key in: $ git config --global --unset http.proxy $ git config --global --unset https.proxy and then restart the linux system, the problem will be solved. Reference: [1]  GitHub 入門(二) — 使用終端機上傳檔案到GitHub [2]  https://markdown.tw/ [3]  GitHub不再支援密碼驗證解決方案,怎麼辦? [4]  使用 Git LFS 上傳大型檔案 [5]  Git Large File Storage - How to Work with Big Files

maplab(2) - multi-session reconstruction

0. Download VI maps from Sample-Datasets  and open maplab console 1. Load all maps load --map_folder <dataset_folder>/euroc_ml1  load --map_folder <dataset_folder>/euroc_ml2  load --map_folder <dataset_folder>/euroc_ml3 2. Select map select_map --map_key euroc_ml1  3. Re-triangulate the landmarks  rtl   4. Optimize the map to get a better initial map state for loop-closure  optvi   5. Run loop closure   lc  6. Run bundle adjustment  optvi  7. Save the optimized map   save --map_folder <dataset_folder>/euroc_ml1_opt 8. Repeat the same for map 2 and 3 Reference: [1]  https://github.com/ethz-asl/maplab/wiki/Preparing-a-multi-session-map [2]  https://github.com/ethz-asl/maplab/wiki/Dense-Reconstruction

Auto flight using a Qualcomm Snapdragon Flight platform (7) - Visual inertial odometry (VIO)

圖片
1. Sensor calibration (1) snav_calibration_manager (2) Navigator SDK (3) RC 2. Configure the VIO parameters and active it (1) Enable VIO in the snav_params.xml (/usr/lib/rfsa/adsp/snav_params.xml) <pos_hold_mode_params>    <param name="enable_vio" value="1"/>    <param name="enable_gps" value="0"/>    <param name="enable_dft" value="0"/> </pos_hold_mode_params> (2)  Configure Qualcomm Navigator to use VIO $ sudo /etc/snav/configure_vio.sh $ snav_dft_vio_app ( *mv_1.1.9 should be installed. ) (3) Check the VIO positioning result $ snav_inspector 3. Record  (1) Machine vision logs Setting the enable_srw_writer parameter in /etc/snav/app_params.snav_dft_vio_app.excelsior to 1 .  MV sequences are logged to /data/logs/snav/mv_sequence Copy data to the host (ex: adb pull /data/logs/snav/mv_sequence/snav_mv_seq_00018/snav_dft_vio_camera/ '/home/shomin/images_

Kalibr: a tool for calibrating camera and IMU

1. Installation (1)  Using the CDE package (2) Building from source 2. Camera calibration (1) Prepare a calibration target. (2) Prepare a image bag file & target.yaml file Command: ./kalibr_calibrate_cameras --target april_intel.yaml --bag rgb_mono.bag --model pinhole-equi --topics /camera/rgb/image_mono Output: camchain-%BAGNAME%.yaml results-cam-%BAGNAME%.txt report-cam-%BAGNAME%.pdf 3. Find IMU parameters (1) From product datasheet (ex: BMI160 ) (2) From the Allan standard deviation (AD) 4. Camera IMU calibration Command: ./kalibr_calibrate_imu_camera --target april_intel.yaml --cam camchain-homenamikidrone2kalibr-cdergb_mono.yaml --imu imu_intel.yaml --bag rgb_mono_imu.bag 5. Convert calibration results to the accessible files in the maplab (1) Building from source *source ~/kalibr_workspace/devel/setup.bash (2) rosrun kalibr kalibr_maplab_config --to-ncamera --label <your_label> --cam <your_cam_chain_yaml> Reference [1]  http