<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ps4手柄ros驱动安装和蓝牙配对教程]]></title><description><![CDATA[<p dir="auto">ps4手柄有丰富的led指示，带摇杆和振动，同时还有触摸板，是个比较理想的机器人遥控手柄。在ROS中使用ps4手柄，主要涉及的步骤是蓝牙配对和ros驱动安装启动。</p>
<h3>1. ps4手柄与ubuntu进行蓝牙配对</h3>
<p dir="auto">ps4手柄和ubuntu之间只用配对一次，之后就可以跳过配对步骤直接连接。<br />
同时长按ps4手柄的share键 和 ps键，手柄开始快速闪短暂的白灯后就进入配对模式，此时可以松手。<br />
<video src="/assets/uploads/files/1623202416912-1d05dfcd0ea13102e7746b698d4a40f8.mp4" controls style="max-width:100%"></video><br />
在手柄保持闪烁白光情况下，进入ubuntu蓝牙管理界面里面，可以看到一个叫wireless Controller的蓝牙设备，这个就是ps4手柄，点击它进行配对。有些ubuntu系统是要通过手动添加蓝牙设备方式进行配对的，界面上有+ -号。<br />
<video src="/assets/uploads/files/1623203311671-20210608_100633.mp4" controls style="max-width:100%"></video><br />
配对成功后，手柄led会停止闪烁，同时颜色变成蓝色。<br />
<video src="/assets/uploads/files/1623202572088-94602711fbf37f646f69a676b549cd02.mp4" controls style="max-width:100%"></video><br />
手柄和ubuntu的蓝牙配对就完成了。</p>
<h3>2. ps4手柄与ubuntu进行蓝牙连接</h3>
<p dir="auto">上面步骤1完成后，手柄与ubuntu就已经连上了，如果ubuntu重启了或者手柄掉线，就需要重新连接。<br />
重新连接很简单，只需要按一下ps键，让手柄进入连接模式，此时手柄会闪白光，白光持续时间比配对时的长。<br />
<video src="/assets/uploads/files/1623202662222-cdf7cf020c357ba9548b29411ad51a9d.mp4" controls style="max-width:100%"></video><br />
ubuntu不用进行任何操作，手柄就会连上ubuntu，连上后手柄led会停止闪烁，同时颜色变成蓝色。<br />
<img src="/assets/uploads/files/1623202733917-94602711fbf37f646f69a676b549cd02.jpg" alt="94602711fbf37f646f69a676b549cd02.jpg" class=" img-responsive img-markdown" width="224" height="398" /><br />
如果白灯熄灭前，也没连上ubuntu，可以等白灯熄灭后再次按ps键，再次尝试连接。蓝牙适配器性能不同，有时需要按两三次才能连上。</p>
<h3>3. ROS驱动安装</h3>
<p dir="auto">ps4手柄的ros驱动包是ds4_driver，依赖于ds4drv这个python库。</p>
<pre><code>#先安装ds4drv库,同时设置udev规则
cd ~/Documents
git clone http://git.bwbot.org/publish/ds4drv --branch devel
cd ds4drv
#安装
sudo python setup.py install 
#拷贝设置udev规则文件
sudo cp udev/50-ds4drv.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger
</code></pre>
<pre><code>#再安装ds4_driver这个ros驱动包
cd ~/Documents/ros/src #这里要换成自己的ros工作空间
git clone http://git.bwbot.org/publish/ds4_driver.git
cd ..
#开始编译
catkin_make -DCMAKE_BUILD_TYPE=Release -DCATKIN_WHITELIST_PACKAGES="ds4_driver"
</code></pre>
<h3>4. 测试ROS驱动</h3>
<pre><code># 用roslaunch启动ds4_driver
roslaunch ds4_driver xiaoqiang.launch
#手柄如果连接上ubuntu，上面launch运行窗口会显示Connected to bluetooth controller， 像下图一样。
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1623203381968-ds4drv.jpg" alt="ds4drv.JPG" class=" img-responsive img-markdown" width="1135" height="623" /></p>
<pre><code># 此时打印/joy 话题，同时按手柄任意按钮，可以观察到/joy话题中对应按钮值发生变化
rostopic echo /joy
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1623203398230-joy.jpg" alt="joy.JPG" class=" img-responsive img-markdown" width="743" height="382" /></p>
<h3>5. 将ROS驱动设成开机自启动</h3>
<p dir="auto">利用ubuntu的startup application功能，添加桌面登录后自动启动功能，下次ubuntu重启后，ds4_driver会自动启动，连上手柄后就可以控制/joy话题发布。<br />
<img src="/assets/uploads/files/1623203462655-startup0.jpg" alt="startup0.JPG" class=" img-responsive img-markdown" width="641" height="237" /><br />
ds4_driver包里面的upstart文件夹，里面有一个文本文档，将文本文档里面的命令复制到ubuntu里面的startup application项目即可。<br />
<img src="/assets/uploads/files/1623203421027-startup.jpg" alt="startup.JPG" class=" img-responsive img-markdown" width="1061" height="496" /></p>
<h3>6.安装turtlebot_teleop包，将手柄/joy话题转换成/cmd_vel速度话题</h3>
<pre><code>cd ~/Documents/ros/src #这里要换成自己的ros工作空间
git clone http://git.bwbot.org/publish/turtlebot --branch melodic
cd ..
#开始编译
catkin_make -DCMAKE_BUILD_TYPE=Release -DCATKIN_WHITELIST_PACKAGES="turtlebot_teleop"
</code></pre>
<pre><code>#开始运行
 roslaunch turtlebot_teleop ps3fakexiaoqiang_teleop.launch
#打印/cmd_vel话题，连上手柄后，保持按住手柄油门键（下图中的１０号键），现在使用左侧的推杆可以控制cmd_vel话题的前后移动和转向（下图中的１＋１－摇杆）
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1623203516572-teleop.jpg" alt="teleop.JPG" class=" img-responsive img-markdown" width="971" height="533" /><br />
<img src="/assets/uploads/files/1623203486373-cmd.jpg" alt="cmd.JPG" class=" img-responsive img-markdown" width="938" height="335" /><br />
<img src="/assets/uploads/files/1623231378801-ds4_glacier_white_top.png" alt="DS4_Glacier_White_top.png" class=" img-responsive img-markdown" width="849" height="517" /><br />
turtlebot_teleop 也可以设成开机自动启动，设置步骤参考上面的步骤5。</p>
<h3>7.常见问题</h3>
<pre><code>1.ps4手柄和ubuntu无法连接
答：之前有没有配对成功，没有配对成功要先确保配对成功。
2.ps4手柄和ubuntu无法连接
答：等白灯熄灭后，再次按ps键尝试连接，因为蓝牙适配器性能原因，有时要尝试两三次才能连上，这是正常现象。
3.ps4手柄和ubuntu无法连接
答：配对成功后，如果再次同时按了share和ps键，会清除手柄的配对信息，此时需要先在ubuntu里面删除叫wireless Controller的蓝牙设备，然后重启执行步骤1的配对。
</code></pre>
<h3>8.PS4手柄按钮编号</h3>
<p dir="auto"><img src="/assets/uploads/files/1623231153227-ds4_0.jpg" alt="ds4_0.jpg" class=" img-responsive img-markdown" width="500" height="500" /><br />
<img src="/assets/uploads/files/1623231171418-ds4_3.jpg" alt="ds4_3.jpg" class=" img-responsive img-markdown" width="474" height="316" /><br />
<img src="/assets/uploads/files/1623231266919-ds4_1.jpg" alt="ds4_1.jpg" class=" img-responsive img-markdown" width="794" height="529" /></p>
]]></description><link>http://community.bwbot.org/topic/16454/ps4手柄ros驱动安装和蓝牙配对教程</link><generator>RSS for Node</generator><lastBuildDate>Fri, 16 Oct 2026 08:59:15 GMT</lastBuildDate><atom:link href="http://community.bwbot.org/topic/16454.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 08 Jun 2021 03:00:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Mon, 24 Feb 2025 14:54:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/1935">@看结果吧</a> hosts文件设置错误，可以咨询gpt获取修改意见</p>
]]></description><link>http://community.bwbot.org/post/17477</link><guid isPermaLink="true">http://community.bwbot.org/post/17477</guid><dc:creator><![CDATA[xiaoqiang]]></dc:creator><pubDate>Mon, 24 Feb 2025 14:54:38 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Sun, 23 Feb 2025 01:56:34 GMT]]></title><description><![CDATA[<p dir="auto"><img src="/assets/uploads/files/1740275792040-%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20250223095534-resized.jpg" alt="微信图片_20250223095534.jpg" class=" img-responsive img-markdown" /></p>
]]></description><link>http://community.bwbot.org/post/17475</link><guid isPermaLink="true">http://community.bwbot.org/post/17475</guid><dc:creator><![CDATA[看结果吧]]></dc:creator><pubDate>Sun, 23 Feb 2025 01:56:34 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Sun, 23 Feb 2025 01:51:49 GMT]]></title><description><![CDATA[<p dir="auto">第四步测试ros驱动 运行launch文件报错</p>
]]></description><link>http://community.bwbot.org/post/17476</link><guid isPermaLink="true">http://community.bwbot.org/post/17476</guid><dc:creator><![CDATA[看结果吧]]></dc:creator><pubDate>Sun, 23 Feb 2025 01:51:49 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Wed, 16 Aug 2023 05:53:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/20">@xiaoqiang</a> 好的，谢谢博主，我去反应一下</p>
]]></description><link>http://community.bwbot.org/post/17256</link><guid isPermaLink="true">http://community.bwbot.org/post/17256</guid><dc:creator><![CDATA[cuiliyun]]></dc:creator><pubDate>Wed, 16 Aug 2023 05:53:22 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Wed, 16 Aug 2023 05:29:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/1687">@cuiliyun</a> ps4手柄有多款山寨版本，有些版本就会能蓝牙配对但是无法使用ros。包装盒有大小两款，小盒子的一般是用不了的垃圾，大盒子能用的概率比较大，原厂原装的最好。</p>
]]></description><link>http://community.bwbot.org/post/17255</link><guid isPermaLink="true">http://community.bwbot.org/post/17255</guid><dc:creator><![CDATA[xiaoqiang]]></dc:creator><pubDate>Wed, 16 Aug 2023 05:29:20 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Wed, 16 Aug 2023 05:16:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/20">@xiaoqiang</a> 是公司的手柄，不是新的 用了有段时间了</p>
]]></description><link>http://community.bwbot.org/post/17254</link><guid isPermaLink="true">http://community.bwbot.org/post/17254</guid><dc:creator><![CDATA[cuiliyun]]></dc:creator><pubDate>Wed, 16 Aug 2023 05:16:28 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Wed, 16 Aug 2023 05:05:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/1687">@cuiliyun</a> 手柄是哪里采购的？</p>
]]></description><link>http://community.bwbot.org/post/17253</link><guid isPermaLink="true">http://community.bwbot.org/post/17253</guid><dc:creator><![CDATA[xiaoqiang]]></dc:creator><pubDate>Wed, 16 Aug 2023 05:05:54 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Wed, 16 Aug 2023 03:53:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/20">@xiaoqiang</a> 可是我感觉已经配对成功了，我照着流程来，现在手柄led也是亮着蓝光，蓝牙那里也显示已经连接上了</p>
]]></description><link>http://community.bwbot.org/post/17252</link><guid isPermaLink="true">http://community.bwbot.org/post/17252</guid><dc:creator><![CDATA[cuiliyun]]></dc:creator><pubDate>Wed, 16 Aug 2023 03:53:40 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Wed, 16 Aug 2023 02:37:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/1687">@cuiliyun</a> 手柄配对没成功，先配对</p>
]]></description><link>http://community.bwbot.org/post/17251</link><guid isPermaLink="true">http://community.bwbot.org/post/17251</guid><dc:creator><![CDATA[xiaoqiang]]></dc:creator><pubDate>Wed, 16 Aug 2023 02:37:28 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Wed, 16 Aug 2023 01:30:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/20">@xiaoqiang</a> 在 <a href="/post/16673">ps4手柄ros驱动安装和蓝牙配对教程</a> 中说：</p>
<blockquote>
<p dir="auto">roslaunch ds4_driver xiaoqiang.launch</p>
</blockquote>
<p dir="auto">博主，我卡在这一步<br />
[INFO] [1692149269.091375]: [hidraw]: Scanning for devices<br />
之后，为就一直在等相应</p>
<h6>Joystick inactive for 3 seconds. Stop publishing joy</h6>
<h6>Joystick inactive for 120 seconds. Disconnecting to save battery</h6>
<p dir="auto">然后也连接不上，请问你知道原因是什么吗</p>
]]></description><link>http://community.bwbot.org/post/17250</link><guid isPermaLink="true">http://community.bwbot.org/post/17250</guid><dc:creator><![CDATA[cuiliyun]]></dc:creator><pubDate>Wed, 16 Aug 2023 01:30:38 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Tue, 18 Apr 2023 02:31:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/1644">@potterson</a> 安装该包之后问题解决，谢谢</p>
]]></description><link>http://community.bwbot.org/post/17138</link><guid isPermaLink="true">http://community.bwbot.org/post/17138</guid><dc:creator><![CDATA[potterson]]></dc:creator><pubDate>Tue, 18 Apr 2023 02:31:07 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Fri, 14 Apr 2023 03:35:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/1644">@potterson</a> 截图完整错误信息</p>
]]></description><link>http://community.bwbot.org/post/17119</link><guid isPermaLink="true">http://community.bwbot.org/post/17119</guid><dc:creator><![CDATA[xiaoqiang]]></dc:creator><pubDate>Fri, 14 Apr 2023 03:35:42 GMT</pubDate></item><item><title><![CDATA[Reply to ps4手柄ros驱动安装和蓝牙配对教程 on Thu, 13 Apr 2023 02:10:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.bwbot.org/uid/20">@xiaoqiang</a> 在 <a href="/post/16673">ps4手柄ros驱动安装和蓝牙配对教程</a> 中说：</p>
<blockquote>
<ol start="4">
<li>测试ROS驱动</li>
</ol>
</blockquote>
<p dir="auto">第四步 4. 测试ROS驱动 roslaunch ds4_driver xiaoqiang.launch 运行之后报错 No module named ‘rospkg’ 咋办呢</p>
]]></description><link>http://community.bwbot.org/post/17115</link><guid isPermaLink="true">http://community.bwbot.org/post/17115</guid><dc:creator><![CDATA[potterson]]></dc:creator><pubDate>Thu, 13 Apr 2023 02:10:42 GMT</pubDate></item></channel></rss>