-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d5e6ce
commit b3fa451
Showing
376 changed files
with
82,523 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
_build | ||
build | ||
dist | ||
|
||
src/robomaster.egg-info | ||
__pycache__ | ||
*pyc | ||
!.gitignore | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# Code Style Guide | ||
|
||
The code should generally follow [PEP8](https://www.python.org/dev/peps/pep-0008/) | ||
|
||
Code documentation should be written using Google style, which can be extracted | ||
using Sphinx: | ||
* http://google.github.io/styleguide/pyguide.html | ||
* http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html | ||
|
||
|
||
Main style points to consider: | ||
|
||
## Line Length | ||
|
||
PEP8 recommends a maximum line length of 80 characters. While some lines | ||
are easier to read if they're a bit longer than that, generally try to stay | ||
within the 80 character limit. | ||
|
||
Parameter lists can be wrapped and long strings can be split by enclosing them | ||
in parentheses: | ||
|
||
````python | ||
long_string = ('First long line...' | ||
'Second long line') | ||
```` | ||
|
||
or by using triple quotes. | ||
|
||
## White Space | ||
|
||
Indentation should be made using 4 space characters. | ||
|
||
* Two blank lines between class definitions and top-level functions | ||
* One blank line between methods (generally) | ||
|
||
Follow [PEP8 guidelines](https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements) | ||
for whitespace in expressions and statements. | ||
|
||
## Imports | ||
|
||
Import statements should be arranged in three blocks at the head of the file | ||
(though after the module documentation). Each block of imports should be in | ||
alphabetical order. | ||
|
||
1. The first block should be Python-provided packages (eg. `sys`) | ||
2. The second block should be third-party packages (eg. `numpy`) | ||
3. The final block should be local packages and module (eg. `from . import camera`) | ||
|
||
````python | ||
import os | ||
import sys | ||
|
||
import numpy | ||
|
||
from . import camera | ||
from . import event | ||
```` | ||
|
||
Wildcard imports (`from module import *`) should not be used outside of tests. | ||
|
||
Additionally it is generally useful to avoid importing variables from modules | ||
directly into the local namespace (`from module import some_object`) - Doing | ||
so means you now have two references to to the same thing, which impedes | ||
mocking during unit tests. | ||
|
||
Better instead to import the module and reference a qualified name (`import module` | ||
and `module.some_object`). | ||
|
||
## Names | ||
|
||
* Module level constants should be in CAPS | ||
* Class names should be CamelCase | ||
* Variables, attributes, functions, methods and properties should be lowercase_with_underscores | ||
* Variables, attributes, functions, methods and properties can be named with a | ||
leading underscore to indicate that they're "private" | ||
|
||
## Documentation | ||
|
||
See http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html | ||
for documentation examples. | ||
|
||
* Module-level documentation should appear first in the file, before imports | ||
* All public-facing classes, functions, methods etc should be documented | ||
* The first line of a docstring should contain the summary of what the item does. | ||
This should be followed by a blank line and the extended description, if any. | ||
* Use Sphinx-friendly markup (per the Google guide above) so that cross-references | ||
work automatically and examples are formatted correctly. | ||
|
||
### Documenting properties and attributes | ||
|
||
For class and object attributes, use the `#:` comment syntax rather than a | ||
trailing docstring. Instance attributes can be documented in the `__init__` | ||
constructor. | ||
|
||
Properties should use a docstring like any other method, but should be | ||
written in the same style as an attribute, as that's how they'll be presented | ||
in Sphinx (ie. as `return_type: description`). | ||
|
||
Properties with setters must have the docstring on the getter rather than | ||
the setter. | ||
|
||
|
||
```python | ||
class MyClass: | ||
"""One line summary of class. | ||
Docstring for constructor should appear in the class description | ||
Args: | ||
default_timeout (int): Default number of seconds for operations to | ||
wait for timeout. | ||
""" | ||
#: string: Description of a class-level attribute. The description | ||
#: may span multiple lines as long as they all begin with #: | ||
class_level_attr = '' | ||
|
||
def __init__(self, default_timeout=None): | ||
#: int: The default number of seconds for operations to wait for timeout. | ||
self.default_timeout = default_timeout | ||
|
||
@property | ||
def timeout_enabled(self): | ||
""" description. | ||
bool: True if a value for :attr:`default_timeout` has been set. | ||
return: | ||
exception: | ||
""" | ||
return self.default_timeout is not None | ||
``` | ||
|
||
|
||
## Exceptions | ||
|
||
Wherever practical, catch explicit exception classes rather than using | ||
a bare try/except statement (or matching `Exception`). | ||
|
||
To re-raise the original exception use `raise` by itself or | ||
`raise MyException() from exc` | ||
(rather than `raise exc`) to maintain the original stack trace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*-coding:utf-8-*- | ||
# Copyright (c) 2020 DJI. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License in the file LICENSE.txt or at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
import robomaster | ||
from robomaster import robot | ||
|
||
|
||
if __name__ == '__main__': | ||
tl_drone = robot.Drone() | ||
tl_drone.initialize() | ||
|
||
# 获取飞机SSID信息 | ||
ssid = tl_drone.get_ssid() | ||
print("drone ssid: {0}".format(ssid)) | ||
|
||
tl_drone.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output | ||
dist | ||
build | ||
libmedia_codec.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
cmake_minimum_required(VERSION 3.4.1) | ||
project (robomaster_media_codec) | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_BUILD_TYPE Release) | ||
SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/output) | ||
|
||
set(PYBIND11_PYTHON_VERSION 3) | ||
add_subdirectory(pybind11) | ||
|
||
pybind11_add_module(libmedia_codec src/media_codec.cpp) | ||
|
||
IF (CMAKE_SYSTEM_NAME MATCHES "Windows") | ||
SET(OPUS_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/src/opus-share/include") | ||
SET(OPUS_LIBRARIES "${CMAKE_SOURCE_DIR}/src/opus-share/lib/opus.lib") | ||
SET(FFMEPG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/src/ffmpeg-4.2.2-win64-dev/include") | ||
SET(FFMEPG_LIBRARIES_PATH "${CMAKE_SOURCE_DIR}/src/ffmpeg-4.2.2-win64-dev/lib") | ||
target_link_libraries(libmedia_codec PRIVATE | ||
${FFMEPG_LIBRARIES_PATH}/avcodec.lib | ||
${FFMEPG_LIBRARIES_PATH}/swscale.lib | ||
${FFMEPG_LIBRARIES_PATH}/avutil.lib | ||
${OPUS_LIBRARIES}) | ||
target_include_directories(libmedia_codec PRIVATE | ||
${FFMEPG_INCLUDE_DIRS} | ||
${OPUS_INCLUDE_DIRS}) | ||
ELSE () | ||
target_link_libraries(libmedia_codec PRIVATE opus avcodec swscale avutil) | ||
ENDIF (CMAKE_SYSTEM_NAME MATCHES "Windows") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Copyright (c) 2016 The Pybind Development Team, All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
You are under no obligation whatsoever to provide any bug fixes, patches, or | ||
upgrades to the features, functionality or performance of the source code | ||
("Enhancements") to anyone; however, if you choose to make your Enhancements | ||
available either publicly, or directly to the author of this software, without | ||
imposing a separate written license agreement for such Enhancements, then you | ||
hereby grant the following license: a non-exclusive, royalty-free perpetual | ||
license to install, use, modify, prepare derivative works, incorporate into | ||
other computer software, distribute, and sublicense such enhancements or | ||
derivative works thereof, in binary and source code form. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include README.md LICENSE | ||
global-include CMakeLists.txt *.cmake | ||
recursive-include src * | ||
recursive-include pybind11/include *.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# cmake_example for pybind11 | ||
|
||
[](https://travis-ci.org/pybind/cmake_example) | ||
[](https://ci.appveyor.com/project/dean0x7d/cmake-example/branch/master) | ||
|
||
An example [pybind11](https://github.com/pybind/pybind11) module built with a | ||
CMake-based build system. This is useful for C++ codebases that have an existing | ||
CMake project structure. | ||
|
||
|
||
## Prerequisites | ||
|
||
**On Unix (Linux, OS X)** | ||
|
||
* A compiler with C++11 support | ||
* CMake >= 2.8.12 | ||
|
||
**On Windows** | ||
|
||
* Visual Studio 2015 (required for all Python versions, see notes below) | ||
* CMake >= 3.1 | ||
|
||
|
||
## Installation | ||
|
||
Just clone this repository and pip install. Note the `--recursive` option which is | ||
needed for the pybind11 submodule: | ||
|
||
```bash | ||
git clone --recursive https://github.com/pybind/cmake_example.git | ||
pip install ./cmake_example | ||
``` | ||
|
||
With the `setup.py` file included in this example, the `pip install` command will | ||
invoke CMake and build the pybind11 module as specified in `CMakeLists.txt`. | ||
|
||
|
||
## Special notes for Windows | ||
|
||
**Compiler requirements** | ||
|
||
Pybind11 requires a C++11 compliant compiler, i.e Visual Studio 2015 on Windows. | ||
This applies to all Python versions, including 2.7. Unlike regular C extension | ||
modules, it's perfectly fine to compile a pybind11 module with a VS version newer | ||
than the target Python's VS version. See the [FAQ] for more details. | ||
|
||
**Runtime requirements** | ||
|
||
The Visual C++ 2015 redistributable packages are a runtime requirement for this | ||
project. It can be found [here][vs2015_runtime]. If you use the Anaconda Python | ||
distribution, you can add `vs2015_runtime` as a platform-dependent runtime | ||
requirement for you package: see the `conda.recipe/meta.yaml` file in this example. | ||
|
||
|
||
## Building the documentation | ||
|
||
Documentation for the example project is generated using Sphinx. Sphinx has the | ||
ability to automatically inspect the signatures and documentation strings in | ||
the extension module to generate beautiful documentation in a variety formats. | ||
The following command generates HTML-based reference documentation; for other | ||
formats please refer to the Sphinx manual: | ||
|
||
- `cd cmake_example/docs` | ||
- `make html` | ||
|
||
|
||
## License | ||
|
||
Pybind11 is provided under a BSD-style license that can be found in the LICENSE | ||
file. By using, distributing, or contributing to this project, you agree to the | ||
terms and conditions of this license. | ||
|
||
|
||
## Test call | ||
|
||
```python | ||
import cmake_example | ||
cmake_example.add(1, 2) | ||
``` | ||
|
||
|
||
[FAQ]: http://pybind11.rtfd.io/en/latest/faq.html#working-with-ancient-visual-studio-2009-builds-on-windows | ||
[vs2015_runtime]: https://www.microsoft.com/en-us/download/details.aspx?id=48145 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# - Find the opus include file and library | ||
# | ||
# OPUS_FOUND - system has opus | ||
# OPUS_INCLUDE_DIRS - the opus include directory | ||
# OPUS_LIBRARIES - The libraries needed to use opus | ||
|
||
find_path(OPUS_INCLUDE_DIRS | ||
NAMES opus/opus.h | ||
PATH_SUFFIXES include | ||
) | ||
if(OPUS_INCLUDE_DIRS) | ||
set(HAVE_OPUS_OPUS_H 1) | ||
endif() | ||
|
||
find_library(OPUS_LIBRARIES NAMES opus) | ||
|
||
if(OPUS_LIBRARIES) | ||
find_library(LIBM NAMES m) | ||
if(LIBM) | ||
list(APPEND OPUS_LIBRARIES ${LIBM}) | ||
endif() | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Opus | ||
DEFAULT_MSG | ||
OPUS_INCLUDE_DIRS OPUS_LIBRARIES HAVE_OPUS_OPUS_H | ||
) | ||
|
||
mark_as_advanced(OPUS_INCLUDE_DIRS OPUS_LIBRARIES HAVE_OPUS_OPUS_H) |
Oops, something went wrong.