Skip to content

Commit

Permalink
Merge pull request #1323 from paparazzi/digital_cam_video
Browse files Browse the repository at this point in the history
[module] digital_cam_video
  • Loading branch information
flixr committed Sep 1, 2015
2 parents 87c25f0 + 3d0d628 commit c51f4d9
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 10 deletions.
9 changes: 7 additions & 2 deletions conf/modules/digital_cam.xml
Expand Up @@ -2,7 +2,12 @@

<module name="digital_cam">
<doc>
<description>Digital camera control (trigger using GPIO)</description>
<description>
Digital Photo Camera Triggering (using a GPIO pin)

This module controls triggering of an attached external digital camera via one or more GPIO pins for on/off/shoot/zoom.
It can trigger photos based on GPS distance, time or circle radius in both fixedwings and rotorcraft.
</description>
<define name="DC_SHOOT_ON_BUTTON_RELEASE" description="if defined, call dc_send_shot_postion on button release instead of on push"/>
<define name="DC_SHUTTER_GPIO" value="GPIOC,GPIO12" description="mandatory, gpio to control shutter"/>
<define name="DC_ZOOM_IN_GPIO" value="GPIOC,GPIO2" description="optional, gpio to activate zoom in"/>
Expand Down Expand Up @@ -45,7 +50,7 @@
</dl_settings>
</settings>

<conflicts>digital_cam_i2c,digital_cam_servo,digital_cam_uart</conflicts>
<conflicts>digital_cam_i2c,digital_cam_servo,digital_cam_uart,digital_cam_video</conflicts>

<header>
<file name="gpio_cam_ctrl.h"/>
Expand Down
10 changes: 7 additions & 3 deletions conf/modules/digital_cam_i2c.xml
Expand Up @@ -3,13 +3,17 @@
<module name="atmega_i2c_cam_ctrl" dir="digital_cam">
<doc>
<description>
Trigger Digital Camera (I2C).
Using I2C connected remote microcontroller
Digital Photo Camera Triggering (using a I2C channel)

This module controls triggering of an attached device via an I2C command.
Typically a remote microcontroller (atmega/arduino) will then use the triggering/zoom/power commands.
Using the PAYLOAD_COMMAND, all functions of the camera can be controlled.
It can trigger photos based on GPS distance, time or circle radius in both fixedwings and rotorcraft.
</description>
<define name="DC_SHOOT_ON_BUTTON_RELEASE" />
<define name="DC_SHOT_SYNC_SEND" value="TRUE|FALSE" description="send DC_SHOT message when photo was taken (default: TRUE)"/>
</doc>
<conflicts>digital_cam,digital_cam_servo,digital_cam_uart</conflicts>
<conflicts>digital_cam,digital_cam_servo,digital_cam_uart,digital_cam_video</conflicts>
<header>
<file name="atmega_i2c_cam_ctrl.h"/>
<file name="dc.h"/>
Expand Down
9 changes: 7 additions & 2 deletions conf/modules/digital_cam_servo.xml
Expand Up @@ -2,7 +2,12 @@

<module name="digital_cam_servo" dir="digital_cam">
<doc>
<description>Digital camera control (trigger using servo)</description>
<description>
Digital Photo Camera Triggering (using a servo)

This module controls triggering of an attached external digital camera via a servo channel.
It can trigger photos based on GPS distance, time or circle radius in both fixedwings and rotorcraft.
</description>
<define name="DC_SHOOT_ON_BUTTON_RELEASE" description="if defined, call dc_send_shot_postion on button release instead of on push"/>
<define name="DC_SHUTTER_SERVO" value="servo" description="mandatory, Servo to control shutter"/>
<define name="DC_ZOOM_IN_SERVO" value="servo" description="optional, Servo to activate zoom in"/>
Expand All @@ -12,7 +17,7 @@
<define name="DC_AUTOSHOOT_DISTANCE_INTERVAL" value="50" description="grid in meters"/>
</doc>

<conflicts>digital_cam,digital_cam_i2c,digital_cam_uart</conflicts>
<conflicts>digital_cam,digital_cam_i2c,digital_cam_uart,digital_cam_video</conflicts>

<header>
<file name="servo_cam_ctrl.h"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/digital_cam_shoot_rc.xml
Expand Up @@ -11,7 +11,7 @@
</description>
<define name="DC_RADIO_SHOOT" value="RADIO_xxx" description="specifies the channel to be used to trigger the camera by radio transmiter"/>
</doc>
<depends>digital_cam|digital_cam_servo|digital_cam_uart|digital_cam_i2c</depends>
<depends>digital_cam|digital_cam_servo|digital_cam_uart|digital_cam_i2c|digital_cam_video</depends>
<header>
<file name="dc_shoot_rc.h"/>
</header>
Expand Down
19 changes: 17 additions & 2 deletions conf/modules/digital_cam_uart.xml
Expand Up @@ -2,8 +2,23 @@
<module name="uart_cam_ctrl" dir="digital_cam">
<doc>
<description>
Digital Camera Triggering over UART link.
Send attitude and other relevant data to a computer based photocamera after a shootphoto command is given. And in return get certain value back from the computerbased photocamera to be able to intercat with the flightplan.</description>
Digital Photo Camera Triggering (using a UART link)

This module controls triggering of an attached external digital camera via UART commands.
It can trigger photos based on GPS distance, time or circle radius in both fixedwings and rotorcraft.

This module fullfilss 4 functions:
1) send shoot commands over UART
2) Besides triggering the shooting of images, the module also sends attitude and other relevant data.
Typically an external linux camera or linux computer will receive the attitude and position data and add
it to the photos.
3) The module will also parse the replies received over the UART. This contains status but can also
contain computer vision results to able to interact with the flightplan.
4) Finally, the module will also relay over telemetry all data it receives from the attached computer
or camera using the PAYLOAD message. This can for instance be used to downlink thumbnails.

The linux program used to parse the UART command is given in the subdirectory.
</description>
<define name="DC_AUTOSHOOT_PERIOD" value="0.5" description="time period for DC_AUTOSHOOT_PERIODIC in seconds"/>
<define name="DC_AUTOSHOOT_DISTANCE_INTERVAL" value="50" description="grid in meters"/>
<define name="DC_SHOT_SYNC_SEND" value="TRUE|FALSE" description="send DC_SHOT message when photo was taken (default: TRUE)"/>
Expand Down
57 changes: 57 additions & 0 deletions conf/modules/digital_cam_video.xml
@@ -0,0 +1,57 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="video_cam_ctrl" dir="digital_cam">
<doc>
<description>
Digital Photo Camera Triggering (using embedded video)

This module controls triggering of an embedded digital camera on a linux based autopilot. This particular version triggers the video_rtp_stream.xml module to store jpeg images.
It can trigger photos based on GPS distance, time or circle radius in both fixedwings and rotorcraft.
</description>
<define name="DC_AUTOSHOOT_PERIOD" value="0.5" description="time period for DC_AUTOSHOOT_PERIODIC in seconds"/>
<define name="DC_AUTOSHOOT_DISTANCE_INTERVAL" value="50" description="grid in meters"/>
<define name="DC_SHOT_SYNC_SEND" value="TRUE|FALSE" description="send DC_SHOT message when photo was taken (default: TRUE)"/>
</doc>
<settings>
<dl_settings name="control">
<dl_settings name="dc">

<dl_setting max="255" min="0" step="1" module="digital_cam/dc" var="0" handler="send_command" shortname="Shutter">
<strip_button name="Photo" icon="digital-camera.png" value="32" group="maindc"/>
</dl_setting>

<dl_setting max="3" min="0" step="1" var="dc_autoshoot" values="STOP|PERIODIC|DISTANCE|EXT_TRIG">
<strip_button name="Start Autoshoot" icon="on.png" value="1" group="dcauto"/>
<strip_button name="Stop Autoshoot" icon="off.png" value="0" group="dcauto"/>
</dl_setting>

<dl_setting max="60" min="0.1" step="0.5" var="dc_autoshoot_period" shortname="Periodic" param="DC_AUTOSHOOT_PERIOD" unit="sec"/>
<dl_setting max="255" min="0" step="1" var="dc_distance_interval" shortname="dist" param="DC_AUTOSHOOT_DISTANCE_INTERVAL" unit="meter"/>

<dl_setting max="250" min="0" step="5" module="digital_cam/dc" var="dc_survey_interval" handler="Survey" shortname="Survey-Interval"/>
<dl_setting max="90" min="5" step="5" module="digital_cam/dc" var="dc_circle_interval" handler="Circle" shortname="Circle-Interval"/>
<dl_setting max="1" min="0" step="1" var="dc_cam_tracing" shortname="Cam-Tracing"/>
</dl_settings>
</dl_settings>
</settings>

<depends>video_rtp_stream</depends>

<conflicts>digital_cam,digital_cam_servo,digital_cam_i2c,digital_cam_uart</conflicts>

<header>
<file name="video_cam_ctrl.h"/>
<file name="dc.h"/>
</header>

<init fun="digital_cam_video_init()"/>

<periodic fun="digital_cam_video_periodic()" freq="10" autorun="TRUE"/>

<makefile target="ap|sim|nps">
<define name="DIGITAL_CAM" />
<file name="video_cam_ctrl.c"/>
<file name="dc.c"/>
</makefile>

</module>

70 changes: 70 additions & 0 deletions sw/airborne/modules/digital_cam/video_cam_ctrl.c
@@ -0,0 +1,70 @@
/*
* Copyright (C)
*
* 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/digital_cam/video_cam_ctrl.c
*/

#include "video_cam_ctrl.h"
#include "generated/airframe.h"

// Include Standard Camera Control Interface
#include "modules/digital_cam/dc.h"


void digital_cam_video_init(void)
{
// Call common DC init
dc_init();
}

void digital_cam_video_periodic(void)
{
// Common DC Periodic task
dc_periodic();
}

#ifndef SITL
#include "viewvideo.h"
#endif

/* Command The Camera */
void dc_send_command(uint8_t cmd)
{
switch (cmd) {
case DC_SHOOT:
#ifndef SITL
viewvideo_take_shot(TRUE);
#endif
dc_send_shot_position();
break;
case DC_TALLER:
break;
case DC_WIDER:
break;
case DC_ON:
break;
case DC_OFF:
break;
default:
break;
}
}
36 changes: 36 additions & 0 deletions sw/airborne/modules/digital_cam/video_cam_ctrl.h
@@ -0,0 +1,36 @@
/*
* Copyright (C)
*
* 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/digital_cam/video_cam_ctrl.h
* @brief Digital Camera Control: controls triggering of an embedded digital camera on a linux based autopilot
*
*/

#ifndef DIGITAL_CAM_VIDEO_H
#define DIGITAL_CAM_VIDEO_H

#include "modules/digital_cam/dc.h"

extern void digital_cam_video_init(void);

extern void digital_cam_video_periodic(void);

#endif // GPIO_CAM_CTRL_H

0 comments on commit c51f4d9

Please sign in to comment.