当前位置:网站首页>Esp32 simple speed message test of ros2 (limit frequency)
Esp32 simple speed message test of ros2 (limit frequency)
2022-07-03 01:07:00 【zhangrelay】
video :
turtlesim_esp32 Release speed test
Use the following code , test :
#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; // Linear velocity
vel->angular.z = 0.1+0.01*cnt; // angular velocity
// vel->linear.x = ((double)rand()/(RAND_MAX)); // Random linear velocity
// vel->angular.z = ((double)rand()/(RAND_MAX)); // Random angular velocity
// vel->linear.x = 0.2; // Fixed linear velocity
// vel->angular.z = 1.0 - 0.001*cnt; // Changing angular velocity
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);
}The effect is as follows :

[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 The theme -h
usage :ros2 topic [-h] [--include-hidden-topics]
call `ros2 topic <command> -h` For more detailed usage . ...Subcommands related to various topics
Optional parameters :
-h, --help Display this help message and exit
--include-hidden-topics
Also consider hidden themescommand :
bw Shows the bandwidth used by the theme
delay Show the delay of the topic from the timestamp in the title
echo Output messages from a topic
find Output a list of available topics of a given type
hz Print the average release rate to the screen
info Print information about the subject
list Output a list of available topics
pub Post a message to the subject
type Type of print topiccall `ros2 topic <command> -h` For more detailed usage .
[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 The theme hz -h
usage :ros2 topic hz [-h] [--window WINDOW] [--filter EXPR] [--wall-time]
Subject namePrint the average release rate to the screen
Positional arguments :
topic_name To listen to ROS The name of the subject ( for example '/chatter')Optional parameters :
-h, --help Display this help message and exit
--window window ,-w window
Window size , In the number of messages , Used to calculate the rate
( The default value is :10000)
--filter EXPR Only measure to match the specified Python The news of
expression
--wall-time Use wall time Calculation rate , It helps
When the clock is not released during simulation
[email protected]:~$
边栏推荐
- R language ggplot2 visualization: use ggplot2 to display dataframe data that are all classified variables in the form of thermal diagram, and customize the legend color legend of factor
- R language uses coin package to apply permutation tests to independence problems (permutation tests, whether response variables are independent of groups, are two numerical variables independent, and
- Advanced pointer (I)
- R language generalized linear model function GLM, (model fit and expression diagnostics), model adequacy evaluation method, use plot function and car package function
- The R language uses the ctree function in the party package to build conditional inference decision trees, uses the plot function to visualize the trained conditional inference decision tree, and the
- JS inheritance and prototype chain
- Thank you for being together for these extraordinary two years!
- 12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
- 删除有序链表中重复的元素-II
- 1696C. Fishingprince plays with array [thinking questions + intermediate state + optimized storage]
猜你喜欢

Embrace the safety concept of platform delivery
![[AUTOSAR I overview]](/img/e4/b97c6beebf6f431d2d7cf209c6683e.png)
[AUTOSAR I overview]

Initial order of pointer (basic)

Basic use of sringcloud & use of component Nacos

2022.2.14 resumption

无向图的割点
![[AUTOSAR II appl overview]](/img/da/76ccc05e2199705b20d8304bfb86b2.png)
[AUTOSAR II appl overview]

Deep analysis of data storage in memory

【无标题】

Leetcode-2280: represents the minimum number of line segments of a line graph
随机推荐
matlab 多普勒效应产生振动信号和处理
数据分析思维分析犯法和业务知识——分析方法(一)
[flutter] icons component (load the built-in icon of flutter | display the material design icon completely)
[love crash] neglected details of gibaro
Leetcode-934: the shortest Bridge
关于Fibonacci数列
leetcode-1964:找出到每个位置为止最长的有效障碍赛跑路线
【AutoSAR 十 IO架构】
Arduino开发之按键检测与正弦信号输出
测试右移:线上质量监控 ELK 实战
攻克哈希的基本概念与实现
Vulkan is not a "panacea"“
Leetcode-1964: find the longest effective obstacle race route to each position
(C语言)数据的存储
Foundations of data science is free to download
安全运营四要素之资产、脆弱性、威胁和事件
全志A40i/T3如何通过SPI转CAN
FPGA - 7 Series FPGA internal structure clocking -04- multi area clock
Delete duplicate elements in the ordered linked list -ii
leetcode:701. Insertion in binary search tree [BST insertion]