Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

RTOS for spinal and neuron #483

Merged
merged 45 commits into from
Aug 6, 2021
Merged

Conversation

tongtybj
Copy link
Collaborator

@tongtybj tongtybj commented Jun 19, 2021

I have completed deployment of RTOS for spinal and neuron.
I have tested with HydrusXI quad type and Dragon. Very stable.

Features:

  • RTOS for spinal (STM32F7)

Spinal_RTOS

  • RTOS for neuron (STM32F4)

Neuron_RTOS

Improvement:

  • Refactor usage of DMA for rosserial UART RX. The throughput of rosserial is significantly improved combined with RTOS (/imu @500hz is available right now).
  • Refactor implementation of CAN in manner of RTOS. The throughput of CAN between spinal and neurons is significantly improved. (full sending mode in neuron (i.e., IMU data + 4 servo data) is available right now).

can

tongtybj and others added 30 commits June 14, 2021 16:04
…_DRIVER library (STM32Cube FW_F7 V1.16.0) for spinal.
…_DRIVER library (STM32Cube FW_F4 V1.25.0) for neuron.
…orresponds to disable "NonAutoRetransmission(NART)" in old HAL version.
…ect is generated from STM32CubeMX

Important: set main.cpp as synbolic link of main.c
- no use of  DMA interrupt for transfer completion, direct incremental write to ringbuffer in SRAM from UART port.
- no 1ms sleep between tx packets from spinal_ros_bridge, thanks for the first improvement
- no use of FIFO of DMA and burst mode, thus no 16bytes padding in spinal_ros_bridge
- use mail function in CMSIS RTOS to send data from RX CAN callback to RX task function.
- remained problem of std:vector variables in RTOS task
- sue DMA for GPS UART3 RX
- refactor the receive function
…to provide enough stack size for core task (512B -> 1024B); otherwise, rosPublishTask will corrupt.
tongtybj added 12 commits June 14, 2021 16:05
…larget message into several small packets to imrpove the transmit throughput
… the project is generated from STM32CubeMX.

Important feature: set main.cpp as synbolic link of main.c
- Enable IMU polling with 1Khz timer
- Enable CAN RX/TX. Using queue to control RX and semaphore to control TX.
…aget message from Neuron. Otherwise, the hard fault occurs because of the wrong memory access.
…rofmance. Previous polling method always corrupts because of the RTOS system
- Strictly guarantee the period for each instunrction (e.g., INST_SET_POS @50Hz, INST_SET_POS @50Hz, 10ms offset from INST_SET_POS.)
- Increase the timeout for HAL_UART_Transmit to handle the intterupt by ohter tasks in RTOS
- Send all insturciton in ring buffer in each iteration using while().
@tongtybj
Copy link
Collaborator Author

RTOS導入の開発は完了しました。ただ、このPRは#416, #417に依存しているため、順を追ってマージします。
また、#416でメッセージタイプの変更があるため、1.2.xとの互換性は失われます。
なので、この3つPRをマージしたのち、バージョンを1.3.0にあげる予定です。

@greenpepper123 @kanke-hayata @Takuzumi240

RTOS導入後の体内通信系のシステム構成の資料をここでまとめています。
ここら辺をちゃんと理解している人が少ないのがすこし心配なので、ぜひこの資料を読んでほしいです。
いずれ講習会を設けてちゃんと説明しようと考えています。

@chibi314
RTOSを導入してから、rosserialとCANの通信状況が大幅に改善されました。
特にCANに関しては、今まで不可能と思われてたneuronにおけるimu_send_data_flag: true + 4 servo send_data_flag: trueという最大の負荷状況にも耐えることができました。
もちろん今の実装は完璧なものではないので、問題があればぜひ指摘ほしいです。

Enable DMA in rosserail UART TX (from MCU to host PC)
@greenpepper123
Copy link
Collaborator

greenpepper123 commented Jul 8, 2021

TODO

  • Neuron: servo TX using DMA

  • Spinal: modify figure, adding UART1 DMA TX

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants