1、使用Win32DiskImager安装镜像到sd卡
1、将SD卡插入读卡器,连接电脑,查看设备盘符。
2、下载Win32DiskImager,安装 https://sourceforge.net/projects/win32diskimager/
3、下载官方镜像 https://www.raspberrypi.org/downloads/
4、以管理员身份运行Win32DiskImager,选择已下载好的镜像,选择相应的SD卡盘符。
5、点击Write,等待烧写完成。
6、退出Win32DiskImager,弹出SD卡。
7、将SD卡连接到电脑上并打开boot,直接新建“SSH”文件(无后缀)即可,如下图
2、windows连接树莓派
网络共享
1、连接树莓派和笔记本网线口
在无线的wifi下右键选择属性
选择 共享选项卡
2、win+r 打开运行窗口,输入cmd
输入 arp -a 查看树莓派的ip地址。
然后打开Xshell 来连接树莓派,如下图所示,默认用户名为pi 密码为 raspberry
登陆到树莓派后首先安装xrdp。
安装xrdp (使用电脑远程连接树莓派)
sudo apt-get install xrdp
sudo apt-get install vim
安装好xrdp后,我们便可以使用远程桌面进入到树莓派的图形界面。
同样用户名为pi 密码为 raspberry
3、安装ROS环境
更改树莓派源
sudo vim /etc/apt/sources.list
加入
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
Step 1: Install Dependecies and Download the Packages
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake
Then initialize rosdep and update it
sudo rosdep init
rosdep update
如果出现问题:ERROR: cannot download default sources list from:https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list Website may be down.
解决方法sudo vim /etc/hosts
增加:
151.101.76.133 raw.githubusercontent.com
重新开启终端尝试
原文链接https://blog.csdn.net/u010539624/article/details/106785549
When that’s done let’s create a dedicated catkin workspace for building ROS and move to that directory.
mkdir ~/ros_catkin_ws
cd ~/ros_catkin_ws
Desktop Install: includes GUI tools, such as rqt, rviz, and robot-generic libraries.
rosinstall_generator desktop --rosdistro melodic --deps --wet-only --tar > melodic-desktop-wet.rosinstall
wstool init -j8 src melodic-desktop-wet.rosinstall
The command will take a few minutes to download all of the core ROS packages into the src folder. If wstool init fails or is interrupted, you can resume the download by running:
wstool update -j 4 -t src
Step 2: Fix the Issues
Let’s install the compatible version of Assimp (Open Asset Import Library) to fix collada_urdf dependency problem.
mkdir -p ~/ros_catkin_ws/external_src
cd ~/ros_catkin_ws/external_src
wget http://sourceforge.net/projects/assimp/files/assimp-3.1/assimp-3.1.1_no_test_models.zip/download -O assimp-3.1.1_no_test_models.zip
unzip assimp-3.1.1_no_test_models.zip
cd assimp-3.1.1
cmake .
make
sudo make install
Let’s also install OGRE for rviz
sudo apt-get install libogre-1.9-dev
Next we use the rosdep tool for installing all the rest of the dependencies:
cd ~/ros_catkin_ws
rosdep install --from-paths src --ignore-src --rosdistro melodic -y
Step 3: Build and Source the Installation
Once it has completed downloading the packages and resolving the dependencies you are ready to build the catkin packages. If you’re using raspberry Pi 3, you need to increase the swap size first. If you are using raspberry Pi 4, skip this step.
sudo mkdir /swap
cd /swap
sudo dd if=/dev/zero of=swapfile bs=1024 count=2000000
sudo mkswap swapfile
sudo swapon swapfile
cd ~/ros_catkin_ws
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/melodic -j2
Now ROS Melodic should be installed on your Raspberry Pi 4. We’ll source the new installation with following command:
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
Try launching roscore to check if everything was successful.
roscore
Step 4:ROS Driver Compile
sudo apt-get install libudev-dev
sudo apt remove gccsudo apt install -y g++-5 gcc-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gccsudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
Before doing the following, make sure that the Kinetic version ROS environment and wiringPi are installed correctly. wiringPi updated to 2.52 for the Raspberry Pi 4B.
cd /tmp
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
Check with
gpio -v
Step 5:启用串口ttyS0
sudo raspi-config
打开系统配置界面
选择Inerfacing Options
然后选择 serial
然后选择Yes
最后选择保存,退出即可。
reboot重启树莓派,重启过程中请勿断开树莓派的电源。
reboot
查看串口映射关系
ls -l /dev
serial0是GPIO引脚对应的串口,serial1是蓝牙对应的串口。
因此代码中写 /dev/ttyS0