Ubuntu 20.04安装Leap Motion问题总结

安装步骤

Step 1 Download and install V2 Tracking.

1、下载Linux版本的 V2 软件(https://developer.leapmotion.com/legacy-v2/)并解压

2、打开leapd.service文件

sudo gedit/lib/systemd/system/leapd.service

打开后粘贴以下代码

[Unit] 
 
Description=LeapMotionDaemon 
 
After=syslog.target
 
[Service] 
 
Type=simple 
 
ExecStart=/usr/sbin/leapd
 
[Install] 
 
WantedBy=multi-user.target 

3、保存并重新加载

sudo ln -s/lib/systemd/system/leapd.service /etc/systemd/system/leapd.service
systemctldaemon-reload

4 、安装deb文件

sudo dpkg -i Leap-2.3.1+31549-x64.deb

5、运行leapd

sudo leapd #A new terminal
LeapControlPanel #A new terminal
Visualizer #A new terminal

Step 2 Download leap_motion package.

cd YOUR_WORK_SPACE/src
git clone https://github.com/qqfly/leap_motion.git
cd YOUR_WORK_SPACE
catkin_make

Step 3 Export python path.
You must make sure that python can find the essential modules.

source YOUR_WORK_SPACE/devel/setup.bash
export PYTHONPATH=$PYTHONPATH:$HOME/LeapSDK/lib:$HOME/LeapSDK/lib/x64

Step 4 Run the ROS driver. Connect the Leap Motion to your computer.

sudo leapd #A new terminal
LeapControlPanel #A new terminal
cd YOUR_WORK_SPACE
roscore #A new terminal
rosrun leap_motion send.py

Now you can see the data updating in the terminal window. Refer to here for more details.

In addition, if you encounter the following problem:

[Info] Tracking initialized
[Critical] Secure WebSocket server failed to start
[Critical] WebSocket server failed to start
[Critical] Have you tried running as root/Administrator?

after you type

sudo leapd

It’s due to the problem that more than one leapd service is runing. Then you can type

sudo service leapd stop

to stop the leapd service and restart it by leapd.

出现问题

一、leapmotion的驱动文件不支持python3,故最好不在ubuntu 20上安装使用

二、python2、pyrospkg和pyyaml安装

1、安装pip3

sudo apt update
sudo apt install python3-pip

# 安装完之后检查一下是否可用
pip3 -V

2、安装python2

sudo add-apt-repository universe

sudo apt update
sudo apt install python2

# 安装完成之后检查一下是否可用
python2

3、安装pip2

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
sudo python2 get-pip.py

# 安装完之后检查一下是否可用
pip2 -V

4、安装rospkg

sudo pip2 install rospkg

5、安装pyyaml

sudo pip2 install pyyaml

三、python2与python3切换

1、查看已安装的python版本

ls /usr/bin/python*

2、查看系统中是否有python配置选项

sudo update-alternatives --list python

3、第1步中看到了系统有python2和python3两个版本,下面配置python选项

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2

4、python版本切换

python --version
sudo update-alternatives --config python

四、【python】错误SyntaxError: invalid syntax的解决方法总结

报错

import rospy
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/__init__.py", line 49, in <module>
    from .client import spin, myargv, init_node, \
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/client.py", line 60, in <module>
    import rospy.impl.init
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/init.py", line 54, in <module>
    from .tcpros import init_tcpros
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros.py", line 45, in <module>
    import rospy.impl.tcpros_service
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 54, in <module>
    from rospy.impl.tcpros_base import TCPROSTransport, TCPROSTransportProtocol, \
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_base.py", line 160
    (e_errno, msg, *_) = e.args
                   ^
SyntaxError: invalid syntax

具体方法

cd opt/ros/noetic/lib/python3/dist-packages/rospy/impl
sudo gedit tcpros_base.py

此时会打开相应文档,按照报错找到相应行,将原本的(e_errno, msg, *_) = e.args 改为(e_errno, msg) = e.args

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值