rosserial是用于非ROS设备与ros设备进行通信的协议。
为非ROS 设备的应用程序提供了ROS节点和服务的发布/订阅功能。可通过串口或网络与ROS应用数据交互。
rosserial分为客户端和服务器两部分。rosserial客户端运行在运行在没有安装ROS的环境的应用中,通过串口或网络与运行在ROS
环境中的rosserial服务器连接,并通过服务器节点在ROS中发布/订阅话题。
链接:
https://blog.youkuaiyun.com/scx837685002/article/details/102770753
https://blog.youkuaiyun.com/ZhangRelay/article/details/101011276rs
rosserial 官网
环境是:TX2、ubuntu18.04、melodic
1
lsusb
2
ls -l /dev/ttyUSB0
3、串口赋权 : sudo chmod 777 /dev/ttyUSB0
4\
cmake_minimum_required(VERSION 3.0.2)
project(riki_msgs)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
message_generation
std_msgs
geometry_msgs
)
## Generate messages in the 'msg' folder
add_message_files(
# FILES
# Message1.msg
# Message2.msg
DIRECTORY msg
FILES
Velocities.msg
PID.msg
Imu.msg
Battery.msg
DHT22.msg
Servo.msg
Infrared.msg
Ultrasonic.msg
)
generate_messages(
# DEPENDENCIES
# std_msgs # Or other packages containing msgs
DEPENDENCIES
std_msgs
geometry_msgs
)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES riki_msgs
# CATKIN_DEPENDS roscpp rospy
# DEPENDS system_lib
CATKIN_DEPENDS
message_runtime
std_msgs
geometry_msgs
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
5\
<?xml version="1.0"?>
<package format="2">
<name>riki_msgs</name>
<version>0.0.0</version>
<description>The riki_msgs package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="robot@todo.todo">robot</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/riki_msgs</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<build_depend>message_generation</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<exec_depend>message_runtime</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
4、保证已下载rosserial_python包
下载命令是:
sudo apt-get install ros-melodic-rosserial-python
卸载包的命令是:
sudo apt-get purge ros-melodic-rosserial-python
5、运行
rosrun rosserial_python serial_node.py _port:=/dev/ttyUSB0 _baud:=115200
未完待续。。。