DonkeyCar for JetRacer Pro 教程一、Jetson nano安装

来自Waveshare Wiki
跳转至: 导航搜索

DonkeyCar for JetRacer Pro 教程目录

步骤1、安装依赖

默认你的jetson nano已经安装镜像并启动。打开控制终端,输入如下命令安装依赖库

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
sudo apt-get install -y python3-dev python3-pip
sudo apt-get install -y libxslt1-dev libxml2-dev libffi-dev libcurl4-openssl-dev libssl-dev libpng-dev libopenblas-dev
sudo apt-get install -y git nano
sudo apt-get install -y openmpi-doc openmpi-bin libopenmpi-dev libopenblas-dev

步骤2、设置虚拟环境

pip3 install virtualenv
python3 -m virtualenv -p python3 env --system-site-packages
echo "source env/bin/activate" >> ~/.bashrc
source env/bin/activate  #进入虚拟环境
*注意:之后donkeycar所以操作都需要在此虚拟环境中进行,新开的终端如没有进入虚拟环境中需要运行source env/bin/activate命令进入此虚拟环境。

步骤3、安装python依赖库

  • 通过pip安装依赖库。
pip3 install -U pip testresources setuptools
pip3 install -U futures==3.1.1 protobuf==3.12.2 pybind11==2.5.0
pip3 install -U cython==0.29.21 pyserial
pip3 install -U future==0.18.2 mock==4.0.2 h5py==2.10.0 keras_preprocessing==1.1.2 keras_applications==1.0.8 gast==0.3.3
pip3 install -U absl-py==0.9.0 py-cpuinfo==7.0.0 psutil==5.7.2 portpicker==1.3.1 six requests==2.24.0 astor==0.8.1 termcolor==1.1.0 wrapt==1.12.1 google-pasta==0.2.0
pip3 install -U gdown

# This will install tensorflow as a system package
pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v45 tensorflow==2.3.1
  • 安装PyTorch
wget https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl
cp p57jwntv436lfrd78inwl7iml6p13fzh.whl torch-1.8.0-cp36-cp36m-linux_aarch64.whl
pip3 install torch-1.8.0-cp36-cp36m-linux_aarch64.whl
sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
mkdir -p ~/projects; cd ~/projects
git clone -b v0.9.0 https://github.com/pytorch/vision torchvision
cd torchvision 
python setup.py install
cd ../

步骤4、安装Donkeycar Python代码

  • 从Github获取最新的donkeycar程序
cd ~/projects
git clone https://github.com/autorope/donkeycar
cd donkeycar
git checkout master
pip install -e .[nano]
pip install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.13.1+nv19.3

步骤5、从模板创建Donkeycar

  • 使用以下命令创建donkeycar实例
donkey createcar --path ~/mycar

程序运行后~/mycar目录下回自动生成一系列控制donkeycar的文件。

  • 打开如下文件,找到摄像头参数设置部分修改摄像头参数
nano myconfig.py

Jetson Nano使用基于Sony IMX219的相机,摄像头改为CSIC,分辨率设置为224*224.

#CAMERA
CAMERA_TYPE = "CSIC"   # (PICAM|WEBCAM|CVCAM|CSIC|V4L|MOCK)
IMAGE_W = 224
IMAGE_H = 224