Skip to content

Commit

Permalink
Initial commit for ISaAC copilot module
Browse files Browse the repository at this point in the history
  • Loading branch information
podhrmic committed Mar 25, 2017
1 parent 0cc060c commit b3a18af
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 1 deletion.
1 change: 1 addition & 0 deletions conf/airframes/AGGIEAIR/aggieair_rp3_lia.xml
Expand Up @@ -57,6 +57,7 @@ RP3 Lisa MX
<module name="nav" type="launcher"/>
<module name="nav" type="skid_landing"/>
<module name="sys_mon"/>
<module name="isaac"/>
<module name="extra_dl">
<!-- in order to use uart1 without chibios we need to remap the peripheral-->
<define name="REMAP_UART1" value="TRUE"/>
Expand Down
52 changes: 52 additions & 0 deletions conf/gcs/AGGIEAIR/vertical.xml
@@ -0,0 +1,52 @@
<layout width="1280" height="709">
<columns>
<rows SIZE="600">
<widget NAME="strips" SIZE="225"/>
<widget NAME="aircraft" SIZE="350"/>
<widget NAME="alarms"/>
</rows>
<rows>
<widget NAME="map2d">
<papget type="message_field" display="gauge" x="77" y="304">
<property name="field" value="CAMERA_PAYLOAD:used_memory"/>
<property name="scale" value="1.0"/>
<property name="min" value="0."/>
<property name="max" value="100."/>
<property name="size" value="50."/>
<property name="text" value="Used memory(%)"/>
</papget>
<papget type="message_field" display="gauge" x="74" y="198">
<property name="field" value="CAMERA_PAYLOAD:used_disk"/>
<property name="scale" value="1.0"/>
<property name="min" value="0."/>
<property name="max" value="100."/>
<property name="size" value="50."/>
<property name="text" value="Used disk(%)"/>
</papget>
<papget type="message_field" display="text" x="45" y="414">
<property name="field" value="CAMERA_PAYLOAD:error_code"/>
<property name="size" value="15."/>
<property name="format" value="Error code: %.0f"/>
<property name="color" value="green"/>
</papget>
<papget type="message_field" display="led" x="151" y="395">
<property name="scale" value="1"/>
<property name="field" value="CAMERA_PAYLOAD:error_code"/>
<property name="size" value="15."/>
<property name="text" value="Error:"/>
<property name="test_value" value="0"/> <!-- will be green only if value==0 -->
<property name="test_invert" value="true"/>
</papget>
<papget type="message_field" display="led" x="152" y="366">
<property name="scale" value="1"/>
<property name="field" value="CAMERA_PAYLOAD:door_status"/>
<property name="size" value="15."/>
<property name="text" value="Door status:"/>
<property name="test_value" value="2"/> <!-- will be green only if value==2 -->
<property name="test_invert" value="true"/>
</papget>

</widget>
</rows>
</columns>
</layout>
33 changes: 33 additions & 0 deletions conf/modules/isaac.xml
@@ -0,0 +1,33 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="isaac" dir="cartography">
<doc>
<description>
ISaAC: The Intelligent Safety and Airworthiness Co-Pilot module
Based on paper "A Payload Verification and Management Framework
for Small UAV-based Personal Remote Sensing Systems" by Cal Coopmans
and Chris Coffin. Link: http://ieeexplore.ieee.org/abstract/document/6309316/

ISaAC is intented mainly for mapping applications.

This module processes messages from ISaAC, and either forwards them to the GCS
(such as CAMERA_SNAPSHOT or CAMERA_PAYLOAD messages), or responds to them necessary
(such as MOVE_WP).

The module assumes the source of the messages is trusted (i.e. not authentication besides
AC_ID check is performed).
</description>
</doc>
<depends>extra_dl</depends>
<header>
<file name="isaac.h"/>
</header>
<init fun="isaac_init()"/>
<periodic fun="isaac_periodic()" freq="1." autorun="TRUE"/>
<datalink message="CAMERA_SNAPSHOT" fun="isaac_parse_cam_snapshot_dl()"/>
<datalink message="CAMERA_PAYLOAD" fun="isaac_parse_cam_payload_dl()"/>
<makefile>
<file name="isaac.c"/>
</makefile>
</module>

120 changes: 120 additions & 0 deletions sw/airborne/modules/cartography/isaac.c
@@ -0,0 +1,120 @@
/*
* Copyright (C) 2016 2017 Michal Podhradsky <http://github.com/podhrmic>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/**
* @file "modules/cartography/isaac.c"
*
* ISaAC: The Intelligent Safety and Airworthiness Co-Pilot module
* Based on paper "A Payload Verification and Management Framework
* for Small UAV-based Personal Remote Sensing Systems" by Cal Coopmans
* and Chris Coffin. Link: http://ieeexplore.ieee.org/abstract/document/6309316/
*
* ISaAC is intented mainly for mapping applications.
*
* This module processes messages from ISaAC, and either forwards them to the GCS
* (such as CAMERA_SNAPSHOT or CAMERA_PAYLOAD messages), or responds to them necessary
* (such as MOVE_WP).
*
* The module assumes the source of the messages is trusted (i.e. not authentication besides
* AC_ID check is performed).
*/

#include "modules/cartography/isaac.h"
#include "subsystems/datalink/telemetry.h"
#include <string.h>

bool send_cam_snapshot;
bool send_cam_payload;

struct CameraPayload cam_payload;
struct CameraSnapshot cam_snapshot;

/** Init function */
void isaac_init(void)
{
send_cam_snapshot = false;
send_cam_payload = false;

memset(&cam_payload, 0, sizeof(cam_payload));
memset(&cam_snapshot, 0, sizeof(cam_snapshot));
}

/** Periodic function */
void isaac_periodic(void)
{
if (send_cam_snapshot)
{
// send down to GCS
DOWNLINK_SEND_CAMERA_SNAPSHOT(DefaultChannel, DefaultDevice,
&cam_snapshot.cam_id,
&cam_snapshot.cam_state,
&cam_snapshot.snapshot_num,
&cam_snapshot.snapshot_valid,
&cam_snapshot.lens_temp);

send_cam_snapshot = false;
}

if (send_cam_payload)
{
// send down to GCS
DOWNLINK_SEND_CAMERA_PAYLOAD(DefaultChannel, DefaultDevice,
&cam_payload.timestamp,
&cam_payload.used_mem,
&cam_payload.used_disk,
&cam_payload.door_status,
&cam_payload.error_code);

send_cam_payload = false;
}
}

/** Message processing functions
* It would be nice to be able to have the dl buffer passed as
* an argument to the parsing function, but for now we assume that
* the message always comes from the extra_dl_buffer
*
* In case of multiple cameras, it is up to the payload computer to send
* CAMERA_SNAPSHOT messages for each camera at proper interval, so the values
* don't get overwritten.
*
* TODO: protect with mutexes?
* */
void isaac_parse_cam_snapshot_dl(void)
{
// copy CAMERA_SNAPSHOT message and mark it to be sent
cam_snapshot.cam_id = DL_CAMERA_SNAPSHOT_camera_id(extra_dl_buffer);
cam_snapshot.cam_state = DL_CAMERA_SNAPSHOT_camera_state(extra_dl_buffer);
cam_snapshot.snapshot_num = DL_CAMERA_SNAPSHOT_snapshot_image_number(extra_dl_buffer);
cam_snapshot.snapshot_valid = DL_CAMERA_SNAPSHOT_valid_snapshot(extra_dl_buffer);
cam_snapshot.lens_temp = DL_CAMERA_SNAPSHOT_lens_temp(extra_dl_buffer);
}

void isaac_parse_cam_payload_dl(void){
// copy CAMERA_PAYLOAD message and mark it to be sent
cam_payload.timestamp = DL_CAMERA_PAYLOAD_timestamp(extra_dl_buffer);
cam_payload.used_mem = DL_CAMERA_PAYLOAD_used_memory(extra_dl_buffer);
cam_payload.used_disk = DL_CAMERA_PAYLOAD_used_disk(extra_dl_buffer);
cam_payload.door_status = DL_CAMERA_PAYLOAD_door_status(extra_dl_buffer);
cam_payload.error_code = DL_CAMERA_PAYLOAD_error_code(extra_dl_buffer);

send_cam_payload = true;
}
73 changes: 73 additions & 0 deletions sw/airborne/modules/cartography/isaac.h
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2016 2017 Michal Podhradsky <http://github.com/podhrmic>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/**
* @file "modules/cartography/isaac.h"
*
* ISaAC: The Intelligent Safety and Airworthiness Co-Pilot module
* Based on paper "A Payload Verification and Management Framework
* for Small UAV-based Personal Remote Sensing Systems" by Cal Coopmans
* and Chris Coffin. Link: http://ieeexplore.ieee.org/abstract/document/6309316/
*
* ISaAC is intented mainly for mapping applications.
*
* This module processes messages from ISaAC, and either forwards them to the GCS
* (such as CAMERA_SNAPSHOT or CAMERA_PAYLOAD messages), or responds to them necessary
* (such as MOVE_WP).
*
* The module assumes the source of the messages is trusted (i.e. not authentication besides
* AC_ID check is performed).
*/

#ifndef ISAAC_H
#define ISAAC_H

#include "subsystems/datalink/datalink.h"
#include "modules/datalink/extra_pprz_dl.h"

struct CameraPayload {
float timestamp;
uint8_t used_mem;
uint8_t used_disk;
uint8_t door_status;
uint8_t error_code;
};

struct CameraSnapshot {
uint16_t cam_id;
uint8_t cam_state;
uint16_t snapshot_num;
uint8_t snapshot_valid;
float lens_temp;
};

/** Init function */
void isaac_init(void);

/** Periodic function */
void isaac_periodic(void);

/** Message processing functions */
void isaac_parse_cam_snapshot_dl(void);
void isaac_parse_cam_payload_dl(void);

#endif /* ISAAC_H */

2 changes: 2 additions & 0 deletions sw/airborne/modules/datalink/extra_pprz_dl.h
Expand Up @@ -41,6 +41,8 @@
/* PPRZ transport structure */
extern struct pprz_transport extra_pprz_tp;

extern uint8_t extra_dl_buffer[MSG_SIZE] __attribute__((aligned));

/** Datalink Event */
void extra_pprz_dl_event(void);

Expand Down
2 changes: 1 addition & 1 deletion sw/ext/pprzlink

0 comments on commit b3a18af

Please sign in to comment.