How to inject position command from scripts

Hi, I’m a newbie of PX4.
I’m trying to inject position command from scripts.
For example, like the following pseudo code:

function pos_cmd(t)
    pos_cmd = nothing
    if t < 1.0
        pos_cmd = [1, 2, 3]
    else
        pos_cmd = [2, 1, -3]
    end
    return pos_cmd
end

For me, the entire PX4-Autopilot code is too big to understand…
I guess that I may have to set something like setpoint.pos.
Is there anyone who can help me?

EDIT: if my question is too rough, please tell me which additional information you need. Sorry for my lack of understanding of PX4.