Hi,
When I try this function, I get error : "attempt to call a nil value(global DroneCAN_Handle).
I tryed scripts : BatteryTag.lua from the applet folder and DroneCAN_test.lua from the exemple folder. Both given me the same error.
Hi,
what version of ardupilot are you using ?
You can have this error if the method you call is too recent and your version too old (if the binding is not included in your version)
On docs.lua : ardupilot/libraries/AP_Scripting/docs/docs.lua at Plane-4.5 · ArduPilot/ardupilot · GitHub
Try to change the branch for your current version and see if the method is still here. Elsewhere, you may have to upgrade …
Hi,
It is ArduCopter V4.6.2 (1ebd4d99)
I’ve found the function in the “master” branch only…
How can I use it on my multirotor drone ?
Ok, I did manage to compile the master branch, with this function enabled…but I’m stuck.
I want to send a “ParamGetSet” request but I don’t know how to create the payload…
I’ve read the chapter called “Bindings” on the ardupilot web site and had a look at the file “bindings.desc” but I can’t figure out form where come this function “DroneCAN_Handle” in the library or module folder.
You can have a look at the commit :
It comes from libraries/AP_Scripting/AP_Scripting_helpers.h
It contains :
class DroneCAN_Handle {
public:
static int new_handle(lua_State *L);
static int broadcast(lua_State *L);
static int __gc(lua_State *L);
void close(void);
static int request(lua_State *L);
static int check_message(lua_State *L);
bool subscribe(void);
uint64_t signature;
uint16_t data_type;
uint8_t transfer_id;
bool canfd;
private:
AP_DroneCAN *dc;
// class for subscribing to messages
class Subscriber : public Canard::HandlerList {
public:
Subscriber(DroneCAN_Handle &_handle, CanardTransferType transfer_type);
virtual ~Subscriber(void);
uint8_t node_id;
struct Payload {
uint8_t *data;
uint16_t length;
uint8_t node_id;
#if CANARD_ENABLE_CANFD
bool canfd;
#endif
uint64_t timestamp;
};
ObjectBuffer<Payload> payloads{DRONECAN_HANDLE_MAX_PAYLOADS};
CanardTransferType trans_type;
private:
bool handle_message(const CanardRxTransfer& transfer) override;
DroneCAN_Handle *handle;
};
Subscriber *subscriber;
};
Was it what you’re looking for ?
Yes !
Thank you !
After several hours of learning it worked.
Does anyone have an idea of when this is likely to make it into a stable release? It worked really nicely for us in testing on the bench. The PR adding this has been merged into master, but it doesn’t look like it’s included in any projects, which as I understand is what tracks inclusion into stable versions.