Servers by jDrones

Lua script send mavlink command to FC?

I watch this video lua script sending Mavlink to GCS. but seem like it was not a success.

But, I want to know is if there is anyhow to interact with Vehicle with Mavlink command.
for example, send MAV_CMD_CONDITION_YAW when the mission starts. currently, I do a trick by edit one waypoint in the script to change command from 16 to 115 but feel like a hack.

not currently possible, would be quite easy to add a binding for it tho.

Thank @iampete for your response! I try to do some binding like in the document but I am too new to this! I can add some existing function in the library but I had no clue where the Mavlink singletons are yet!
Can you shed some light? Currently I tested in SITL! And I can do a lot with Lua! My project is to do agriculture UAV! Like Chinese JIYi K++ which I own one and I think Ardupilot can do the same!
FIY I am a web developer! I hope I could grasp Arducopter code soon! Thanks

no need to deal with mavlink just add a vehicle binding for the function the message calls,

Thank you for the hint, I try to work on it now. will come back and give the progress!

It was quite a learning curve. but I’m not sure if I do it correctly.
I finally add the set_fixed_yaw to AP_Vehicle.h by

void virtual set_yaw(float angle_deg, float turn_rate_dps, int8_t direction, bool relative_angle) const = 0;

in Copter.h I override by:

void set_yaw(float angle_deg, float turn_rate_dps, int8_t direction,bool relative_angle) const override{
        Mode::auto_yaw.set_fixed_yaw(angle_deg, turn_rate_dps, direction,relative_angle);
}

In binding.desc

singleton AP_Vehicle method set_yaw void float 0 380 float 0 300 int8_t -1 1 boolean

In script.lua
vehicle:set_yaw(120,150,1,false)

I am in Copter 4.0 branch so I need to do make run in libraries/AP_Scripting/generator folder.

yes, the readme on that branch should explain what to do.

@iampete can you help me with this, please? Reading GPIO input from script

Servers by jDrones