当前位置:网站首页>esp32和ros2基础篇草稿-micro-ros-
esp32和ros2基础篇草稿-micro-ros-
2022-08-02 23:40:00 【zhangrelay】
博客中两两三三记录了一些使用micro-ros建立esp32与ros2之间通信的一些调试记录。
也参考了如下的内容:
1 zhuanlan.zhihu.com/p/542563252
2 blog.csdn.net/qq_62096941/article/details/125638469
除了如下博文中提及的工具:
micro-ros arduino esp32 ros2 笔记
还需要:
Micro-XRCE-DDS-Agent
主要参考如下:
arduino配置好后,支持ros1,ros2多种模式通信。
- micro-ros(ros2 dashing foxy humble)
- ros2arduino(ros2 dashing foxy humble)
- rosserial(ros1 kinetic melodic noetic)
这些都测试过,也都非常稳定,如果不用arduino。
参考如下这篇:
micro-ROS之esp32与ros2资料(freertos)_zhangrelay的博客-CSDN博客
使用arduino esp32 micro-ros发布一个主题的代码如下:
#include <micro_ros_arduino.h>
#include <stdio.h>
#include <rcl/rcl.h>
#include <rcl/error_handling.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#include <std_msgs/msg/int32.h>
#if !defined(ESP32) && !defined(TARGET_PORTENTA_H7_M7) && !defined(ARDUINO_NANO_RP2040_CONNECT)
#error This example is only avaible for Arduino Portenta, Arduino Nano RP2040 Connect and ESP32 Dev module
#endif
rcl_publisher_t publisher;
std_msgs__msg__Int32 msg;
rclc_support_t support;
rcl_allocator_t allocator;
rcl_node_t node;
#define LED_PIN 13
#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){error_loop();}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){}}
void error_loop(){
while(1){
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
delay(100);
}
}
void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
msg.data++;
}
}
void setup() {
set_microros_wifi_transports("***", "***", "***", 8888);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
delay(2000);
allocator = rcl_get_default_allocator();
//create init_options
RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));
// create node
RCCHECK(rclc_node_init_default(&node, "micro_ros_arduino_wifi_node", "", &support));
// create publisher
RCCHECK(rclc_publisher_init_best_effort(
&publisher,
&node,
ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32),
"topic_name"));
msg.data = 0;
}
void loop() {
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
msg.data++;
}
其中:
set_microros_wifi_transports("***", "***", "***", 8888);
分别为wifi名,wifi密码,agent地址,agent端口。
测试效果稳定。
需要启动agent。
测试共稳定接受22585890个数据,未出现任何异常:
边栏推荐
- 服务间歇性停顿问题优化|得物技术
- 关于地图GIS开发事项的一次实践整理(上)
- 【QT】自定义工程封装成DLL并如何调用(带ui界面的)
- 十二、form表单的提交
- 即席查询—— Kylin使用
- I have been in the software testing industry for nearly 20 years, let me talk to you about today's software testing
- Canonical correlation analysis of CCA calculation process
- 我们来浅谈代码语言的魅力
- 十三、数据回显
- 漫画:怎么证明sleep不释放锁,而wait释放锁?
猜你喜欢
# DWD层及DIM层构建## ,220801 ,
CAS:1445723-73-8,DSPE-PEG-NHS,磷脂-聚乙二醇-活性酯两亲性脂质PEG共轭物
关于地图GIS开发事项的一次实践整理(上)
记一次sql优化Using temporary; Using filesort
Let's talk about the charm of code language
公司招个程序员,34岁以上两年一跳的不要,开出工资以为看错了
牛客网剑指offer刷题练习之链表中环的入口结点
I have been in the software testing industry for nearly 20 years, let me talk to you about today's software testing
fifa将采用半自动越位技术计算进球
语音合成模型小抄(1)
随机推荐
Visual Studio中vim模拟器
主流定时任务解决方案全横评
Apache Doris 1.1 特性揭秘:Flink 实时写入如何兼顾高吞吐和低延时
Numpy数组中d[True]=1的含义
js基础知识整理之 —— 变量和数据类型
TensorFlow学习记录(一):基本介绍
如何使用vlookup+excel数组公式 完成逆向查找?
Teach you to locate online MySQL slow query problem hand by hand, package teaching package meeting
5、Citrix云桌面初始化Storefront设置
2022 Shandong International Youth Eye Health Industry Exhibition, Vision Health Exhibition, Optometry Exhibition
UE5 官方案例Lyra 全特性详解 8.如何用配置表初始化角色数据
牛客网剑指offer刷题练习之链表中环的入口结点
Speech Synthesis Model Cheat Sheet (1)
秒懂网络拓扑中的下一跳地址
CKAN教程之在 AWS 上部署 CKAN 应用程序
Moco of Mock tools use tutorial
一文读懂 Web 3.0 应用架构
Rasa 3.x study series - Rasa - Issues 4792 socket debug logs clog up debug feed study notes
十年架构五年生活-05第一次出差
DownMusic总结记录