ROS 进阶学习笔记(15) - Use Service to play ROS-Serial communication

2024-01-23 03:08

本文主要是介绍ROS 进阶学习笔记(15) - Use Service to play ROS-Serial communication,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Use Service to play ROS-Serial communication

Continue for this blog :

ROS 进阶学习笔记(12) - Communication with ROS through USART Serial Port

In that blog above, we discussed ROS-Serial communication through r2serial_driver node (C++). There is a problem that the r2serial made too much cpu expenses. Like below:


----------

 Kevin mentioned a question: "Interesting, but a lot of my serial stuff is send a message and receive a response back. Instead of separate publish/subscribes. have you tried a service? That seems like it would work nicely for this."

I also noticed a problem: MY Linux's System RAM and CPU seems to be much costed by r2serial_driver when it is running.

This time, we'll see how to use Kevin's service to play ROS serial communication.

Use Service to play ROS-Serial communication

=============

-- Check out and compile this package --

Use this commands to check out the rosbuild package (rather than catkin package), androsmakethem:

exbot@my_robot:~/rosbuild_ws$ cd sandbox/
exbot@my_robot:~/rosbuild_ws/sandbox$ git clone https://github.com/walchko/serial_node
exbot@my_robot:~/rosbuild_ws/sandbox$ cd serial_node/
exbot@my_robot:~/rosbuild_ws/sandbox/serial_node$ rosmake
...
...
[ rosmake ] /home/exbot/.ros/rosmake/rosmake_output-20160511-173021             exbot@my_robot:~/rosbuild_ws/sandbox/serial_node$ rospack find serial_node
/home/exbot/rosbuild_ws/sandbox/serial_node
exbot@my_robot:~/rosbuild_ws/sandbox/serial_node$roscore && rosrun serial_node serial_node 0 /dev/ttyUSB0 9600 true[ INFO] [1462959095.157208573]: Service uc0_serial on /dev/ttyUSB0 @ 9600 baud

We can see the expense of serial_node by command "top": [ The expenses has been very small. ]


====================================================================================

-- How to use this service for our works --

1.  Understand what is ros service:

  • Here, I recommend the newer of ROS to read four links carefully and understand them as deep as you can:
  • http://wiki.ros.org/ROS/Tutorials/UnderstandingServicesParams#Using_rosservice
    Above, you need to understand the service_node need a request and will give back a response.

    http://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv#Using_srv
    Above, you need to understand the .srv file defines the data type of req. and rep.

    http://wiki.ros.org/ROS/Tutorials/WritingServiceClient%28c%2B%2B%29
    Above, you need to understand the key points of a source code for an ROS Service node.

    http://wiki.ros.org/ROS/Tutorials/ExaminingServiceClient
    Above, describes the source code for client to examine if the service node works fine.


2.  Read the source code of "serial_node_service.cpp" and use "rosservice call" command to test it

          run the service by:

        > $ rosrun seal_node serial_node 0 /dev/ttyUSB0 9600 true

          call this service by (open another terminal):

        > $ rosservi

这篇关于ROS 进阶学习笔记(15) - Use Service to play ROS-Serial communication的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/635060

相关文章

深度解析Python装饰器常见用法与进阶技巧

《深度解析Python装饰器常见用法与进阶技巧》Python装饰器(Decorator)是提升代码可读性与复用性的强大工具,本文将深入解析Python装饰器的原理,常见用法,进阶技巧与最佳实践,希望可... 目录装饰器的基本原理函数装饰器的常见用法带参数的装饰器类装饰器与方法装饰器装饰器的嵌套与组合进阶技巧

MybatisPlus service接口功能介绍

《MybatisPlusservice接口功能介绍》:本文主要介绍MybatisPlusservice接口功能介绍,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友... 目录Service接口基本用法进阶用法总结:Lambda方法Service接口基本用法MyBATisP

从基础到进阶详解Pandas时间数据处理指南

《从基础到进阶详解Pandas时间数据处理指南》Pandas构建了完整的时间数据处理生态,核心由四个基础类构成,Timestamp,DatetimeIndex,Period和Timedelta,下面我... 目录1. 时间数据类型与基础操作1.1 核心时间对象体系1.2 时间数据生成技巧2. 时间索引与数据

Go学习记录之runtime包深入解析

《Go学习记录之runtime包深入解析》Go语言runtime包管理运行时环境,涵盖goroutine调度、内存分配、垃圾回收、类型信息等核心功能,:本文主要介绍Go学习记录之runtime包的... 目录前言:一、runtime包内容学习1、作用:① Goroutine和并发控制:② 垃圾回收:③ 栈和

Android学习总结之Java和kotlin区别超详细分析

《Android学习总结之Java和kotlin区别超详细分析》Java和Kotlin都是用于Android开发的编程语言,它们各自具有独特的特点和优势,:本文主要介绍Android学习总结之Ja... 目录一、空安全机制真题 1:Kotlin 如何解决 Java 的 NullPointerExceptio

重新对Java的类加载器的学习方式

《重新对Java的类加载器的学习方式》:本文主要介绍重新对Java的类加载器的学习方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、介绍1.1、简介1.2、符号引用和直接引用1、符号引用2、直接引用3、符号转直接的过程2、加载流程3、类加载的分类3.1、显示

Java学习手册之Filter和Listener使用方法

《Java学习手册之Filter和Listener使用方法》:本文主要介绍Java学习手册之Filter和Listener使用方法的相关资料,Filter是一种拦截器,可以在请求到达Servl... 目录一、Filter(过滤器)1. Filter 的工作原理2. Filter 的配置与使用二、Listen

利用Python快速搭建Markdown笔记发布系统

《利用Python快速搭建Markdown笔记发布系统》这篇文章主要为大家详细介绍了使用Python生态的成熟工具,在30分钟内搭建一个支持Markdown渲染、分类标签、全文搜索的私有化知识发布系统... 目录引言:为什么要自建知识博客一、技术选型:极简主义开发栈二、系统架构设计三、核心代码实现(分步解析

Spring Boot + MyBatis Plus 高效开发实战从入门到进阶优化(推荐)

《SpringBoot+MyBatisPlus高效开发实战从入门到进阶优化(推荐)》本文将详细介绍SpringBoot+MyBatisPlus的完整开发流程,并深入剖析分页查询、批量操作、动... 目录Spring Boot + MyBATis Plus 高效开发实战:从入门到进阶优化1. MyBatis

Java进阶学习之如何开启远程调式

《Java进阶学习之如何开启远程调式》Java开发中的远程调试是一项至关重要的技能,特别是在处理生产环境的问题或者协作开发时,:本文主要介绍Java进阶学习之如何开启远程调式的相关资料,需要的朋友... 目录概述Java远程调试的开启与底层原理开启Java远程调试底层原理JVM参数总结&nbsMbKKXJx