【ESP32-microros(vscode-Platformio)】

一、步骤

1、目前支持ESP32

2、同一个局域网

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

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

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

platformio.ini文件

bash 复制代码
; 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文件

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));
}
bash 复制代码
pio run -v -t upload

4.2 官方工具烧录

5、上位机安装 代理

官方安装参考
安装参考

注意:

bash 复制代码
sudo apt install ros-foxy-micro-ros-msgs

6、上位机运行代理

6.1

bash 复制代码
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -v6

或者

bash 复制代码
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyUSB0

6.2 重启ESP32

7、上位机查看

相关推荐
Waltt_Qiope1 小时前
关于使用cursor tunnel链接vscode(避免1006 issue的做法)
ide·vscode·issue
Charlene Fung3 小时前
vs code远程自动登录服务器,无需手动输入密码的终极方案(windows版)
运维·服务器·vscode·ssh
旷世奇才李先生3 小时前
PyCharm 安装使用教程
ide·python·pycharm
奇文怪式4 小时前
VSCode+arm-none-eabi-gcc交叉编译+CMake构建+OpenOCD(基于Raspberry Pico RP2040)
arm开发·ide·vscode·rp2040
hero_heart12 小时前
vscode中c_cpp_properities.cpp文件生成和作用
ide·vscode·编辑器
Naiva13 小时前
【小技巧】Python+PyCharm IDE 配置解释器出错,环境配置不完整或不兼容。(小智AI、MCP、聚合数据、实时新闻查询、NBA赛事查询)
ide·python·pycharm
FrostedLotus·霜莲14 小时前
C++主流编辑器特点比较
开发语言·c++·编辑器
花王江不语15 小时前
android studio 配置硬件加速 haxm
android·ide·android studio
喝可乐的布偶猫17 小时前
韩顺平之第九章综合练习-----------房屋出租管理系统
java·开发语言·ide·eclipse
DO ITNOW18 小时前
Cursor/VScode ,点击运行按钮,就打开新的终端,如何设置为在当前终端运行文件而不是重新打开终端----一招搞定篇
ide·vscode·编辑器