欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 文化 > 【ESP32-microros(vscode-Platformio)】

【ESP32-microros(vscode-Platformio)】

2025/4/12 19:21:15 来源:https://blog.csdn.net/sgd985437/article/details/147154744  浏览:    关键词:【ESP32-microros(vscode-Platformio)】

一、步骤

1、目前支持ESP32

2、同一个局域网

3、上位机要安装代理(电脑或者linux设备)

4、可直接通过USB下载,也可以使用官方烧录工具,具体的分区表地址要从USB烧录的时候日志查看,一共四个文件,第三个文件在安装目录下。

4.1在Platformio项目下终端运行命令烧录

platformio.ini文件

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html[env:featheresp32]
platform = espressif32
board = featheresp32
framework = arduino
board_microros_transport = wifi
lib_deps = https://gitee.com/ohhuo/micro_ros_platformio.git

main.cpp文件


#include <Arduino.h>
#include <micro_ros_platformio.h>
#include <WiFi.h>
#include <rcl/rcl.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>rclc_executor_t executor;
rclc_support_t support;
rcl_allocator_t allocator;
rcl_node_t node;void setup()
{Serial.begin(115200);// 设置通过WIFI进行MicroROS通信IPAddress agent_ip;agent_ip.fromString("192.168.31.79");// 设置wifi名称,密码,电脑IP,端口号set_microros_wifi_transports("Xiaomi_320C", "66222888", agent_ip, 8888);// 延时时一段时间,等待设置完成delay(2000);// 初始化内存分配器allocator = rcl_get_default_allocator();// 创建初始化选项rclc_support_init(&support, 0, NULL, &allocator);// 创建节点 microros_wifirclc_node_init_default(&node, "microros_wifi", "", &support);// 创建执行器rclc_executor_init(&executor, &support.context, 1, &allocator);
}void loop()
{delay(100);// 循环处理数据rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100));
}
pio run -v -t upload

4.2 官方工具烧录

在这里插入图片描述

5、上位机安装 代理

官方安装参考
安装参考

注意:

sudo apt install ros-foxy-micro-ros-msgs

6、上位机运行代理

6.1

ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -v6

在这里插入图片描述

或者

ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyUSB0

6.2 重启ESP32

7、上位机查看
在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词