real-stanford / arx5-sdk

C++ and Python SDK for ARX5 robot arm develeoped by @yihuai-gao (@real-stanford)
MIT License
41 stars 7 forks source link

ARX X5 arm communication protocols - CAN vs EtherCAT #10

Closed villekuosmanen closed 3 months ago

villekuosmanen commented 3 months ago

Hey Yihuai,

Thanks for publishing this SDK, it's been a useful resource so far. I am working with the AgileX Cobot Magic robot, it comes with ARX X5 arms, but there is a catch - the arms in that robot use a protocol called EtherCAT for communication, which I believe is CAN over Ethernet.

I believe you have been in touch with ARX during this project? I wonder id you know whether they are planning to use EtherCAT for future development, or the standard CAN-based interface? It would be really useful to be able to support the EtherCAT interface as well, as I've had a lot of trouble trying to get the standard C++ code working.

To support EtherCAT, I believe some changes to the CAT libraries will be needed. The EtherCAT CAN header file looks like this:

class can
{
public:
    can();
    ~can();

    void can0_ReceiveFrame(ecat::EcatBase ecat_base);
    void Enable_Moto(ecat::EcatBase ecat_base,uint16_t ID);
    void Send_moto_Cmd1(ecat::EcatBase ecat_base, uint16_t motor_id, float kp, float kd, float pos, float spd, float tor);
    void Send_moto_Cmd2(ecat::EcatBase ecat_base, uint16_t motor_id, float kp, float kd, float pos, float spd, float tor);

};

I believe here Send_moto_Cmd1 is for the EC_A4310 joints at the base, shoulder, and elbow, while Send_moto_Cmd2 is for the wrists (I have not yet managed to get the Cmd1 working reliably). So changes to the libraries from which the shared objects are compiled to would be required.

Questions

  1. Have you heard of the EtherCAT based controls for the ARX arm before, and would you consider supporting them in this library?
  2. Do you know where the libhardware.so shard objects are compiled from?

Thanks!

yihuai-gao commented 3 months ago

Thanks for your feedback. Unforturnately, we heard that EtherCat does not support arm64 architecture (nvidia jetson etc.). Therefore, we will not support this interface recently.

That said, we believe that using USB-CAN adapters directly shoudn't take too much time. It usually only takes 10mins to setup according to my experience. Please let me know if you have any trouble compiling this repository and I'll keep updating the documents.

libhardware.so is compiled by myself. As a very early user of ARX, we have some source code but are asked not to publish them. We have already exposed all of the control interfaces so we think it is enough for costomization.

yihuai-gao commented 3 months ago

It seems that EtherCAT works on arm64. I wrote a communication interface for EtherCAT and all the high-level methods are unchanged. I haven't tested it yet but it is promising.

yihuai-gao commented 3 months ago

EtherCAT-CAN interface is ready (though not tested extensively)