资讯详情

Romi Robot Kit (for FIRST) 快速入门指南

本文首发于GitHub,原地址: https://github.com/VMAxCoding/RomiDevDoc https://vmaxcoding.github.io/RomiDevDoc/

1 简介

1.1 Pololu

Pololu 是一个教学&DIY电路硬件设备供应商类似于国内硅交付技术。他们为业余开发者和学生提供了一些常用的开发板和教学电路组件。它也是一种制造商教育。

  • Pololu 官网: https://www.pololu.com/
  • Pololu GitHub: https://github.com/pololu
  • 硅递科技官网: https://www.seeedstudio.com/
  • 矽递科技 GitHub: https://github.com/Seeed-Studio/

1.2 Romi

Romi 是 Pololu 的产品。Pololu 作为 FIRST 竞争中的第三方,其产品 Romi 只是部分还原 FIRST 竞赛套件的开发流。因此,学习和理解以下内容 Romi 建议将其视为一种而不是 ,提醒两者的独立性。

  • Romi官方详情: https://www.pololu.com/product/4022
  • Romi主板官方细节: https://www.pololu.com/product/3544
  • 开发文档: https://www.pololu.com/docs/0J69
  • FRC版本开发文件: https://docs.wpilib.org/en/stable/docs/romi-robot/index.html

1.2.1 学Romi的理由

Romi 和 FIRST 机器人在代码层面有可重用性,但都在基本层面。这与学习伪代码后发现编程语言的基本逻辑相似。因此 Romi 它确实适合从未接触过硬件编程的人 FIRST 软件开发竞赛。但是已经有了 Arduino 学习单片机开发经验的人 Romi 对 FIRST 比赛帮助有限。

1.2.2 不学Romi的理由

就像 1.2.1 如果你已经开始了单片机和编程,或者你想专注于它 FIRST 竞赛的硬件部分,Romi 什么都教不了你。由于 Romi 是第三方开发的套件,其自由度远大于 FIRST 比赛,后者需要更熟悉官方指定的硬件。更何况,FIRST 机械工程比赛的难度和发挥空间更大 Romi 没有。

1.2.3 本文立场

本文将重点关注清晰度 Romi 开发平台本身的概念,而不是关注 FIRST 与竞赛相关的模拟。

因此,综合 1.2.11.2.2 所述,

2 上手

2.1 知识储备

在继续阅读本文之前,有一些硬件开发的基本知识需要理解。这里将列出必要的相关概念和推荐的学习材料。请在进入下一步之前了解相关概念。

2.1.1 计算机基础知识

如果有足够的时间,建议先了解计算机结构和基本编程原理。建议从基本的软件编程开始。或者组装一台电脑来了解它CPU、内存等结构的作用。

2.1.2 Arduino / 单片机开发板

是目前最流行的,其中包含 、**Arduino 编译器**等。

  • 【推荐】《Arduino极速入门教程-两篇文章会让你使用Arduino(上)》CSDN: https://yunwuhai.blog.csdn.net/article/details/113528255
  • 【推荐】《Arduino极速入门教程-两篇文章会让你使用Arduino(下)》CSDN: https://yunwuhai.blog.csdn.net/article/details/113558575
  • 《Arduino IDE使用教程-超细节CSDN: https://blog.csdn.net/as480133937/article/details/105331315

2.1.3 树莓派 / Linux 开发板

**树莓派**是目前最流行的 。其级别从微波炉使用的单片机升级到手机级别ARM处理器。从操作开始 Arduino 升级到固件 Linux 系统。但其本质是操作程序。这里不需要学习太多,但至少需要安装覆盆子派的操作系统,并配置开发环境。

2.2 准备 Romi

Romi Robot Kit for FIRST 汽车可分为底盘部分和树莓派开发板。其中,没有树莓派的底盘本身就是一块 Arduino 主板,熟悉 Arduino 的人看到 Romi 32U4 时 能马上想到 Arduino UNO R3 单片机 ATMEGA328PU4。而树莓派在 Romi 操作不是必需品,但作为上位机,通过 I2C 提供更复杂的控制。

所以不需要树莓派做上位机,Romi 也可以作为一个 Arduino 机器人正常工作。安装树莓派后,可以进行更复杂的控制,甚至模拟 FIRST 开发环境。

  • 开发文档: https://www.pololu.com/docs/0J69
  • FRC版本开发文件: https://docs.wpilib.org/en/stable/docs/romi-robot/index.html
  • Romi Robot Kit for FIRST: https://www.pololu.com/product/4022
  • Romi 32U4 Control Board: https://www.pololu.com/product/3544
  • Romi包库开发文件: https://pololu.github.io/romi-32u4-arduino-library/
  • 【推荐】Romi 树莓派4B文档 (非官方): https://github.com/czbeatty/FRC-Romi-Programming-Course/tree/main/Lssons
  • Romi + 树莓派4B示范视频 (非官方): https://www.youtube.com/watch?v=mop51tpWWcA

2.2.1 硬件组装

直接参看官方文档:

  • 开发文档-硬件组装: https://www.pololu.com/docs/0J69/4
  • FRC版开发文档-硬件组装: https://docs.wpilib.org/en/stable/docs/romi-robot/hardware.html

2.2.2 Romi 32U4 Control Board 底盘 (主板) Arduino 部分

2.2.2.1 Arduino IDE 配置

安装 Arduino IDE:

  • 【推荐】《Arduino极速入门教程——两篇文章让你会用Arduino(上)》CSDN: https://yunwuhai.blog.csdn.net/article/details/113528255
  • 【推荐】《Arduino极速入门教程——两篇文章让你会用Arduino(下)》CSDN: https://yunwuhai.blog.csdn.net/article/details/113558575
  • 《Arduino IDE使用教程-超详细》CSDN: https://blog.csdn.net/as480133937/article/details/105331315

直接参看官方文档:

  • 开发文档-ArduinoIDE: https://www.pololu.com/docs/0J69/5.2
  • 库管理器安装 Pololu A-Star Boards

测试代码:

/*
  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}
2.2.2.1.1 Arduino IDE 安装错误和不识别问题排查
  • 《arduino usb串口驱动_Arduino开发环境的搭建与编程入门基础教程》CSDN: https://blog.csdn.net/weixin_39844590/article/details/111197427

  • 《arduino usb串口驱动_正确安装驱动的姿势》CSDN: https://blog.csdn.net/weixin_39734399/article/details/111205281

2.2.2.2 Arduino IDE 使用 Romi 32U4 包库

直接参看官方文档:

  • 开发文档-ArduinoIDE 使用 Romi 库: https://www.pololu.com/docs/0J69/6
  • 库管理器安装 Romi32U4
  • Romi包库开发文档: https://pololu.github.io/romi-32u4-arduino-library/

测试代码:

/*
  2022.5.14 new file
  This example code is written by:
  https://github.com/SynthesisDu
*/

#include <Romi32U4.h>

Romi32U4Motors motors;
Romi32U4ButtonA buttonA;

void setup()
{
  // Wait for the user to press button A.
  buttonA.waitForButton();
  // Delay so that the robot does not move away while the user is
  // still touching it.
  delay(1000);
}

void loop()
{
  // Run forward.
  ledYellow(1);
  for (int speed = 0; speed <= 400; speed++)
  {
    motors.setLeftSpeed(speed);
    motors.setRightSpeed(speed);
    delay(2);
  }
  for (int speed = 400; speed >= 0; speed--)
  {
    motors.setLeftSpeed(speed);
    motors.setRightSpeed(speed);
    delay(2);
  }

  // Run backward.
  ledYellow(0);
  for (int speed = 0; speed >= -400; speed--)
  {
    motors.setLeftSpeed(speed);
    motors.setRightSpeed(speed);
    delay(2);
  }
  for (int speed = -400; speed <= 0; speed++)
  {
    motors.setLeftSpeed(speed);
    motors.setRightSpeed(speed);
    delay(2);
  }

  delay(500);
}
2.2.2.3 Romi 32U4 Control Board 底盘配置为下位机

使用树莓派控制 Arduino 下位机时使用 I²C 信号传输,此时 Arduino 需要烧录专门的程序用以接收上位机的控制。

直接参看官方文档:

  • 开发文档-I²C 信号规范: https://www.pololu.com/docs/0J69/3.7
  • 开发文档-将 Arduino 配置为下位机: https://www.pololu.com/blog/577/building-a-raspberry-pi-robot-with-the-a-star-32u4-robot-controller
  • 官方包库-Romi 32U4 下位机包库: https://github.com/pololu/pololu-rpi-slave-arduino-library

2.2.3 树莓派上位机部分

2.2.3.1 树莓派系统安装

FRC版系统安装教程:

  • FRC版开发文档-树莓派系统安装: https://docs.wpilib.org/en/stable/docs/romi-robot/imaging-romi.html

普通系统安装教程:

2.2.3.1.1 系统安装的错误排查
  1. 如果教程中使用的软件无法排故,可以尝试 Rufus,我目前用过最强大的系统烧录软件。市面上有和没有的系统,家用主板到服务器我基本都试过,没遇到过 Rufus 造成的问题。 · Rufus 发布页: https://rufus.ie/zh/ · Rufus 微软商城版: https://apps.microsoft.com/store/detail/rufus/9PC3H3V7Q9CH · Rufus GitHub: https://github.com/pbatard/rufus
  2. 如果 Rufus 无法解决,接下来考虑下载的系统镜像不完整,尝试重新下载或更换镜像。
  3. 如果还有问题,基本可以怀疑是硬件的问题,可以尝试更换读卡器、更换SD/TF卡。因为这类存储卡转接USB也依靠一个桥主控芯片,便宜货确实容易有兼容性问题。
  1. 如果新烧录的系统盘无法运行树莓派系统,直接重试一遍烧录系统的步骤。
  2. 上一步无效的话尝试以其他文件格式格式化存储介质。例如切换 GPT/MBR 分区表,修改 NTFS/FAT32 文件系统。
  3. 如果依然不行,换个系统镜像试试,否则为硬件问题。其实第二步和第三步概率相近,基本不分先后。
  4. 此处硬件问题就比较杂了,如果缺乏经验,也没什么好的建议了。
2.2.3.2 连接树莓派

此处多提一嘴,如果使用树莓派4B等有无线网卡的型号,是可以直接连接树莓派的 WiFi 的。不同版本的操作系统可能有不同的 WiFi 密码,可以在 GitHub 下载的位置查看。

2.2.3.2.1 首次启动故障排查
  • 按理说刚通电时,红灯常亮,绿灯会闪烁。红灯表示通电,绿灯表示读盘。绿灯闪烁说明树莓派开始加载操作系统了。而我本人就遇到通电后绿灯完全不亮的情况。
    • 我的排查结果是 Romi 提供的供电不足,树莓派无法开机。在更换电池前我直接给树莓派外接了 TypeC 的充电器,直接正常开机。
    • 后续扒掉外接线,更换电池,同样正常开机。
    • 此故障的原因大概是化学电池的电压波动超限,其电压依然能够点亮 Romi 的 LED 但无法让树莓派开机。

3 使用

3.1 FIRST 开发模式

3.1.1 安装软件开发环境

安装 WPILib 模组版 VSCode,之后便可和其他 FIRST 机器人一样在 VSCode 中开发。

  • 官方安装包 GitHub 下载: https://github.com/wpilibsuite/allwpilib/releases
3.1.1.1 Windows 系统

Windows 版本的安装包以 .iso 文件的形式打包。安装的部分可以参考这个视频:

  • Romi + 树莓派4B示范视频 (非官方): https://www.youtube.com/watch?v=mop51tpWWcA
3.1.1.1.1 Windows 安装注意事项
  • 直接用压缩软件解压此 .iso 文件可能会提示文件损坏,其实无需解压,只需要右键文件 --> 打开方式 --> 文件资源管理器,直接运行安装程序即可。
  • 运行安装程序后,偶尔会有命令行窗口弹出。
  • 建议在能访问外网的网络环境下安装。
  • 有 VPN 的情况下,包含在线下载,总安装时常一般不超过10分钟。
3.1.1.2 Linux 系统

Linux 版本的安装包以 .tar.gz 文件的形式打包。

3.1.1.3 MacOS 系统

MacOS 版本的安装包以 .dmg 文件的形式打包。

3.2 Arduino 开发模式

直接参看官方文档:

  • 开发文档-ArduinoIDE 使用 Romi 库: https://www.pololu.com/docs/0J69/6
  • Romi包库开发文档: https://pololu.github.io/romi-32u4-arduino-library/

3.3 树莓派 – I²C -> Arduino 开发模式

直接参看官方文档:

  • 开发文档-I²C 信号规范: https://www.pololu.com/docs/0J69/3.7
  • 开发文档-将 Arduino 配置为下位机: https://www.pololu.com/blog/577/building-a-raspberry-pi-robot-with-the-a-star-32u4-robot-controller
  • 官方包库-Romi 32U4 下位机包库: https://github.com/pololu/pololu-rpi-slave-arduino-library

标签: 47frc连接器

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台