parent
af4f9f1f31
commit
61229779e4
112 changed files with 2409 additions and 1089 deletions
Binary file not shown.
@ -0,0 +1,73 @@ |
|||||||
|
import numpy as np |
||||||
|
|
||||||
|
class RunningStat(): |
||||||
|
# tracks realtime mean and standard deviation without storing any data |
||||||
|
def __init__(self, priors=None, max_trackable=-1): |
||||||
|
self.max_trackable = max_trackable |
||||||
|
if priors is not None: |
||||||
|
# initialize from history |
||||||
|
self.M = priors[0] |
||||||
|
self.S = priors[1] |
||||||
|
self.n = priors[2] |
||||||
|
self.M_last = self.M |
||||||
|
self.S_last = self.S |
||||||
|
|
||||||
|
else: |
||||||
|
self.reset() |
||||||
|
|
||||||
|
def reset(self): |
||||||
|
self.M = 0. |
||||||
|
self.S = 0. |
||||||
|
self.M_last = 0. |
||||||
|
self.S_last = 0. |
||||||
|
self.n = 0 |
||||||
|
|
||||||
|
def push_data(self, new_data): |
||||||
|
# short term memory hack |
||||||
|
if self.max_trackable < 0 or self.n < self.max_trackable: |
||||||
|
self.n += 1 |
||||||
|
if self.n == 0: |
||||||
|
self.M_last = new_data |
||||||
|
self.M = self.M_last |
||||||
|
self.S_last = 0. |
||||||
|
else: |
||||||
|
self.M = self.M_last + (new_data - self.M_last) / self.n |
||||||
|
self.S = self.S_last + (new_data - self.M_last) * (new_data - self.M); |
||||||
|
self.M_last = self.M |
||||||
|
self.S_last = self.S |
||||||
|
|
||||||
|
def mean(self): |
||||||
|
return self.M |
||||||
|
|
||||||
|
def variance(self): |
||||||
|
if self.n >= 2: |
||||||
|
return self.S / (self.n - 1.) |
||||||
|
else: |
||||||
|
return 0 |
||||||
|
|
||||||
|
def std(self): |
||||||
|
return np.sqrt(self.variance()) |
||||||
|
|
||||||
|
def params_to_save(self): |
||||||
|
return [self.M, self.S, self.n] |
||||||
|
|
||||||
|
class RunningStatFilter(): |
||||||
|
def __init__(self, raw_priors=None, filtered_priors=None, max_trackable=-1): |
||||||
|
self.raw_stat = RunningStat(raw_priors, max_trackable) |
||||||
|
self.filtered_stat = RunningStat(filtered_priors, max_trackable) |
||||||
|
|
||||||
|
def reset(self): |
||||||
|
self.raw_stat.reset() |
||||||
|
self.filtered_stat.reset() |
||||||
|
|
||||||
|
def push_and_update(self, new_data): |
||||||
|
_std_last = self.raw_stat.std() |
||||||
|
self.raw_stat.push_data(new_data) |
||||||
|
_delta_std = self.raw_stat.std() - _std_last |
||||||
|
if _delta_std<=0: |
||||||
|
self.filtered_stat.push_data(new_data) |
||||||
|
else: |
||||||
|
pass |
||||||
|
# self.filtered_stat.push_data(self.filtered_stat.mean()) |
||||||
|
|
||||||
|
# class SequentialBayesian(): |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,274 @@ |
|||||||
|
BoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL |
||||||
|
licensing. Files that are completely new have a Google copyright and an ISC |
||||||
|
license. This license is reproduced at the bottom of this file. |
||||||
|
|
||||||
|
Contributors to BoringSSL are required to follow the CLA rules for Chromium: |
||||||
|
https://cla.developers.google.com/clas |
||||||
|
|
||||||
|
Files in third_party/ have their own licenses, as described therein. The MIT |
||||||
|
license, for third_party/fiat, which, unlike other third_party directories, is |
||||||
|
compiled into non-test libraries, is included below. |
||||||
|
|
||||||
|
The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the |
||||||
|
OpenSSL License and the original SSLeay license apply to the toolkit. See below |
||||||
|
for the actual license texts. Actually both licenses are BSD-style Open Source |
||||||
|
licenses. In case of any license issues related to OpenSSL please contact |
||||||
|
openssl-core@openssl.org. |
||||||
|
|
||||||
|
The following are Google-internal bug numbers where explicit permission from |
||||||
|
some authors is recorded for use of their work. (This is purely for our own |
||||||
|
record keeping.) |
||||||
|
27287199 |
||||||
|
27287880 |
||||||
|
27287883 |
||||||
|
|
||||||
|
OpenSSL License |
||||||
|
--------------- |
||||||
|
|
||||||
|
/* ==================================================================== |
||||||
|
* Copyright (c) 1998-2011 The OpenSSL Project. 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. All advertising materials mentioning features or use of this |
||||||
|
* software must display the following acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)" |
||||||
|
* |
||||||
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
||||||
|
* endorse or promote products derived from this software without |
||||||
|
* prior written permission. For written permission, please contact |
||||||
|
* openssl-core@openssl.org. |
||||||
|
* |
||||||
|
* 5. Products derived from this software may not be called "OpenSSL" |
||||||
|
* nor may "OpenSSL" appear in their names without prior written |
||||||
|
* permission of the OpenSSL Project. |
||||||
|
* |
||||||
|
* 6. Redistributions of any form whatsoever must retain the following |
||||||
|
* acknowledgment: |
||||||
|
* "This product includes software developed by the OpenSSL Project |
||||||
|
* for use in the OpenSSL Toolkit (http://www.openssl.org/)" |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
||||||
|
* EXPRESSED 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 OpenSSL PROJECT OR |
||||||
|
* ITS 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. |
||||||
|
* ==================================================================== |
||||||
|
* |
||||||
|
* This product includes cryptographic software written by Eric Young |
||||||
|
* (eay@cryptsoft.com). This product includes software written by Tim |
||||||
|
* Hudson (tjh@cryptsoft.com). |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
Original SSLeay License |
||||||
|
----------------------- |
||||||
|
|
||||||
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* This package is an SSL implementation written |
||||||
|
* by Eric Young (eay@cryptsoft.com). |
||||||
|
* The implementation was written so as to conform with Netscapes SSL. |
||||||
|
* |
||||||
|
* This library is free for commercial and non-commercial use as long as |
||||||
|
* the following conditions are aheared to. The following conditions |
||||||
|
* apply to all code found in this distribution, be it the RC4, RSA, |
||||||
|
* lhash, DES, etc., code; not just the SSL code. The SSL documentation |
||||||
|
* included with this distribution is covered by the same copyright terms |
||||||
|
* except that the holder is Tim Hudson (tjh@cryptsoft.com). |
||||||
|
* |
||||||
|
* Copyright remains Eric Young's, and as such any Copyright notices in |
||||||
|
* the code are not to be removed. |
||||||
|
* If this package is used in a product, Eric Young should be given attribution |
||||||
|
* as the author of the parts of the library used. |
||||||
|
* This can be in the form of a textual message at program startup or |
||||||
|
* in documentation (online or textual) provided with the package. |
||||||
|
* |
||||||
|
* 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 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. All advertising materials mentioning features or use of this software |
||||||
|
* must display the following acknowledgement: |
||||||
|
* "This product includes cryptographic software written by |
||||||
|
* Eric Young (eay@cryptsoft.com)" |
||||||
|
* The word 'cryptographic' can be left out if the rouines from the library |
||||||
|
* being used are not cryptographic related :-). |
||||||
|
* 4. If you include any Windows specific code (or a derivative thereof) from |
||||||
|
* the apps directory (application code) you must include an acknowledgement: |
||||||
|
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 AUTHOR 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. |
||||||
|
* |
||||||
|
* The licence and distribution terms for any publically available version or |
||||||
|
* derivative of this code cannot be changed. i.e. this code cannot simply be |
||||||
|
* copied and put under another distribution licence |
||||||
|
* [including the GNU Public Licence.] |
||||||
|
*/ |
||||||
|
|
||||||
|
|
||||||
|
ISC license used for completely new code in BoringSSL: |
||||||
|
|
||||||
|
/* Copyright (c) 2015, Google Inc. |
||||||
|
* |
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any |
||||||
|
* purpose with or without fee is hereby granted, provided that the above |
||||||
|
* copyright notice and this permission notice appear in all copies. |
||||||
|
* |
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
||||||
|
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
||||||
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
||||||
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
||||||
|
|
||||||
|
|
||||||
|
The code in third_party/fiat carries the MIT license: |
||||||
|
|
||||||
|
Copyright (c) 2015-2016 the fiat-crypto authors (see |
||||||
|
https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all |
||||||
|
copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||||
|
SOFTWARE. |
||||||
|
|
||||||
|
|
||||||
|
The code in third_party/sike also carries the MIT license: |
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved. |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all |
||||||
|
copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||||
|
SOFTWARE |
||||||
|
|
||||||
|
|
||||||
|
Licenses for support code |
||||||
|
------------------------- |
||||||
|
|
||||||
|
Parts of the TLS test suite are under the Go license. This code is not included |
||||||
|
in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so |
||||||
|
distributing code linked against BoringSSL does not trigger this license: |
||||||
|
|
||||||
|
Copyright (c) 2009 The Go Authors. All rights reserved. |
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without |
||||||
|
modification, are permitted provided that the following conditions are |
||||||
|
met: |
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright |
||||||
|
notice, this list of conditions and the following disclaimer. |
||||||
|
* 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. |
||||||
|
* Neither the name of Google Inc. 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 |
||||||
|
OWNER 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. |
||||||
|
|
||||||
|
|
||||||
|
BoringSSL uses the Chromium test infrastructure to run a continuous build, |
||||||
|
trybots etc. The scripts which manage this, and the script for generating build |
||||||
|
metadata, are under the Chromium license. Distributing code linked against |
||||||
|
BoringSSL does not trigger this license. |
||||||
|
|
||||||
|
Copyright 2015 The Chromium Authors. All rights reserved. |
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without |
||||||
|
modification, are permitted provided that the following conditions are |
||||||
|
met: |
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright |
||||||
|
notice, this list of conditions and the following disclaimer. |
||||||
|
* 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. |
||||||
|
* Neither the name of Google Inc. 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 |
||||||
|
OWNER 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. |
@ -0,0 +1,42 @@ |
|||||||
|
|
||||||
|
-------------------------------------------------------------------------- |
||||||
|
|
||||||
|
This program, "bzip2", the associated library "libbzip2", and all |
||||||
|
documentation, are copyright (C) 1996-2010 Julian R Seward. 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. The origin of this software must not be misrepresented; you must |
||||||
|
not claim that you wrote the original software. If you use this |
||||||
|
software in a product, an acknowledgment in the product |
||||||
|
documentation would be appreciated but is not required. |
||||||
|
|
||||||
|
3. Altered source versions must be plainly marked as such, and must |
||||||
|
not be misrepresented as being the original software. |
||||||
|
|
||||||
|
4. The name of the author may not be used to endorse or promote |
||||||
|
products derived from this software without specific prior written |
||||||
|
permission. |
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. |
||||||
|
|
||||||
|
Julian Seward, jseward@bzip.org |
||||||
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010 |
||||||
|
|
||||||
|
-------------------------------------------------------------------------- |
Binary file not shown.
@ -0,0 +1,29 @@ |
|||||||
|
Copyright 2011 The LibYuv Project Authors. All rights reserved. |
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without |
||||||
|
modification, are permitted provided that the following conditions are |
||||||
|
met: |
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright |
||||||
|
notice, this list of conditions and the following disclaimer. |
||||||
|
|
||||||
|
* 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. |
||||||
|
|
||||||
|
* Neither the name of Google 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. |
@ -1 +0,0 @@ |
|||||||
libopenblas_armv8p-r0.2.19.so |
|
Binary file not shown.
@ -0,0 +1,19 @@ |
|||||||
|
Copyright (c) 2008-2015 Jesse Beder. |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in |
||||||
|
all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||||
|
THE SOFTWARE. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,87 @@ |
|||||||
|
from cereal import car |
||||||
|
from selfdrive.car.ford.fordcan import make_can_msg, create_steer_command, create_lkas_ui, \ |
||||||
|
spam_cancel_button |
||||||
|
from selfdrive.can.packer import CANPacker |
||||||
|
|
||||||
|
|
||||||
|
MAX_STEER_DELTA = 1 |
||||||
|
TOGGLE_DEBUG = False |
||||||
|
|
||||||
|
class CarController(object): |
||||||
|
def __init__(self, dbc_name, enable_camera, vehicle_model): |
||||||
|
self.packer = CANPacker(dbc_name) |
||||||
|
self.enable_camera = enable_camera |
||||||
|
self.enabled_last = False |
||||||
|
self.main_on_last = False |
||||||
|
self.vehicle_model = vehicle_model |
||||||
|
self.generic_toggle_last = 0 |
||||||
|
self.steer_alert_last = False |
||||||
|
self.lkas_action = 0 |
||||||
|
|
||||||
|
def update(self, enabled, CS, frame, actuators, visual_alert, pcm_cancel): |
||||||
|
|
||||||
|
can_sends = [] |
||||||
|
steer_alert = visual_alert == car.CarControl.HUDControl.VisualAlert.steerRequired |
||||||
|
|
||||||
|
apply_steer = actuators.steer |
||||||
|
|
||||||
|
if self.enable_camera: |
||||||
|
|
||||||
|
if pcm_cancel: |
||||||
|
#print "CANCELING!!!!" |
||||||
|
can_sends.append(spam_cancel_button(self.packer)) |
||||||
|
|
||||||
|
if (frame % 3) == 0: |
||||||
|
|
||||||
|
curvature = self.vehicle_model.calc_curvature(actuators.steerAngle*3.1415/180., CS.v_ego) |
||||||
|
|
||||||
|
# The use of the toggle below is handy for trying out the various LKAS modes |
||||||
|
if TOGGLE_DEBUG: |
||||||
|
self.lkas_action += int(CS.generic_toggle and not self.generic_toggle_last) |
||||||
|
self.lkas_action &= 0xf |
||||||
|
else: |
||||||
|
self.lkas_action = 5 # 4 and 5 seem the best. 8 and 9 seem to aggressive and laggy |
||||||
|
|
||||||
|
can_sends.append(create_steer_command(self.packer, apply_steer, enabled, |
||||||
|
CS.lkas_state, CS.angle_steers, curvature, self.lkas_action)) |
||||||
|
self.generic_toggle_last = CS.generic_toggle |
||||||
|
|
||||||
|
if (frame % 100) == 0: |
||||||
|
|
||||||
|
can_sends.append(make_can_msg(973, '\x00\x00\x00\x00\x00\x00\x00\x00', 0, False)) |
||||||
|
#can_sends.append(make_can_msg(984, '\x00\x00\x00\x00\x80\x45\x60\x30', 0, False)) |
||||||
|
|
||||||
|
if (frame % 100) == 0 or (self.enabled_last != enabled) or (self.main_on_last != CS.main_on) or \ |
||||||
|
(self.steer_alert_last != steer_alert): |
||||||
|
can_sends.append(create_lkas_ui(self.packer, CS.main_on, enabled, steer_alert)) |
||||||
|
|
||||||
|
if (frame % 200) == 0: |
||||||
|
can_sends.append(make_can_msg(1875, '\x80\xb0\x55\x55\x78\x90\x00\x00', 1, False)) |
||||||
|
|
||||||
|
if (frame % 10) == 0: |
||||||
|
|
||||||
|
can_sends.append(make_can_msg(1648, '\x00\x00\x00\x40\x00\x00\x50\x00', 1, False)) |
||||||
|
can_sends.append(make_can_msg(1649, '\x10\x10\xf1\x70\x04\x00\x00\x00', 1, False)) |
||||||
|
|
||||||
|
can_sends.append(make_can_msg(1664, '\x00\x00\x03\xe8\x00\x01\xa9\xb2', 1, False)) |
||||||
|
can_sends.append(make_can_msg(1674, '\x08\x00\x00\xff\x0c\xfb\x6a\x08', 1, False)) |
||||||
|
can_sends.append(make_can_msg(1675, '\x00\x00\x3b\x60\x37\x00\x00\x00', 1, False)) |
||||||
|
can_sends.append(make_can_msg(1690, '\x70\x00\x00\x55\x86\x1c\xe0\x00', 1, False)) |
||||||
|
|
||||||
|
can_sends.append(make_can_msg(1910, '\x06\x4b\x06\x4b\x42\xd3\x11\x30', 1, False)) |
||||||
|
can_sends.append(make_can_msg(1911, '\x48\x53\x37\x54\x48\x53\x37\x54', 1, False)) |
||||||
|
can_sends.append(make_can_msg(1912, '\x31\x34\x47\x30\x38\x31\x43\x42', 1, False)) |
||||||
|
can_sends.append(make_can_msg(1913, '\x31\x34\x47\x30\x38\x32\x43\x42', 1, False)) |
||||||
|
can_sends.append(make_can_msg(1969, '\xf4\x40\x00\x00\x00\x00\x00\x00', 1, False)) |
||||||
|
can_sends.append(make_can_msg(1971, '\x0b\xc0\x00\x00\x00\x00\x00\x00', 1, False)) |
||||||
|
|
||||||
|
static_msgs = range(1653, 1658) |
||||||
|
for addr in static_msgs: |
||||||
|
cnt = (frame % 10) + 1 |
||||||
|
can_sends.append(make_can_msg(addr, chr(cnt<<4) + '\x00\x00\x00\x00\x00\x00\x00', 1, False)) |
||||||
|
|
||||||
|
self.enabled_last = enabled |
||||||
|
self.main_on_last = CS.main_on |
||||||
|
self.steer_alert_last = steer_alert |
||||||
|
|
||||||
|
return can_sends |
@ -0,0 +1,54 @@ |
|||||||
|
from common.numpy_fast import clip |
||||||
|
from selfdrive.car.ford.values import MAX_ANGLE |
||||||
|
|
||||||
|
|
||||||
|
def make_can_msg(addr, dat, alt, cks=False): |
||||||
|
return [addr, 0, dat, alt] |
||||||
|
|
||||||
|
|
||||||
|
def create_steer_command(packer, angle_cmd, enabled, lkas_state, angle_steers, curvature, lkas_action): |
||||||
|
"""Creates a CAN message for the Ford Steer Command.""" |
||||||
|
|
||||||
|
#if enabled and lkas available: |
||||||
|
if enabled and lkas_state in [2,3]: #and (frame % 500) >= 3: |
||||||
|
action = lkas_action |
||||||
|
else: |
||||||
|
action = 0xf |
||||||
|
angle_cmd = angle_steers/MAX_ANGLE |
||||||
|
|
||||||
|
angle_cmd = clip(angle_cmd * MAX_ANGLE, - MAX_ANGLE, MAX_ANGLE) |
||||||
|
|
||||||
|
values = { |
||||||
|
"Lkas_Action": action, |
||||||
|
"Lkas_Alert": 0xf, # no alerts |
||||||
|
"Lane_Curvature": clip(curvature, -0.01, 0.01), # is it just for debug? |
||||||
|
#"Lane_Curvature": 0, # is it just for debug? |
||||||
|
"Steer_Angle_Req": angle_cmd |
||||||
|
} |
||||||
|
return packer.make_can_msg("Lane_Keep_Assist_Control", 0, values) |
||||||
|
|
||||||
|
|
||||||
|
def create_lkas_ui(packer, main_on, enabled, steer_alert): |
||||||
|
"""Creates a CAN message for the Ford Steer Ui.""" |
||||||
|
|
||||||
|
if not main_on: |
||||||
|
lines = 0xf |
||||||
|
elif enabled: |
||||||
|
lines = 0x3 |
||||||
|
else: |
||||||
|
lines = 0x6 |
||||||
|
|
||||||
|
values = { |
||||||
|
"Set_Me_X80": 0x80, |
||||||
|
"Set_Me_X45": 0x45, |
||||||
|
"Set_Me_X30": 0x30, |
||||||
|
"Lines_Hud": lines, |
||||||
|
"Hands_Warning_W_Chime": steer_alert, |
||||||
|
} |
||||||
|
return packer.make_can_msg("Lane_Keep_Assist_Ui", 0, values) |
||||||
|
|
||||||
|
def spam_cancel_button(packer): |
||||||
|
values = { |
||||||
|
"Cancel": 1 |
||||||
|
} |
||||||
|
return packer.make_can_msg("Steering_Buttons", 0, values) |
@ -1 +1 @@ |
|||||||
#define COMMA_VERSION "0.6.3-release" |
#define COMMA_VERSION "0.6.4-release" |
||||||
|
@ -0,0 +1,17 @@ |
|||||||
|
_RHD_REGION_MAP = [ ['AUS', -54.76, -9.23, 112.91, 159.11], \ |
||||||
|
['IN1', 6.75, 28.10, 68.17, 97.4], \ |
||||||
|
['IN2', 28.09, 35.99, 72.18, 80.87], \ |
||||||
|
['IRL', 51.42, 55.38, -10.58, -5.99], \ |
||||||
|
['JP1', 32.66, 45.52, 137.27, 146.02], \ |
||||||
|
['JP2', 32.79, 37.60, 131.41, 137.28], \ |
||||||
|
['JP3', 24.04, 34.78, 122.93, 131.42], \ |
||||||
|
['NZ', -52.61, -29.24, 166, 178.84], \ |
||||||
|
['SF', -35.14, -22.13, 16.07, 33.21], \ |
||||||
|
['UK', 49.9, 60.84, -8.62, 1.77] ] |
||||||
|
|
||||||
|
def is_rhd_region(latitude, longitude): |
||||||
|
for region in _RHD_REGION_MAP: |
||||||
|
if region[1] <= latitude <= region[2] and \ |
||||||
|
region[3] <= longitude <= region[4]: |
||||||
|
return True |
||||||
|
return False |
@ -1,62 +0,0 @@ |
|||||||
import numpy as np |
|
||||||
import math |
|
||||||
from common.numpy_fast import interp |
|
||||||
|
|
||||||
_K_CURV_V = [1., 0.6] |
|
||||||
_K_CURV_BP = [0., 0.002] |
|
||||||
|
|
||||||
# lane width http://safety.fhwa.dot.gov/geometric/pubs/mitigationstrategies/chapter3/3_lanewidth.cfm |
|
||||||
_LANE_WIDTH_V = [3., 3.8] |
|
||||||
|
|
||||||
# break points of speed |
|
||||||
_LANE_WIDTH_BP = [0., 31.] |
|
||||||
|
|
||||||
|
|
||||||
def calc_d_lookahead(v_ego, d_poly): |
|
||||||
# this function computes how far too look for lateral control |
|
||||||
# howfar we look ahead is function of speed and how much curvy is the path |
|
||||||
offset_lookahead = 1. |
|
||||||
k_lookahead = 7. |
|
||||||
# integrate abs value of second derivative of poly to get a measure of path curvature |
|
||||||
pts_len = 50. # m |
|
||||||
if len(d_poly) > 0: |
|
||||||
pts = np.polyval([6 * d_poly[0], 2 * d_poly[1]], np.arange(0, pts_len)) |
|
||||||
else: |
|
||||||
pts = 0. |
|
||||||
curv = np.sum(np.abs(pts)) / pts_len |
|
||||||
|
|
||||||
k_curv = interp(curv, _K_CURV_BP, _K_CURV_V) |
|
||||||
|
|
||||||
# sqrt on speed is needed to keep, for a given curvature, the y_des |
|
||||||
# proportional to speed. Indeed, y_des is prop to d_lookahead^2 |
|
||||||
# 36m at 25m/s |
|
||||||
d_lookahead = offset_lookahead + math.sqrt(max(v_ego, 0)) * k_lookahead * k_curv |
|
||||||
return d_lookahead |
|
||||||
|
|
||||||
|
|
||||||
def calc_lookahead_offset(v_ego, angle_steers, d_lookahead, VM, angle_offset): |
|
||||||
# this function returns the lateral offset given the steering angle, speed and the lookahead distance |
|
||||||
sa = math.radians(angle_steers - angle_offset) |
|
||||||
curvature = VM.calc_curvature(sa, v_ego) |
|
||||||
# clip is to avoid arcsin NaNs due to too sharp turns |
|
||||||
y_actual = d_lookahead * np.tan(np.arcsin(np.clip(d_lookahead * curvature, -0.999, 0.999)) / 2.) |
|
||||||
return y_actual, curvature |
|
||||||
|
|
||||||
|
|
||||||
def calc_desired_steer_angle(v_ego, y_des, d_lookahead, VM, angle_offset): |
|
||||||
# inverse of the above function |
|
||||||
curvature = np.sin(np.arctan(y_des / d_lookahead) * 2.) / d_lookahead |
|
||||||
steer_des = math.degrees(VM.get_steer_from_curvature(curvature, v_ego)) + angle_offset |
|
||||||
return steer_des, curvature |
|
||||||
|
|
||||||
|
|
||||||
def compute_path_pinv(l=50): |
|
||||||
deg = 3 |
|
||||||
x = np.arange(l*1.0) |
|
||||||
X = np.vstack(tuple(x**n for n in range(deg, -1, -1))).T |
|
||||||
pinv = np.linalg.pinv(X) |
|
||||||
return pinv |
|
||||||
|
|
||||||
|
|
||||||
def model_polyfit(points, path_pinv): |
|
||||||
return np.dot(path_pinv, [float(x) for x in points]) |
|
@ -0,0 +1,193 @@ |
|||||||
|
import unittest |
||||||
|
import numpy as np |
||||||
|
from common.realtime import DT_CTRL, DT_DMON |
||||||
|
from selfdrive.controls.lib.driver_monitor import DriverStatus, MAX_TERMINAL_ALERTS, \ |
||||||
|
_AWARENESS_TIME, _AWARENESS_PRE_TIME_TILL_TERMINAL, \ |
||||||
|
_AWARENESS_PROMPT_TIME_TILL_TERMINAL, _DISTRACTED_TIME, \ |
||||||
|
_DISTRACTED_PRE_TIME_TILL_TERMINAL, _DISTRACTED_PROMPT_TIME_TILL_TERMINAL |
||||||
|
from selfdrive.controls.lib.gps_helpers import is_rhd_region |
||||||
|
|
||||||
|
_TEST_TIMESPAN = 120 # seconds |
||||||
|
_DISTRACTED_SECONDS_TO_ORANGE = _DISTRACTED_TIME - _DISTRACTED_PROMPT_TIME_TILL_TERMINAL + 1 |
||||||
|
_DISTRACTED_SECONDS_TO_RED = _DISTRACTED_TIME + 1 |
||||||
|
_INVISIBLE_SECONDS_TO_ORANGE = _AWARENESS_TIME - _AWARENESS_PROMPT_TIME_TILL_TERMINAL + 1 |
||||||
|
_INVISIBLE_SECONDS_TO_RED = _AWARENESS_TIME + 1 |
||||||
|
|
||||||
|
class fake_DM_msg(): |
||||||
|
def __init__(self, is_face_detected, is_distracted=False): |
||||||
|
self.faceOrientation = [0.,0.,0.] |
||||||
|
self.facePosition = [0.,0.] |
||||||
|
self.faceProb = 1. * is_face_detected |
||||||
|
self.leftEyeProb = 1. |
||||||
|
self.rightEyeProb = 1. |
||||||
|
self.leftBlinkProb = 1. * is_distracted |
||||||
|
self.rightBlinkProb = 1. * is_distracted |
||||||
|
|
||||||
|
|
||||||
|
# driver state from neural net, 10Hz |
||||||
|
msg_NO_FACE_DETECTED = fake_DM_msg(is_face_detected=False) |
||||||
|
msg_ATTENTIVE = fake_DM_msg(is_face_detected=True) |
||||||
|
msg_DISTRACTED = fake_DM_msg(is_face_detected=True, is_distracted=True) |
||||||
|
|
||||||
|
# driver interaction with car |
||||||
|
car_interaction_DETECTED = True |
||||||
|
car_interaction_NOT_DETECTED = False |
||||||
|
|
||||||
|
# openpilot state |
||||||
|
openpilot_ENGAGED = True |
||||||
|
openpilot_NOT_ENGAGED = False |
||||||
|
|
||||||
|
# car standstill state |
||||||
|
car_STANDSTILL = True |
||||||
|
car_NOT_STANDSTILL = False |
||||||
|
|
||||||
|
# some common state vectors |
||||||
|
always_no_face = [msg_NO_FACE_DETECTED] * int(_TEST_TIMESPAN/DT_DMON) |
||||||
|
always_attentive = [msg_ATTENTIVE] * int(_TEST_TIMESPAN/DT_DMON) |
||||||
|
always_distracted = [msg_DISTRACTED] * int(_TEST_TIMESPAN/DT_DMON) |
||||||
|
always_true = [True] * int(_TEST_TIMESPAN/DT_DMON) |
||||||
|
always_false = [False] * int(_TEST_TIMESPAN/DT_DMON) |
||||||
|
|
||||||
|
def run_DState_seq(driver_state_msgs, driver_car_interaction, openpilot_status, car_standstill_status): |
||||||
|
# inputs are all 10Hz |
||||||
|
DS = DriverStatus() |
||||||
|
events_from_DM = [] |
||||||
|
for idx in range(len(driver_state_msgs)): |
||||||
|
DS.get_pose(driver_state_msgs[idx], [0,0,0], 0, openpilot_status[idx]) |
||||||
|
# cal_rpy and car_speed don't matter here |
||||||
|
|
||||||
|
# to match frequency of controlsd (100Hz) |
||||||
|
for _ in range(int(DT_DMON/DT_CTRL)): |
||||||
|
event_per_state = DS.update([], driver_car_interaction[idx], openpilot_status[idx], car_standstill_status[idx]) |
||||||
|
events_from_DM.append(event_per_state) # evaluate events at 10Hz for tests |
||||||
|
|
||||||
|
assert len(events_from_DM)==len(driver_state_msgs), 'somethings wrong' |
||||||
|
return events_from_DM |
||||||
|
|
||||||
|
class TestMonitoring(unittest.TestCase): |
||||||
|
# -1. rhd parser sanity check |
||||||
|
def test_rhd_parser(self): |
||||||
|
cities = [[32.7, -117.1, 0],\ |
||||||
|
[51.5, 0.129, 1],\ |
||||||
|
[35.7, 139.7, 1],\ |
||||||
|
[-37.8, 144.9, 1],\ |
||||||
|
[32.1, 41.74, 0],\ |
||||||
|
[55.7, 12.69, 0]] |
||||||
|
result = [] |
||||||
|
for city in cities: |
||||||
|
result.append(int(is_rhd_region(city[0],city[1]))) |
||||||
|
self.assertEqual(result,[int(city[2]) for city in cities]) |
||||||
|
|
||||||
|
# 0. op engaged, driver is doing fine all the time |
||||||
|
def test_fully_aware_driver(self): |
||||||
|
events_output = run_DState_seq(always_attentive, always_false, always_true, always_false) |
||||||
|
self.assertTrue(np.sum([len(event) for event in events_output])==0) |
||||||
|
|
||||||
|
# 1. op engaged, driver is distracted and does nothing |
||||||
|
def test_fully_distracted_driver(self): |
||||||
|
events_output = run_DState_seq(always_distracted, always_false, always_true, always_false) |
||||||
|
self.assertTrue(len(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL)/2/DT_DMON)])==0) |
||||||
|
self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL+\ |
||||||
|
((_DISTRACTED_PRE_TIME_TILL_TERMINAL-_DISTRACTED_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)][0].name, 'preDriverDistracted') |
||||||
|
self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PROMPT_TIME_TILL_TERMINAL+\ |
||||||
|
((_DISTRACTED_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)][0].name, 'promptDriverDistracted') |
||||||
|
self.assertEqual(events_output[int((_DISTRACTED_TIME+\ |
||||||
|
((_TEST_TIMESPAN-10-_DISTRACTED_TIME)/2))/DT_DMON)][0].name, 'driverDistracted') |
||||||
|
|
||||||
|
# 2. op engaged, no face detected the whole time, no action |
||||||
|
def test_fully_invisible_driver(self): |
||||||
|
events_output = run_DState_seq(always_no_face, always_false, always_true, always_false) |
||||||
|
self.assertTrue(len(events_output[int((_AWARENESS_TIME-_AWARENESS_PRE_TIME_TILL_TERMINAL)/2/DT_DMON)])==0) |
||||||
|
self.assertEqual(events_output[int((_AWARENESS_TIME-_AWARENESS_PRE_TIME_TILL_TERMINAL+\ |
||||||
|
((_AWARENESS_PRE_TIME_TILL_TERMINAL-_AWARENESS_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)][0].name, 'preDriverUnresponsive') |
||||||
|
self.assertEqual(events_output[int((_AWARENESS_TIME-_AWARENESS_PROMPT_TIME_TILL_TERMINAL+\ |
||||||
|
((_AWARENESS_PROMPT_TIME_TILL_TERMINAL)/2))/DT_DMON)][0].name, 'promptDriverUnresponsive') |
||||||
|
self.assertEqual(events_output[int((_AWARENESS_TIME+\ |
||||||
|
((_TEST_TIMESPAN-10-_AWARENESS_TIME)/2))/DT_DMON)][0].name, 'driverUnresponsive') |
||||||
|
|
||||||
|
# 3. op engaged, down to orange, driver pays attention, back to normal; then down to orange, driver touches wheel |
||||||
|
# - should have short orange recovery time and no green afterwards; should recover rightaway on wheel touch |
||||||
|
def test_normal_driver(self): |
||||||
|
ds_vector = [msg_DISTRACTED] * int(_DISTRACTED_SECONDS_TO_ORANGE/DT_DMON) + \ |
||||||
|
[msg_ATTENTIVE] * int(_DISTRACTED_SECONDS_TO_ORANGE/DT_DMON) + \ |
||||||
|
[msg_DISTRACTED] * (int(_TEST_TIMESPAN/DT_DMON)-int(_DISTRACTED_SECONDS_TO_ORANGE*2/DT_DMON)) |
||||||
|
interaction_vector = [car_interaction_NOT_DETECTED] * int(_DISTRACTED_SECONDS_TO_ORANGE*3/DT_DMON) + \ |
||||||
|
[car_interaction_DETECTED] * (int(_TEST_TIMESPAN/DT_DMON)-int(_DISTRACTED_SECONDS_TO_ORANGE*3/DT_DMON)) |
||||||
|
events_output = run_DState_seq(ds_vector, interaction_vector, always_true, always_false) |
||||||
|
self.assertTrue(len(events_output[int(_DISTRACTED_SECONDS_TO_ORANGE*0.5/DT_DMON)])==0) |
||||||
|
self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_ORANGE-0.1)/DT_DMON)][0].name, 'promptDriverDistracted') |
||||||
|
self.assertTrue(len(events_output[int(_DISTRACTED_SECONDS_TO_ORANGE*1.5/DT_DMON)])==0) |
||||||
|
self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_ORANGE*3-0.1)/DT_DMON)][0].name, 'promptDriverDistracted') |
||||||
|
self.assertTrue(len(events_output[int((_DISTRACTED_SECONDS_TO_ORANGE*3+0.1)/DT_DMON)])==0) |
||||||
|
|
||||||
|
# 4. op engaged, down to orange, driver dodges camera, then comes back still distracted, down to red, \ |
||||||
|
# driver dodges, and then touches wheel to no avail, disengages and reengages |
||||||
|
# - orange/red alert should remain after disappearance, and only disengaging clears red |
||||||
|
def test_biggest_comma_fan(self): |
||||||
|
_invisible_time = 2 # seconds |
||||||
|
ds_vector = always_distracted[:] |
||||||
|
interaction_vector = always_false[:] |
||||||
|
op_vector = always_true[:] |
||||||
|
ds_vector[int(_DISTRACTED_SECONDS_TO_ORANGE/DT_DMON):int((_DISTRACTED_SECONDS_TO_ORANGE+_invisible_time)/DT_DMON)] = [msg_NO_FACE_DETECTED] * int(_invisible_time/DT_DMON) |
||||||
|
ds_vector[int((_DISTRACTED_SECONDS_TO_RED+_invisible_time)/DT_DMON):int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time)/DT_DMON)] = [msg_NO_FACE_DETECTED] * int(_invisible_time/DT_DMON) |
||||||
|
interaction_vector[int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+0.5)/DT_DMON):int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+1.5)/DT_DMON)] = [True] * int(1/DT_DMON) |
||||||
|
op_vector[int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+2.5)/DT_DMON):int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+3)/DT_DMON)] = [False] * int(0.5/DT_DMON) |
||||||
|
events_output = run_DState_seq(ds_vector, interaction_vector, op_vector, always_false) |
||||||
|
self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_ORANGE+0.5*_invisible_time)/DT_DMON)][0].name, 'promptDriverDistracted') |
||||||
|
self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_RED+1.5*_invisible_time)/DT_DMON)][0].name, 'driverDistracted') |
||||||
|
self.assertEqual(events_output[int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+1.5)/DT_DMON)][0].name, 'driverDistracted') |
||||||
|
self.assertTrue(len(events_output[int((_DISTRACTED_SECONDS_TO_RED+2*_invisible_time+3.5)/DT_DMON)])==0) |
||||||
|
|
||||||
|
# 5. op engaged, invisible driver, down to orange, driver appears; then down to orange again, driver touches wheel |
||||||
|
# - both actions should clear the alert |
||||||
|
def test_sometimes_transparent_commuter(self): |
||||||
|
_visible_time = 2 # seconds |
||||||
|
ds_vector = always_no_face[:]*2 |
||||||
|
interaction_vector = always_false[:]*2 |
||||||
|
ds_vector[int(_INVISIBLE_SECONDS_TO_ORANGE/DT_DMON):int((_INVISIBLE_SECONDS_TO_ORANGE+_visible_time)/DT_DMON)] = [msg_ATTENTIVE] * int(_visible_time/DT_DMON) |
||||||
|
interaction_vector[int((2*_INVISIBLE_SECONDS_TO_ORANGE+_visible_time)/DT_DMON):int((2*_INVISIBLE_SECONDS_TO_ORANGE+_visible_time+1)/DT_DMON)] = [True] * int(1/DT_DMON) |
||||||
|
events_output = run_DState_seq(ds_vector, interaction_vector, 2*always_true, 2*always_false) |
||||||
|
self.assertTrue(len(events_output[int(_INVISIBLE_SECONDS_TO_ORANGE*0.5/DT_DMON)])==0) |
||||||
|
self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE-0.1)/DT_DMON)][0].name, 'promptDriverUnresponsive') |
||||||
|
self.assertTrue(len(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE*1.5+_visible_time)/DT_DMON)])==0) |
||||||
|
self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE*2+_visible_time-0.5)/DT_DMON)][0].name, 'promptDriverUnresponsive') |
||||||
|
self.assertTrue(len(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE*2+_visible_time+0.1)/DT_DMON)])==0) |
||||||
|
|
||||||
|
# 6. op engaged, invisible driver, down to red, driver appears and then touches wheel, then disengages/reengages |
||||||
|
# - only disengage will clear the alert |
||||||
|
def test_last_second_responder(self): |
||||||
|
_visible_time = 2 # seconds |
||||||
|
ds_vector = always_no_face[:] |
||||||
|
interaction_vector = always_false[:] |
||||||
|
op_vector = always_true[:] |
||||||
|
ds_vector[int(_INVISIBLE_SECONDS_TO_RED/DT_DMON):int((_INVISIBLE_SECONDS_TO_RED+_visible_time)/DT_DMON)] = [msg_ATTENTIVE] * int(_visible_time/DT_DMON) |
||||||
|
interaction_vector[int((_INVISIBLE_SECONDS_TO_RED+_visible_time)/DT_DMON):int((_INVISIBLE_SECONDS_TO_RED+_visible_time+1)/DT_DMON)] = [True] * int(1/DT_DMON) |
||||||
|
op_vector[int((_INVISIBLE_SECONDS_TO_RED+_visible_time+1)/DT_DMON):int((_INVISIBLE_SECONDS_TO_RED+_visible_time+0.5)/DT_DMON)] = [False] * int(0.5/DT_DMON) |
||||||
|
events_output = run_DState_seq(ds_vector, interaction_vector, op_vector, always_false) |
||||||
|
self.assertTrue(len(events_output[int(_INVISIBLE_SECONDS_TO_ORANGE*0.5/DT_DMON)])==0) |
||||||
|
self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_ORANGE-0.1)/DT_DMON)][0].name, 'promptDriverUnresponsive') |
||||||
|
self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_RED-0.1)/DT_DMON)][0].name, 'driverUnresponsive') |
||||||
|
self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_RED+0.5*_visible_time)/DT_DMON)][0].name, 'driverUnresponsive') |
||||||
|
self.assertEqual(events_output[int((_INVISIBLE_SECONDS_TO_RED+_visible_time+0.5)/DT_DMON)][0].name, 'driverUnresponsive') |
||||||
|
self.assertTrue(len(events_output[int((_INVISIBLE_SECONDS_TO_RED+_visible_time+1+0.1)/DT_DMON)])==0) |
||||||
|
|
||||||
|
# 7. op not engaged, always distracted driver |
||||||
|
# - dm should stay quiet when not engaged |
||||||
|
def test_pure_dashcam_user(self): |
||||||
|
events_output = run_DState_seq(always_distracted, always_false, always_false, always_false) |
||||||
|
self.assertTrue(np.sum([len(event) for event in events_output])==0) |
||||||
|
|
||||||
|
# 8. op engaged, car stops at traffic light, down to orange, no action, then car starts moving |
||||||
|
# - should only reach green when stopped, but continues counting down on launch |
||||||
|
def test_long_traffic_light_victim(self): |
||||||
|
_redlight_time = 60 # seconds |
||||||
|
standstill_vector = always_true[:] |
||||||
|
standstill_vector[int(_redlight_time/DT_DMON):] = [False] * int((_TEST_TIMESPAN-_redlight_time)/DT_DMON) |
||||||
|
events_output = run_DState_seq(always_distracted, always_false, always_true, standstill_vector) |
||||||
|
self.assertEqual(events_output[int((_DISTRACTED_TIME-_DISTRACTED_PRE_TIME_TILL_TERMINAL+1)/DT_DMON)][0].name, 'preDriverDistracted') |
||||||
|
self.assertEqual(events_output[int((_redlight_time-0.1)/DT_DMON)][0].name, 'preDriverDistracted') |
||||||
|
self.assertEqual(events_output[int((_redlight_time+0.5)/DT_DMON)][0].name, 'promptDriverDistracted') |
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
print 'MAX_TERMINAL_ALERTS', MAX_TERMINAL_ALERTS |
||||||
|
unittest.main() |
@ -1 +1 @@ |
|||||||
e3388c62ffb80f4b3ca8721da56a581a93c44e79 |
8a11bcbc9833e154e10b59a8babb2b4545372f56 |
@ -0,0 +1,74 @@ |
|||||||
|
CC = clang
|
||||||
|
CXX = clang++
|
||||||
|
|
||||||
|
PHONELIBS = ../../../phonelibs
|
||||||
|
|
||||||
|
WARN_FLAGS = -Werror=implicit-function-declaration \
|
||||||
|
-Werror=incompatible-pointer-types \
|
||||||
|
-Werror=int-conversion \
|
||||||
|
-Werror=return-type \
|
||||||
|
-Werror=format-extra-args
|
||||||
|
|
||||||
|
CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS)
|
||||||
|
CXXFLAGS = -std=c++11 -fPIC -O2 $(WARN_FLAGS)
|
||||||
|
|
||||||
|
NANOVG_FLAGS = -I$(PHONELIBS)/nanovg
|
||||||
|
|
||||||
|
OPENGL_LIBS = -lGLESv3
|
||||||
|
|
||||||
|
FRAMEBUFFER_LIBS = -lutils -lgui -lEGL
|
||||||
|
|
||||||
|
OBJS = spinner.o \
|
||||||
|
../../common/framebuffer.o \
|
||||||
|
$(PHONELIBS)/nanovg/nanovg.o \
|
||||||
|
../../common/spinner.o \
|
||||||
|
opensans_semibold.o \
|
||||||
|
img_spinner_track.o \
|
||||||
|
img_spinner_comma.o
|
||||||
|
|
||||||
|
DEPS := $(OBJS:.o=.d)
|
||||||
|
|
||||||
|
.PHONY: all |
||||||
|
all: spinner |
||||||
|
|
||||||
|
spinner: $(OBJS) |
||||||
|
@echo "[ LINK ] $@"
|
||||||
|
$(CXX) -fPIC -o '$@' $^ \
|
||||||
|
-s \
|
||||||
|
$(FRAMEBUFFER_LIBS) \
|
||||||
|
-L/system/vendor/lib64 \
|
||||||
|
$(OPENGL_LIBS) \
|
||||||
|
-lm -llog
|
||||||
|
|
||||||
|
../../common/framebuffer.o: ../../common/framebuffer.cc |
||||||
|
@echo "[ CXX ] $@"
|
||||||
|
$(CXX) $(CXXFLAGS) -MMD \
|
||||||
|
-I$(PHONELIBS)/android_frameworks_native/include \
|
||||||
|
-I$(PHONELIBS)/android_system_core/include \
|
||||||
|
-I$(PHONELIBS)/android_hardware_libhardware/include \
|
||||||
|
-c -o '$@' '$<'
|
||||||
|
|
||||||
|
opensans_semibold.o: ../../assets/fonts/opensans_semibold.ttf |
||||||
|
@echo "[ bin2o ] $@"
|
||||||
|
cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)'
|
||||||
|
|
||||||
|
img_spinner_track.o: ../../assets/img_spinner_track.png |
||||||
|
@echo "[ bin2o ] $@"
|
||||||
|
cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)'
|
||||||
|
|
||||||
|
img_spinner_comma.o: ../../assets/img_spinner_comma.png |
||||||
|
@echo "[ bin2o ] $@"
|
||||||
|
cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)'
|
||||||
|
|
||||||
|
%.o: %.c |
||||||
|
@echo "[ CC ] $@"
|
||||||
|
$(CC) $(CFLAGS) -MMD \
|
||||||
|
-I../.. \
|
||||||
|
$(NANOVG_FLAGS) \
|
||||||
|
-c -o '$@' '$<'
|
||||||
|
|
||||||
|
.PHONY: clean |
||||||
|
clean: |
||||||
|
rm -f spinner $(OBJS) $(DEPS)
|
||||||
|
|
||||||
|
-include $(DEPS) |
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue