SDK 通信¶
当使用 FTC® SDK 中的任何方法访问硬件时,比如设置电机功率、读取编码器、传感器等,都会发送LynxCommand。
备注
LynxCommand不是通过USB直接从机器人控制器发送到Expansion Hub;在扩展集线器中,它们通过USB发送到FTDI,FTDI将USB信号转换为通用异步收发设备信号(UART)。在Control Hub中,跳过此USB步骤,而是Control Hub主板直接通过UART将数据发送到内部Expansion Hub。
警告
LynxCommand被阻塞(更具体地说,每个USB设备上都有一个主锁)意味着多线程硬件调用充其量是没有帮助的,通常对性能有害。
如果使用Android手机和扩展集线器,LynxCommand将通过USB发送;但是,如果使用Control Hub,LynxCommand将通过通用异步收发设备发送。这一点非常重要,不仅因为通用异步收发设备而不是USB提高了可靠性,而且因为LynxCommand在USB上大约需要3毫秒,在通用异步收发设备上大约需要2毫秒。
Any expansion hubs connected via RS485 receive their commands via that connector. To get from the USB or UART to RS485 the parent Lynx hub has to retransmit the packets, but packets traveling over RS485 and passing through Lynx hubs do not. The added latency from this process isn’t significant, but there will be some added latency. Up to 255 expansion hubs can be connected together over RS485 in theory.
备注
与I2C设备交互需要更长的时间;通过USB超过7毫秒。但是,这并不是因为每个LynxCommand需要更长的时间,而是因为必须发送多个LynxCommand才能与I2C交互。
请注意,从SDK5.5版本开始,Control Hub上的I2C调用比Expansion Hub上的调用快得多。这是因为轮询率大幅提高,这可以减少不必要的浪费时间。