当前位置: 首页 > news >正文

【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_wifi
  rclc_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、上位机查看
在这里插入图片描述

相关文章:

  • Go 语言中的 package main、 func main() 和main.go的使用规范
  • 浮点数比较在Eigen数学库中的处理方法
  • AI前沿周报:2025年3月技术深度解析
  • Express中间件(Middleware)详解:从零开始掌握(1)
  • 在Java项目中,引入【全局异常处理器】
  • HarmonyOS-ArkUI V2装饰器-@Once
  • 第一节:React 基础篇-React虚拟DOM原理及Diff算法优化策略
  • 【Web功能测试】注册与登录功能测试用例设计深度解析
  • (十四)安卓开发中的RecyclerView详解
  • Python 和 JavaScript两种语言的相似部分-由DeepSeek产生
  • 计算机操作系统-【死锁】
  • 信奥赛之c++基础(循环结构之for循环)
  • Java常用工具算法-6--秘钥托管云服务3--微软zure Key Vault
  • 第5章,将 Toy IR 程序部分地下降到更低层的 dialect 以便优化
  • 【Grok 大模型深度解析】第二期:架构探秘与训练哲学
  • 在AMGX中使用MPI加载自定义分布式矩阵和向量
  • 自定义函数:为接口开发增添灵活性 - Apipost 的独特优势
  • [特殊字符] 各领域 Dummy 开关实现方式大集合
  • SQL:单表查询基础
  • 面试之《前端信息加密》
  • 中国人才网登录入口/合肥全网优化
  • 哪里找做网站客户/百度公司的发展历程
  • 门户网站建设哪家好/seo深圳培训班
  • 什么是网站建设/百度seo怎么把关键词优化上去
  • 保定网站设计公司/国外搜索引擎大全百鸣
  • 如皋网页设计/开封搜索引擎优化