Giter Site home page Giter Site logo

goprocontroller's Introduction

GoProController

An http API to control multiple GoPro cameras over wifi.

Description

This program can be used to control multiple GoPro cameras via the goprohero Python library. When ran from a Linux machine with compatible wireless card, this program is capable of automatically negotiating between the different ad-hoc wireless networks that each cameras makes.

A user interface is available for this API as a standalone package. See GoProControllerUI.

How it works

The backbone of GoProApp is a program called GoProProxy that runs asynchronously to the server. This proxy periodically grabs the status of every camera in the database and sends commands to cameras when appropriate. The proxy uses wifi to jump between networks and goprohero to handle the communication to the cameras. A Django app is used to persist data from the proxy and serve API endpoints.

diagram

Note: The xml version of the above diagram can be modified with https://www.draw.io/.

Production Setup (Ubuntu)

First, download the code:

git clone https://github.com/joshvillbrandt/GoProController.git ~/GoProController
sudo ln -s ~/GoProController /home/GoProController

If you are running Ubuntu, use the setup.sh script to automatically set up the application in a production mode:

sudo /home/GoProController/setup.sh

Upon completion of setup.sh, you should now be able to navigate to http://localhost/ and see the API. In addition, the GoProApp/proxy.py file is also now running continuously to the local wifi adapter and communicate with the cameras.

You can interact with the server and proxy using service and initctl:

sudo service apache2 status
sudo initctl status gopro-proxy

Logs for both are also available:

tail /var/log/apache2/error.log
tail -f /var/log/gopro-proxy.log

To set a specific interface for wifi control, add the following to upstart.conf:

env GOPRO_WIFI_INTERFACE=wlan1

Development Setup (Ubuntu, Mac)

To run GoProApp without Apache and Upstart, launch the site with the Django development server:

git clone https://github.com/joshvillbrandt/GoProController.git ~/GoProController
cd ~/GoProController
sudo python setup.py install
python manage.py runserver 0.0.0.0:8000

In another terminal window, launch the proxy to communicate with the cameras:

sudo python ~/GoProController/proxy.py # sudo needed for logging (or add yourself to syslog in Ubuntu)

You should now be able to navigate to http://localhost:8000/ and see the API.

To set a specific interface for wifi control, add the following environment variable before the proxy command:

sudo GOPRO_WIFI_INTERFACE='wlan1' python ~/GoProController/proxy.py

API

This API provides the following endpoints:

Endpoint Actions
/cameras GET, POST
/cameras/:id GET, PUT
/commands GET, POST
/commands/:id GET, PUT

The API if build on the Django REST Framework. Please reference their documentation for detailed querying information.

Change History

This project uses semantic versioning.

v0.2.4 - 2015/01/29

  • Added GOPRO_SNAPSHOTS environment flag to turn off grabbing snapshots images if desired
  • The proxy now fails commands when it can't find the camera instead of leaving them in the queue to block everybody else
  • Added spammer.py - try sudo goprospammer -p record -v on
  • Added logger.py - try goprologger -d output

v0.2.3 - 2015/01/14

  • Updated goprohero and wireless library versions

v0.2.2 - 2015/01/06

  • Pagination is now supported; try ?page=1&limit=20
  • Basic sorting/ordering is now supported; try ?ordering=-date_added
  • Fixed a schema bug that prevented commands without values from being saved (commands like delete_all and delete_last)

v0.2.1 - 2014/12/03

  • Updated for library change from gopro to goprohero
  • Fixed bugs in setup.sh
  • Moved API root to /api when using the Apache config
  • Added the /api/config endpoint
  • Added support to serve GoProControllerUI static content at /

v0.2.0 - 2014/11/24

  • Renamed project from GoProApp to GoProController
  • Refactored user interface out of the project and into GoProControllerUI
  • Now contains a RESTful API for cameras and commands

v0.1.1 - 2014/09/11

  • Bug fixes

v0.1.0 - 2013/10/31

  • Initial release

Known Issues

There is a memory leak that will cause the program to crash after a couple hours of use with two or more cameras. (It will crash quicker with just one camera since the program runs quicker without network hops.) I've spent a few hours trying to track down the issue to no avail. It seems as though there are uncollectable objects from both the Django side and the GoPro/urllib2 side. I tried replacing urllib2 with python-requests/urllib3, but that didn't help. I used gc and objgraph to help debug.

Contributions

Pull requests to the develop branch are welcomed!

goprocontroller's People

Contributors

joshvillbrandt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goprocontroller's Issues

GoProController and GoProControllerUI installation issues

Lately I have been fiddling around with the GoPro software. The GoPro Hero library installs fine and seems to be working on my Ubuntu 14.4 (64bit) machine.

However, after installing the GoProController I run into problems - the page at http://localhost/ shows a no permission error

"Forbidden - You don't have permission to access / on this server"

Looking at the Apache configuration I can see that access is granted for /home/GoProControllerUI/_public. But this directory does not exist.

Apparently, it should be there after installing GoProControllerUI. However, this installation runs into the error of a ambiguous "node" binary which prevents correct installation (see below).


npm http GET https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.0.tgz
/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp
npm http GET https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.19.0-31-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/gopro/GoProControllerUI/node_modules/auto-reload-brunch/node_modules/ws/node_modules/bufferutil
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm http 200 https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.0.tgz

npm http 200 https://registry.npmjs.org/is-property
npm http GET https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz
npm http 200 https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz

[email protected] postinstall /home/gopro/GoProControllerUI
node_modules/bower/bin/bower install --config.interactive=false

/usr/bin/env: node: No such file or directory
npm ERR! weird error 127
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0

Latency between switching cameras

HI Josh, it looks like the api is constantly switch between the gopro's wifi networks? What is the latency between the camera switching (disconnect/connect to a new wifi network)?

Thanks!

Cannot connect to Hero4

I am having trouble connecting to Hero4 cameras. I've tried all 7 of our cams. I tried resetting the wireless settings. I've looked everywhere and cannot find a fix. Am I missing something with the SSID? I am using the camera's network name and password for the SSID and password. The cameras connect fine using WIFI remote/app/http . Can you help? Thanks.

Shows disconnected / hardware support

Hey,

Great library. Im seeing disconnected when I followed the instructions for GoProController and GoProControllerUI. Can you post some hardware setups that have worked for you?

Also, what is the process for setting up the GoPros to connect to the django app?

Thanks!

GoPro Hero 4 Black not functioning

The Hero 4 Black does not communicate status while sleeping. It does not power on by command. It will report when turned on, and will receive record and sleep commands. The rest seem to be ignored.

Cannot add new cameras

When I click add camera nothing happens. I cannot figure out how to add my gopros to this UI/API. Everything seems to be working otherwise. The webpage/UI appears just like the screenshot and I did not encounter any issues or warnings during the install.

Cannot access the API

It seems that something is wrong with django. Here is the error I get:

`Environment:

Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.7.1
Python Version: 2.7.9
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'GoProController')
Installed Middleware:
('corsheaders.middleware.CorsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:
File "/usr/local/lib/python2.7/dist-packages/Django-1.7.1-py2.7.egg/django/core/handlers/base.py" in get_response
98. resolver_match = resolver.resolve(request.path_info)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7.1-py2.7.egg/django/core/urlresolvers.py" in resolve
343. for pattern in self.url_patterns:
File "/usr/local/lib/python2.7/dist-packages/Django-1.7.1-py2.7.egg/django/core/urlresolvers.py" in url_patterns
372. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7.1-py2.7.egg/django/core/urlresolvers.py" in urlconf_module
366. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/init.py" in import_module
37. import(name)
File "/home/pi/GoProController/GoProController/urls.py" in
4. from rest_framework import serializers, viewsets, routers, filters
File "/usr/local/lib/python2.7/dist-packages/djangorestframework-3.5.4-py2.7.egg/rest_framework/serializers.py" in
23. from django.db.models import DurationField as ModelDurationField

Exception Type: ImportError at /
Exception Value: cannot import name DurationField
`

GoProController

HI,I have Ubuntu(V14.04) and GOPRO3,I want to use WIFI control GOPRO3( take photos,replay,) But I'm not familiar with programming.Can you teach me How to use this demo?

Loss of Communication to GoPros

I lose communication with the GoPros after some time. Usually between 30mins-2hours. Does the proximity between GoPros have any bearing? Is there a known firmware revision that works best?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.