MAVLink Camera Triggering from GCS

928 views
Skip to first unread message

andrew.m...@sentera.com

unread,
Sep 8, 2015, 5:34:07 PM9/8/15
to drones-discuss
Please be gentle, this is my first venture into the drones-discuss group and the Ardupilot community.

Sentera is working toward making our cameras compatible with Pixhawk/Ardupilot/MAVLink.  Our cameras listen for MAVLink DO_DIGICAM_CONTROL messages.  Things are working well for Survey Grids generated in Mission Planner using both DO_DIGICAM_CONTROL commands and CAM_TRIGG_DIST.  Mission Planner's "Trigger Camera NOW" option sends a DO_DIGICAM_CONTROL message, which is processed by AP_Camera::control_msg() in the ardupilot code.  AP_Camera::control_msg() calls trigger_pic with the "send_mavlink_msg" parameter set to false, meaning "Trigger Camera NOW" (or any other GCS sending a DO_DIGICAM_CONTROL message) will only trigger cameras via PWM or Relay.  When I change this line to call trigger_pic(true), the messages is forwarded over MAVLink and we take picture as desired.

In our case, forwarding DO_DIGICAM_CONTROL messages from the ground station (or any other node) to the camera over MAVLink is desired.  Are there cases where forwarding would be problematic, or would this be a positive change all around?  I wanted to do a sanity check to make sure this change would be welcome before I submit this one line patch on github.

Thanks,

Andrew

Jaime Machuca

unread,
Sep 8, 2015, 8:30:30 PM9/8/15
to drones-...@googlegroups.com
Hi Andrew we got this forwarding already working on the ardupilot code, we added this when I wrote the Mavproxy smart camera module. There may be something off on your system if you are bit seeing the messages. Can you share a bit more O. How the connections are on tour system?

Saludos / Best Regards

Jaime Machuca Mercado
CTO | Droidika | www.Droidika.com




Este correo electrónico y cualquier archivo transmitido en él, son confidenciales y para uso exclusivo de los individuos y entidades a quienes está dirigido. Si usted no es el destinatario previsto o la persona encargada de recibirlo, y tiene por error este mensaje, queda prohibido y sin validez el uso, difusión, re-envío, reimpresión o copia. Toda oferta y/o aceptación de propuestas comerciales, celebración de contratos u otros actos tendientes a la adquisición de bienes o servicios, así como el establecimiento de cualquier clase de obligación legal para Droidika S.A. de C.V., deberá confirmarse por escrito firmado autógrafamente por funcionario competente, excepto que se cuente con un contrato vigente que autorice el uso de este medio para tales fines. Si usted recibió este correo por equivocación, favor de notificar inmediatamente por este medio a su remitente, y después borrarlo de su correo

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

andrew.m...@sentera.com

unread,
Sep 9, 2015, 9:50:19 AM9/9/15
to drones-discuss
Jaime,

I'm new here and have a lot to learn.  If the solution is already available, perhaps you can point me in the right direction.  I'll outline my system and understanding of what happens.

I am using Mission Planner V1.3.31 to control a Pixhawk autopilot running APMPlane V3.3.0, connected to a Sentera camera via the serial port on TELEM2.  The Sentera camera sends heartbeat packets so the Pixhawk learns the route out TELEM2.     

I do get forwarding for two of the three ways images are triggered.  I'm hoping to get the third way up and running as well.  Here is my understanding of the three ways a picture is triggered

1) Create a mission including a Polygon / Survey Grid with CAM_TRIGG_DIST.  An array of waypoints is generated by the ground station.  A DO_SET_CAM_TRIGG_DIST command is written as a waypoint in the mission immediately following the first waypoint of the mission to enable distance based triggering, and another is added immediately following the last waypoint of the mission to disable.  AP_Camera::update_location is called from ArduPlane.cpp, or ArduCopter.cpp, etc to see if the distance covered merits a new camera trigger.  If it returns true, the calling code executes Plane::do_take_picture() or Copter::do_take_picture(), etc.  Each of these functions calls AP_Camera::trigger_pic(true).  With send_mavlink_msg set to true, a MAVLink message is forwarded to all components, including the camera.

2) Create a mission including a Polygon / Survey Grid with DO_DIGICAM_CONTROL.  A grid of waypoints is generated by the ground station.  A DO_DIGICAM_CONTROL command is written as a waypoint immediately following every photo waypoint in the mission.  These waypoints/commands execute Plane::do_digicam_control or Copter::do_digicam_control, etc which call AP_Camera::control_cmd().  AP_Cameara::control_cmd() calls trigger_pic(false), which does not generate a MAVLink message for forwarding to components.  However, after the trigger(false) call, AP_Camera::control_cmd copies the command contents into a new message and fowards it over MAVLink to all components, including the camera.  In reading through this just now, I'm wondering if the trigger_pic call should only happen on the condition of shooting_cmd==true.  Even if that should be tweaked, it's still working for us.

3) Send an individual DO_DIGICAM_CONTROL message from the ground station.  In Mission Planner, this is implemented by right clicking on the map and selecting "Trigger Camera NOW".  Mission Planner sends a DO_DIGICAM_CONTROL message, which makes its way to AP_Camera::control_msg(), which calls trigger_pic(false).  With send_mavlink_msg set to false, no MAVLink message gets forwarded to the camera.  My proposed solution is to change the single line to trigger_pic(true).  I've compiled and tested on my system and it works.  Alternatively, the full message could be repackaged in a mav_cmd_long with all the parameters preserved, similar to the way AP_Camera::control_cmd works.  This would be more elegant.  Provided this is desired behavior by the community, and not just me, I'm happy to submit a pull request for either approach.

Is there a better way for a camera component to get individual DO_DIGICAM_CONTROL messages sent from a ground station?  A custom ground station could specify a component ID, but then our cameras aren't out-of-the-box compatible with popular ground stations.

Thanks, I appreciate your assistance.

andrew.m...@sentera.com

unread,
Sep 24, 2015, 3:05:27 PM9/24/15
to drones-discuss
Looking in GitHub, rmackay9 committed changes that forward DO_DIGICAM_CONTROL messages to components as is, which looks great to me, and would solve my issue.  When I flashed ArduPlane 3.4.0 to try it, however, I now get two DO_DIGICAM_CONTROL messages each time one is sent from the GCS (Mission Planner for this test).  Does anyone know why?

Michael Oborne

unread,
Sep 24, 2015, 10:17:26 PM9/24/15
to drones-discuss
Currently MP sends 2 packets, one for the older version of ardupilot, and one for the newer versions.
code is here

what packet are you seeing? the command_long?

andrew.m...@sentera.com

unread,
Sep 25, 2015, 5:51:24 PM9/25/15
to drones-discuss
Yes, I see the command long (#76) with MAV_CMD_DO_DIGICAM_CONTROL (#203) inside.  It's the same command twice, in rapid succession (on the order of milliseconds apart).  

ArduPlane v3.3.0 did not forward the messages sent by Mission Planner on "Trigger Camera NOW" to components at all.  Starting with v3.4.0 they are forwarded twice.  The odd part is that modifications I made locally to AP_Camera.cpp from v3.3.0 produced a single forwarded message.  It looks to me that the double message occurs because ArduPlane/GCS_Mavlink.cpp now processes both the old (MAVLINK_MSG_ID_DIGICAM_CONTROL) and new (Command long: MAV_CMD_DO_DIGICAM_CONTROL) messages, whereas v3.3.0 processed only the old.  Processing both results in a call to AP::Camera::control() for the new, and a call to AP::Camera::control_msg() for the old, which subsequently calls AP:Camera::control(). 

I'm not familiar enough with the motivation and difference between the old and new version of these messages to propose an intelligent solution, or whether the change would go in Mission Planner or ArduPlane.  But I do think the desired behavior would be for "Trigger Camera NOW" to result in a single trigger message forwarded to components.

Survey Grids still operate as expected and desired, generating a single command long with #203, MAV_CMD_DO_DIGICAM_CONTROL inside.  I tested for both CAM_TRIGG_DIST and DO_DIGICAM_CONTROL.
Reply all
Reply to author
Forward
0 new messages