Legohead259 / OlympianESC-Firmware

Firmware for a novel Micro-ROS based electronic speed controller (ESC)
MIT License
0 stars 0 forks source link

[Bug Report] : Topics and Services do not work sometimes on startup #11

Closed Legohead259 closed 9 months ago

Legohead259 commented 9 months ago

Describe the bug Most of the time, the publishers and services will not start on connection to the host ROS2 system They will be listed in the ros2 topic list and ros2 service list command outputs, but calling the services or echoing the topics will not yield any output.

To Reproduce Steps to reproduce the behavior:

  1. Boot board
  2. Connect to ROS2 host over agent serial connection (baudrate=115200)
  3. Execute ros2 topic list or ros2 service list
  4. Attempt to call either topic (ex: ros2 topic echo /angular_position) or service (ex: ros2 service call /set_motor_direction motor_interfaces/SetMotorDirection "{direction: false}"
  5. See error

Expected behavior Topics and services should show up and be live as soon as ROS2 agent is connected

Legohead259 commented 9 months ago

After reducing script to minimal publisher (0bf950c), topics show up as expected when agent is connected. Could be an issue with one of the services not initializing properly? Need to implement #5 .

Legohead259 commented 9 months ago

When the FOC algorithm is introduced, the Micro-ROS instance seems to freeze. Could be an issue with the FOC algorithm holding things up

Legohead259 commented 9 months ago

Kept the FOC initialization, but removed the motor.loopFOC() call in the motor control task. The system works as intended and the ROS interface is handled. Seems to be something with this function. Perhaps a core panic? Or a sensor read issue.

What if the loopFOC() and angularPosition publisher are stepping on each other (race condition)? Should try disabling the angularPosition publisher to check.

Legohead259 commented 9 months ago

Removing the angularPosition publisher and replacing the loopFOC() call seems to have fixed this particular problem. I believe the theory about the race condition is correct. #23 should be implemented and this retested to confirm.

Legohead259 commented 9 months ago

Issue has not appeared since #27. Closing for now.