上传文件至 Docs/2024-11-14
parent
f02aed8f6c
commit
71d8c6d2e7
|
@ -0,0 +1,79 @@
|
||||||
|
PIBOT键盘控制小车运动
|
||||||
|
|
||||||
|
1.在编译过pibot_ros/ros_ws下的代码之后,对pibot底盘进行初始化配置:
|
||||||
|
|
||||||
|
```
|
||||||
|
# 进入PIBot_ROS
|
||||||
|
cd ~/pibot_ros
|
||||||
|
# 给脚本添加可执行的权限
|
||||||
|
chmod +x pibot_init_env.sh
|
||||||
|
# 执行脚本
|
||||||
|
./pibot_init_env.sh
|
||||||
|
# 脚本最后会提示:刷新环境变量使其在当前命令行生效
|
||||||
|
source ~/.bashrc
|
||||||
|
```
|
||||||
|
|
||||||
|
在执行脚本的时候可能会遇到'/usr/bin/env: ‘python\r’: No such file or directory'之类的问题,表示脚本文件中使用了 Windows 风格的换行符(`\r`),而在 Linux 环境中应该使用 Unix 风格的换行符。
|
||||||
|
|
||||||
|
解决办法:可以安装工具dos2unix,用于把Windows风格的换行符转变为unix的风格。
|
||||||
|
|
||||||
|
安装命令:sudo apt-get install dos2unix
|
||||||
|
|
||||||
|
安装无误后,可以将脚本文件转换:dos2unix + [需要转变的文件目录]
|
||||||
|
|
||||||
|
之后就可以正确运行脚本。
|
||||||
|
|
||||||
|
2.在运行脚本的时候,会要求进行选择,与下图类似。
|
||||||
|
|
||||||
|
但是注意,在选择类型的时候要根据实际情况选择,脚本会根据选择配置环境变量,并且会根据驱动板型号设置波特率,而波特率会影响后续操作。在选择之前要确定实际使用的设备和环境,避免后续的错误。
|
||||||
|
|
||||||
|
在本次实验环境中,驱动板类型选择1:stm32f103,其余选择0:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
在脚本运行结束后,运行指令source ~/.bashrc,使得配置生效。
|
||||||
|
|
||||||
|
3.在`pibot_init_env.sh`执行过程中,会将部分串口的设备创建名为`pibot`的软链接。在脚本运行后可以运行指令:ls /dev/pibot -l进行查看,如果创建软连接成功,会出现类似的结果:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
设置权限:find ~/pibot_ros -type f -name "*.py" -exec chmod +x {} \;
|
||||||
|
|
||||||
|
安装依赖:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# 先安装控制所需要的依赖
|
||||||
|
sudo apt-get install ros-noetic-teleop-twist-keyboard
|
||||||
|
# 安装python,一般在前面的步骤就已经安装了
|
||||||
|
sudo apt install -y python3
|
||||||
|
# 创建python的软链接,因为后续的代码执行用到了python xxxx.py
|
||||||
|
sudo ln -s /usr/bin/python3 /usr/bin/python
|
||||||
|
```
|
||||||
|
|
||||||
|
4.此时,能够通过pibot提供的脚本使用键盘控制小车运动:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# 1.先启动pibot_bringup, 它负责pibot底盘的基本通信(必要),或者运行roslaunch pibot_bringup bringup.launch
|
||||||
|
pibot_bringup
|
||||||
|
# 2.启动pibot的配置界面
|
||||||
|
# 或者采用命令 rosrun rqt_reconfigure rqt_reconfigure
|
||||||
|
pibot_configure
|
||||||
|
# 3. 启动小车控制, 或者使用命令 roslaunch pibot keyboard_teleop.launch
|
||||||
|
pibot_control
|
||||||
|
# 4. 通过步骤1和3即可启动小车的控制,如果需采用小米等手柄,运行:
|
||||||
|
roslaunch pibot joystick.launch
|
||||||
|
```
|
||||||
|
|
||||||
|
启动pibot_bringup之后,会显示:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
之后运行pibot_control:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
此时就能够使用键盘控制小车运动,具体控制方式在上图中有具体介绍。
|
||||||
|
|
||||||
|
在按下键盘之后,pibot_bringup中会有如下显示:
|
||||||
|
|
||||||
|

|
Loading…
Reference in New Issue