# Some problems when sending actuator status messages

**URL:** <https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697>\
**Category:** Libcanard\
**Created:** [July 1, 2022, 8:29am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697 "2022-07-01T08:29:33Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![liu](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://forum.opencyphal.org/u/liu)\
**Post date:** [July 1, 2022, 8:29am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/1 "2022-07-01T08:29:33Z")

</div>

Hello!  
I’m using UAVCAN on STM32F446 to send actuator status information .But I can only received one actuator status information by Zubax while there are six actuator’s status information being sent.

 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/9/98776e2999bb18f031a38b28cbb4984c7f651c3e.png)  
 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/6/64a1fc31ea8227837e62a4bdf76b9be8a6090a46.png)

I call the above function in this function

 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/3/3990a62686563b23ae1ca61e12ed9905be646033.png)

It can be seen from the above code that the information of 6 Motors should be sent each time, but only one motor can be received

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [July 1, 2022, 8:58am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/2 "2022-07-01T08:58:51Z")

</div>

First things first, what you are using is now called DroneCAN — [UAVCAN does no longer exist](https://forum.opencyphal.org/t/uavcan-v1-is-now-cyphal/1622). It will take a while for all the existing resources and materials to update the naming so certain confusion is expected to persist for some time.

I see that you are using a data type that is not actually present in the standard data type set of DroneCAN, which is a problem by itself because you are not expected/allowed by the standard to add vendor-specific data types into the standard namespace (unless they changed this rule, which I doubt they did). That said, it is unlikely to have anything to do with your specific problem at hand.

I recommend that you analyze the traffic on the bus using the DroneCAN GUI Tool or something similar to see what is happening with your CAN frames. It could be that some of them are being timed out before making it to the bus.

We strongly advise that all new projects should adopt Cyphal/CAN instead of the legacy protocols because of its technical superiority. I wrote about this many times on this forum before, so let me quote myself below.

> [@](#):
>
> Building any non-trivial system based on DroneCAN today would be a mistake unless you strongly require compatibility with legacy hardware out there. This is because of its inherent architectural limitations, which are covered in the Guide. I am fairly confident saying this since I was more involved in the architecting and designing of both DroneCAN and Cyphal than anybody else.
> 
> Cyphal/CAN is **already [supported in PX4](https://github.com/PX4/PX4-Autopilot/tree/master/src/drivers/cyphal)**. Although the support might be considered somewhat minimal, it should be easy to extend since the hard part is already done.
> 
> Cyphal/CAN is minimally supported in a fork of ArduPilot. There is an [**upstream pull request**](https://github.com/ArduPilot/ardupilot/pull/20408) which appears to be failing to gain the attention of the maintainers but one might hope to see it merged one day.

> [@](#):
>
> 1. DroneCAN is only suitable for highly centralized systems where there is only one actor responsible for the consumption of data from the bus and the issuance of imperatives to other nodes.
> 
> 2. DroneCAN is only suitable for networks that match the rigid architectural patterns envisioned by the authors of its data types. E.g., if you have a quadplane and the authors of the ESC service did not foresee that use case, you’re out of luck.
> 
> 3. DroneCAN only supports CAN, which is being phased out in the industry. In five years every major medium- to the high-end vehicle will be heavily leveraging Ethernet.
> 
> 4. All existing implementations of DroneCAN (both official and third-party) are seriously lacking in quality compared to Cyphal, which might make them inadmissible in certain systems.
> 
> You may find more information on the differences here: [UAVCAN 2019 roadmap](https://forum.opencyphal.org/t/uavcan-2019-roadmap/666)

If you are building a new product and require help navigating around the CAN ecosystem in the drone industry, feel free to reach out to [info@zubax.com](mailto:info@zubax.com) for assistance.

---

<div class="post-metadata">

**Author:** ![liu](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://forum.opencyphal.org/u/liu)\
**Post date:** [July 1, 2022, 9:19am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/3 "2022-07-01T09:19:17Z")

</div>

Thanks for your ananser!

I just came into contact with him, soI am confused about some concepts. The data types I use are standard data types and I just redefined the name. I will consider using the latest Cyphal/CAN。  
Thank you again！

---

<div class="post-metadata">

**Author:** ![liu](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://forum.opencyphal.org/u/liu)\
**Post date:** [July 10, 2022, 10:31am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/4 "2022-07-10T10:31:51Z")

</div>

Hello!I want to receive the information of six motors through a self-made circuit board using stm32f446. When the board obtains the information of six motors, it will send it to pixhawk4 with the dronecan protocol. Standard data type uavcan.equipment. actuator. State is required when sending, but this standard data type can only transmit the information of one motor at a time. I want to transmit the information of six motors at the same time. Theoretically, can the information of six motors be broadcast on the same node ID at one time if not using the user-defined data type.

 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/5/5db1c3c6922c0cc5ae3d62591b927516912cebe7.png)

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [July 10, 2022, 2:10pm UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/5 "2022-07-10T14:10:44Z")

</div>

Per DroneCAN logic, you have to assign a unique actuator\_id per motor and publish this message six times back-to-back. There is no other solution.

Really, you should be using Cyphal though. You may want to consult with this to see how it is implemented in Cyphal:

> **[GitHub - OpenCyphal-Garage/demos: Demo applications and reference...](https://github.com/OpenCyphal-Garage/demos)**
>
> Demo applications and reference implementations. Contribute to OpenCyphal-Garage/demos development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![liu](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://forum.opencyphal.org/u/liu)\
**Post date:** [July 11, 2022, 3:21am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/6 "2022-07-11T03:21:20Z")

</div>

Thansk for your reply.I can’t use Cyphal for some reasons .I sent the information of six motors in sequence, with ids of 1,2… 5,6. However, the UAVCAN GUI TOOl can only receive information with id 1, and every six messages with motor id 1 will cause an error frame, and the corresponding information is as follows:

Data type macro definition：

 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/5/5fe2634d23b3f00772e62089ddb64166fd9aab1b.png)  
Code for broadcasting 6 motor information  
 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/f/f2a595cf0babf1802afce62c3c7292eae649bbbf.png)  
 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/e/e3eb749655f80108e23f46c4a1cabc5b6e05920e.png)  
Only motor information with ID 1 was received.  
 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/8/889015ce1571f355f26dbbccf555726e64246057.png)

---

<div class="post-metadata">

**Author:** ![liu](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://forum.opencyphal.org/u/liu)\
**Post date:** [July 11, 2022, 3:22am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/7 "2022-07-11T03:22:41Z")

</div>

The received message will appear one error frame per six frames

 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/5/5fdc1de54e08221bb0258f52fb85b567a0ec0ca1.png)

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [July 11, 2022, 5:37am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/8 "2022-07-11T05:37:58Z")

</div>

Why are you receiving 900 frames per second while your app is supposed to publish only 12 FPS?

It looks like you’re losing frames to queue overflow or some other queue-related issue. I am assuming here that the broadcasting function competes successfully (you do seem to have a check in place I see). To be sure, try lowering the broadcasting rate and inserting a brief pause between messages in the same group to see if it resolves the problem. If it does, you need to look into fixing the TX queue in your app.

Also try checking the bus traffic using candump just to make sure that the problem is not caused by the DroneCAN GUI Tool itself being unable to keep up with your FPS.

P.S. It is better to post source code as text.

---

<div class="post-metadata">

**Author:** ![liu](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://forum.opencyphal.org/u/liu)\
**Post date:** [July 11, 2022, 8:12am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/9 "2022-07-11T08:12:15Z")

</div>

The reason for the mismatch in the number of frames may be the timing when I call the broadcast function, but after adjustment, only the information of the motor with ID 1 can be received.I also changed the GUI tool, and the result is the same.  
This is the code.  
[uav\_port.txt](https://forum.opencyphal.org/uploads/short-url/frdsrSeHfvwMFyeh6gBzzcItzOy.txt) (43.9 KB)

 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/7/7a1e50261e112c1fa6cd10ec3b788ca2338b0e36.png)

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [July 11, 2022, 8:28am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/10 "2022-07-11T08:28:09Z")

</div>

Okay. The advice I gave in the previous post still holds.

---

<div class="post-metadata">

**Author:** ![liu](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://forum.opencyphal.org/u/liu)\
**Post date:** [July 12, 2022, 7:22am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/11 "2022-07-12T07:22:15Z")

</div>

OK.Thanks for your suggestions!

---

<div class="post-metadata">

**Author:** ![liu](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@liu](https://forum.opencyphal.org/u/liu)\
**Post date:** [July 12, 2022, 11:26am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/12 "2022-07-12T11:26:22Z")

</div>

Hello!Careful, there I go again!I am trying to use a custom data type, but the following error occurred when sending to GUI tool. The corresponding data type definitions and codes are as follows:  
**Data type definitions：**

 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/8/8cdf197e133524b38eb067f68d0c5b9befe50a92.png)  
 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/2/26bef94dc6567672e0dba9397ecbbc3c47b68f76.png)  
**Compiled header file：**  
[ArrayStatus.h](https://forum.opencyphal.org/uploads/short-url/hgCDGXglQ3NrbcBixx8bmWB04X6.h) (8.2 KB)  
[Statusinfo.h](https://forum.opencyphal.org/uploads/short-url/m079eUpl4pt5vLALsFFeBK6eYBU.h) (9.1 KB)

**code:**

```auto
#define UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_ID 1999
#define UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_NAME "uavcan.equipment.actuator.ArrayStatus"
#define UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_SIGNATURE (0xB4274B775EE28B6FULL)
#define UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_MAX_SIZE (387/8)
typedef struct __packed _actuator_Status_b
{
    uint16_t actuator_id;
    uint16_t position;
    uint16_t force;
    uint16_t speed;
} _actuator_Status_b ;
static void BroadMotorInfoCanard(void)
{
    uint16_t buffer[UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_MAX_SIZE];
    memset(buffer,0,UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_MAX_SIZE);
    _actuator_Status_b motor_status;
    static uint8_t motor_transfer_id;
    uint8_t array_len=6;
    int offset=0;
    canardEncodeScalar(buffer, offset, 8, &array_len);
    offset += 8;
    for (uint16_t i=1;i<=6;i++)
    {
        motor_status.actuator_id=i;
        motor_status.position=canardConvertNativeFloatToFloat16(3.0);
        motor_status.speed=canardConvertNativeFloatToFloat16(4.0);
        motor_status.force=canardConvertNativeFloatToFloat16(5.0);
        
        canardEncodeScalar(buffer, offset, 16, &motor_status.actuator_id);
        offset += 16;
        canardEncodeScalar(buffer, offset, 16, &motor_status.position);
        offset += 16;
        canardEncodeScalar(buffer, offset, 16, &motor_status.force);
        offset += 16;
        canardEncodeScalar(buffer, offset, 16, &motor_status.speed);    
        offset += 16;
    }
    LOGI("%d",offset);
      const int16_t Broad_res=canardBroadcast(&g_canard,
                                                UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_SIGNATURE,
                                                UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_ID ,
                                                &motor_transfer_id,
                                                CANARD_TRANSFER_PRIORITY_MEDIUM,
                                                &buffer,
                                                UAVCAN_EQUIPMENT_ACTUATOR_ARRAYSTATUS_MAX_SIZE);
            LOGI("%d,%d",motor_transfer_id,Broad_res);
            if (Broad_res <= 0)
            {
                (void)fprintf(stderr, "Could not broad motor feedback; error %d\n", Broad_res);
            }
}

```

**Errors occurred：**

 ![图片](https://forum.opencyphal.org/uploads/default/original/2X/b/ba74ae09db018a3dc49cc423f10bca52e68da3b4.png)

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [July 12, 2022, 11:29am UTC](https://forum.opencyphal.org/t/some-problems-when-sending-actuator-status-messages/1697/13 "2022-07-12T11:29:42Z")

</div>

Whether you use a custom or a standard data type makes no difference if your CAN queue is broken. Now we see that it clearly is. Please follow the advice I gave earlier to diagnose the problem before proceeding further.

Also, **you should be using Cyphal**. This is an OpenCyphal forum, by the way, not a DroneCAN one.
