当前位置:网站首页>ROS2之ESP32简单速度消息测试(极限频率)
ROS2之ESP32简单速度消息测试(极限频率)
2022-07-03 00:33:00 【zhangrelay】
视频:
turtlesim_esp32发布速度测试
使用如下代码,测试:
#include <ros2arduino.h>
#include <WiFi.h>
#include <WiFiUdp.h>
#define SSID "***"
#define SSID_PW "***"
#define AGENT_IP "***"
#define AGENT_PORT *** //AGENT port number
#define PUBLISH_FREQUENCY 5000 //hz
void publishVel(geometry_msgs::Twist* vel, void* arg)
{
(void)(arg);
static int cnt = 0;
vel->linear.x = 0.1+0.01*cnt; //线速度
vel->angular.z = 0.1+0.01*cnt; //角速度
// vel->linear.x = ((double)rand()/(RAND_MAX)); //随机线速度
// vel->angular.z = ((double)rand()/(RAND_MAX)); //随机角速度
// vel->linear.x = 0.2; //固定线速度
// vel->angular.z = 1.0 - 0.001*cnt; //变化角速度
cnt++;
}
class VelPub : public ros2::Node
{
public:
VelPub()
: Node("esp32_cmdvel")
{
ros2::Publisher<geometry_msgs::Twist>* publisher_ = this->createPublisher<geometry_msgs::Twist>("turtle1/cmd_vel");
this->createWallFreq(PUBLISH_FREQUENCY, (ros2::CallbackFunc)publishVel, nullptr, publisher_);
}
};
WiFiUDP udp;
void setup()
{
WiFi.begin(SSID, SSID_PW);
while(WiFi.status() != WL_CONNECTED);
ros2::init(&udp, AGENT_IP, AGENT_PORT);
}
void loop()
{
static VelPub VelNode;
ros2::spin(&VelNode);
}效果如下:

[email protected]:~$ ros2 topic -h
usage: ros2 topic [-h] [--include-hidden-topics]
Call `ros2 topic <command> -h` for more detailed usage. ...
Various topic related sub-commands
optional arguments:
-h, --help show this help message and exit
--include-hidden-topics
Consider hidden topics as well
Commands:
bw Display bandwidth used by topic
delay Display delay of topic from timestamp in header
echo Output messages from a topic
find Output a list of available topics of a given type
hz Print the average publishing rate to screen
info Print information about a topic
list Output a list of available topics
pub Publish a message to a topic
type Print a topic's type
Call `ros2 topic <command> -h` for more detailed usage.
[email protected]:~$ ros2 主题 -h
用法:ros2 topic [-h] [--include-hidden-topics]
调用 `ros2 topic <command> -h` 以获得更详细的用法。 ...各种主题相关的子命令
可选参数:
-h, --help 显示此帮助信息并退出
--include-hidden-topics
也考虑隐藏的主题命令:
bw 显示主题使用的带宽
delay 从标题中的时间戳显示主题的延迟
echo 从一个主题输出消息
find 输出给定类型的可用主题列表
hz 将平均发布率打印到屏幕
info 打印有关主题的信息
list 输出可用主题的列表
pub 向主题发布消息
type 打印主题的类型调用 `ros2 topic <command> -h` 以获得更详细的用法。
[email protected]:~$ ros2 topic hz -h
usage: ros2 topic hz [-h] [--window WINDOW] [--filter EXPR] [--wall-time]
topic_name
Print the average publishing rate to screen
positional arguments:
topic_name Name of the ROS topic to listen to (e.g. '/chatter')
optional arguments:
-h, --help show this help message and exit
--window WINDOW, -w WINDOW
window size, in # of messages, for calculating rate
(default: 10000)
--filter EXPR only measure messages matching the specified Python
expression
--wall-time calculates rate using wall time which can be helpful
when clock is not published during simulation
[email protected]:~$
[email protected]:~$ ros2 主题 hz -h
用法:ros2 topic hz [-h] [--window WINDOW] [--filter EXPR] [--wall-time]
主题名称将平均发布率打印到屏幕上
位置参数:
topic_name 要收听的 ROS 主题的名称(例如 '/chatter')可选参数:
-h, --help 显示此帮助信息并退出
--window 窗口,-w 窗口
窗口大小,以消息数为单位,用于计算速率
(默认值:10000)
--filter EXPR 只测量匹配指定 Python 的消息
表达
--wall-time 使用 wall time 计算速率,这很有帮助
在模拟期间未发布时钟时
[email protected]:~$
边栏推荐
- 递归处理组织的几种情况
- Teach you JDBC hand in hand -- structure separation
- 瑞萨电子RZ/G2L开发板上手评测
- Understanding and distinguishing of some noun concepts in adjustment / filtering
- Several cases of recursive processing organization
- cordova-plugin-device获取设备信息插件导致华为审核不通过
- 合并K个已排序的链表
- 飞凌搭载TI AM62x的ARM核心板/开发板首发上市,亮相Embedded World 2022
- (C language) data storage
- 【AutoSAR 十 IO架构】
猜你喜欢

Shell implements basic file operations (cutting, sorting, and de duplication)

Baidu AI Cloud takes the lead in building a comprehensive and standardized platform for smart cloud
![[AUTOSAR + IO Architecture]](/img/cf/9ea42b50bed298c0546764b63bd957.png)
[AUTOSAR + IO Architecture]

Data analysis, thinking, law breaking and professional knowledge -- analysis method (I)

百度智能云牵头打造智能云综合标准化平台

(C语言)数据的存储

深度剖析数据在内存中的存储

(C language) data storage

【AutoSAR 三 RTE概述】

安全运营四要素之资产、脆弱性、威胁和事件
随机推荐
Reading and writing speed of Reza rz/g2l arm development board storage and network measurement
线程的启动与优先级
Leetcode-224: basic calculator
安全运营四要素之资产、脆弱性、威胁和事件
【AutoSAR 九 C/S原理架构】
leetcode-241:为运算表达式设计优先级
基于ARM RK3568的红外热成像体温检测系统
[C language] branch and loop statements (Part 1)
数据分析思维分析犯法和业务知识——分析方法(一)
Leetcode-2280: represents the minimum number of line segments of a line graph
2022中国3D视觉企业(引导定位、分拣场景)厂商名单
Callback event after the antv X6 node is dragged onto the canvas (stepping on a big hole record)
Illustrated network: what is virtual router redundancy protocol VRRP?
1038 Recover the Smallest Number
MySQL multi table joint deletion
RK3568开发板评测篇(二):开发环境搭建
FPGA - 7 Series FPGA internal structure clocking -04- multi area clock
Win10 多种方式解决无法安装.Net3.5的问题
Leetcode-934: the shortest Bridge
Vulkan is not a "panacea"“