다이나믹셀 라이브러리에서 제공하는 코드의 내부 로직이 궁금합니다

다이나믹셀 워크벤치의 goalPosition() 함수는 어떻게 동작하나요?
예를 들어,
goalPosition(0)
goalPosition(4095)
goalPosition(0)
을 차례로 아두이노에 입력한 후 실행했을 때 0 위치로 모터가 이동한 이후의 상황이 궁금합니다.
4095위치로 가는 동안 그 다음 코드인 goalPosition(0)이 실행되지 않고 있는건지, 스택처럼 모든 코드가 순차적으로 실행되고 내부 로직에 의해 4095 위치에 정상적으로 도달하면 다음코드가 실행되는 방식인건지 여쭤보고 싶습니다.

In the example that you specified, the controller will immediately send the goal positions 0, 4095, 0 in sequence, without waiting for the actuator to move to any of the goals between commands.

If you want the actuator to hold at a specified position, or wait for a movement to be completed, you’d need to add a delay or position check into your code.

I’d also like to ask why you are using the DYNAMIXEL Workbench library for this application? We recommend the use of the DYNAMIXEL SDK instead.

Depending on whether you use the newer XL series such as XL-330 or XL-430 or an older AX-12/18, the answer is a little more nuanced because of their firmware differences:

  1. Let’s say your actuator starts at Position A, and then you tell it to go to Position B. The actuator will start to go to Position B.
  2. But, let’s say a short time later, you change your mind and you want it to go to Position C. But at this time your actuator is not at Position B yet. So what will happen? If you use an older servo like AX-12/18, it will still go to B. If you use the newer XL series, your servo will switch its Motion Profile to go to C NOW - so your XL servo would never reach Position B.

So for your sequence:
goalPosition(0)
goalPosition(4095)
goalPosition(0)

and if you have a fast MCU and use an XL servo, you may see the servo jerks out a little bit out of Position 0 and comes back to Position 0 - or you may not see any apparent motion of the servo at all. And for sure it would never reach Position 4095.

To ensure this actual sequence of Goal Positions 0->4095->0 with “practically” no stop or time spent when the servo reaches either Position 0 or Position 4095, you will have to write some code to watch either Address 122 or Bit 1 of Address 123 after you issued each of those Goal Position commands.