Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion Chat/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ <h1><a href="" style="color: #000000; text-decoration:none;">Chat</a></h1>
// fallthrough
case "get_vehicle_state":
// Get the vehicle state including armed status and (flight) mode
// fallthrough
return get_vehicle_state();
case "get_location_plus_offset":
// Calculate the latitude and longitude given an existing latitude and longitude and distances (in meters) North and East
// fallthrough
Expand Down Expand Up @@ -641,6 +641,26 @@ <h1><a href="" style="color: #000000; text-decoration:none;">Chat</a></h1>
return new Date().toLocaleString('en-US', options);
}


//get vehicle state
function get_vehicle_state(){
//get latest HEARTBEAT message
const heartbeat_msg = mavlink_store.get_latest_message(0);
//sanity check
if (!heartbeat_msg || !heartbeat_msg.hasOwnProperty("base_mode") || !heartbeat_msg.hasOwnProperty("custom_mode")) {
return "unknown because no HEARTBEAT message has been received from the vehicle";
}
//get the armed state flag by applying mask to base_model property
const armed_flag = (heartbeat_msg["base_mode"] & mavlink20.MAV_MODE_FLAG_SAFETY_ARMED) > 0;
//get mode number from custom_mode property
const mode_number = heartbeat_msg["custom_mode"];

return {
"armed": armed_flag,
"mode": mode_number
}
}

class EventHandler extends EventEmitter {
constructor(client) {
super()
Expand Down Expand Up @@ -713,6 +733,7 @@ <h1><a href="" style="color: #000000; text-decoration:none;">Chat</a></h1>
try {
const toolOutputs = data.required_action.submit_tool_outputs.tool_calls.map((toolCall) => {
let output = handle_function_call(toolCall.function.name, toolCall.function.arguments)
output = JSON.stringify(output);
add_text_to_debug("fn:" + toolCall.function.name + " output:" + output)
return {
tool_call_id: toolCall.id,
Expand Down