FRC CAN设备规格

This document seeks to describe the basic functions of the current FRC® CAN system and the requirements for any new CAN devices seeking to work with the system.

编址

FRC CAN节点根据预定义的方案分配仲裁ID,该方案将ID分为5个部分:

设备类型

这是一个五位的数值,它代表了被编址的设备的类型。当前分配的设备类型可以在下表中找到。如果你想从 ``Reserved``库中选取新的设备类型,请向FIRST提交申请。

设备类型

广播消息

0

机器人控制器

1

电机控制器

2

继电器控制器

3

陀螺仪传感器

4

加速度计

5

超声波传感器

6

齿轮传感器

7

配电模块

8

气动控制器

9

杂项

10

IO接口

11

预留

12-30

固件升级

31

制造商

这是一个8位的数值,它代表了被编址的设备的制造商。当前分配的设备类型可以在下表中找到。如果你想从``Reserved``库中选取新的制造商ID,请向FIRST提交申请。

制造商

广播

0

1

发光微

2

德卡

3

点阅电子

4

REV机器人技术

5

抓钩

6

心灵感应器

7

团队使用

8

考艾岛实验室

9

Copperforge

10

Playing with Fusion

11

Studica

12

The Thrifty Bot

13

Redux Robotics

14

AndyMark

15

Vivid Hosting

16

预留

17-255

API /消息标识符

API/消息标识符是一个10位的数值,它代表了一个特定的指令或消息类型。这些标识符对于每一个制造商+设备类型都是唯一的(所以它对于Luminary Micro的电机可能是“电压设置”,对于CTR Electronic的电机可能是“状态获取”,对于CTR配电模块可能是“通电Current Get ”)

消息标识符进一步细分为2个子字段:6位API类和4位API索引。

API类

API类别是API分组的6位数值。类似的消息被分组到单个API类中。下表显示了Jaguar电机的API类的示例。

API类

电压控制模式

0

调速模式

1

电压补偿模式

2

位置控制模式

3

电流控制模式

4

状态

5

周期状态

6

配置

7

确认

8

API索引

API索引是API类中特定消息的4位数值。下表显示了Jaguar电机速度控制API类的API索引值的示例。

API索引

启用控制

0

禁用控制

1

设定设定值

2

P常数

3

I常数

4

D常数

5

设置参考

6

受信任的启用

7

受信任的设置无确认

8

可信设定设定值无确认

10

设定设定值无确认

11

设备编号

设备编号是一个6位数字,它代表特定类型的设备编号。设备应默认为设备ID 0,以匹配FRC控制系统的其他组件。可以为设备特定的广播消息保留设备0x3F。

CAN addressing bit mapping.

受保护的框架

有执行、控制功能的FRC CAN节点(电机控制器,继电器,气动控制器等)必须采用一种方法来验证机器人是否已启用以及命令是否来自主机器人控制器(即roboRIO)。

广播消息

广播消息是通过将设备类型和制造商字段设置为0来发送到所有节点的消息。广播消息的API类为0。下表中显示了当前定义的广播消息:

描述

禁用

0

系统停止

1

系统重置

2

设备分配

3

设备查询

4

中心

5

同步

6

更新

7

固件版本

8

枚举

9

系统恢复

10

Devices should disable immediately when receiving the Disable message (arbID 0). Implementation of other broadcast messages is optional.

FRC CAN节点的要求

为了使CAN节点可以在FRC系统中使用,它们必须:

  • 使用与规定的FRC格式匹配的ID进行通信:

    • 有效的已发布的CAN设备类型(根据表1-CAN设备类型)

    • 有效的,已发布的制造商ID(根据表2-CAN制造商代码)

    • 由设备制造商分配和记录的API类与API索引

    • 如果设备类型的多个单元要在同一网络上共存,则用户可以选择设备编号。

  • 符合“广播消息”部分中详细介绍的最低广播消息要求。

  • If controlling actuators, utilize a scheme to assure that the robot is issuing commands, is enabled, and is still present.

  • Provide software library support for LabVIEW, C++, and Java or arrange with FIRST® or FIRST’s Control System Partners to provide such interfaces.

Universal Heartbeat

The roboRIO provides a universal CAN heartbeat that any device on the bus can listen and react to. This heartbeat is sent every 20 ms. The heartbeat has a full CAN ID of 0x01011840 (which is the NI Manufacturer ID, RobotController type, Device ID 0 and API ID 0x061). It is an 8 byte CAN packet with the following bitfield layout.

描述

Byte

Width (bits)

Match time (seconds)

8

8

Match number

6-7

10

Replay number

6

6

Red alliance

5

1

Enabled

5

1

Autonomous mode

5

1

Test mode

5

1

System watchdog

5

1

Tournament type

5

3

Time of day (year)

4

6

Time of day (month)

3-4

4

Time of day (day)

3

5

Time of day (seconds)

2-3

6

Time of day (minutes)

1-2

6

Time of day (hours)

1

5

struct [[gnu::packed]] RobotState {
  uint64_t matchTimeSeconds : 8;
  uint64_t matchNumber : 10;
  uint64_t replayNumber : 6;
  uint64_t redAlliance : 1;
  uint64_t enabled : 1;
  uint64_t autonomous : 1;
  uint64_t testMode : 1;
  uint64_t systemWatchdog : 1;
  uint64_t tournamentType : 3;
  uint64_t timeOfDay_yr : 6;
  uint64_t timeOfDay_month : 4;
  uint64_t timeOfDay_day : 5;
  uint64_t timeOfDay_sec : 6;
  uint64_t timeOfDay_min : 6;
  uint64_t timeOfDay_hr : 5;
};

If the System watchdog flag is set, motor controllers are enabled. If 100 ms has passed since this packet was received, the robot program can be considered hung, and devices should act as if the robot has been disabled.

Note that all fields except Enabled, Autonomous mode, Test mode, and System watchdog will contain invalid values until an arbitrary time after the Driver Station connects.