forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add time gap and distance cost parameters to Longitudinal MPC (#23)
* Update longitudinal mpc with follow distance param Update generator.cpp to parameterize the follow time. Then, using the process outlined in the ACADO docs (https://acado.github.io/cgt_overview.html), rebuild the generator binary and run it to regenerate the source files in lib_mpc_export, then manually copy them into the openpilot repo. Update longitudinal_mpc.c, libmpc_py.py, and planner.py to take in the additional follow_time parameter. Incorporate arne182's PR to update the Makefile (commaai#248). Note that I did not use the generate recipie inside the repo; I created the files outside of the repo as stated above. * Add distance cost parameter to longitudinal mpc The distance cost was hardcoded, allow with the time gap. But as we lower the time gap we will need to increase the distance cost for reliable control * Scale the time gap up as we slow down
- Loading branch information
1 parent
0eaf034
commit b24f909
Showing
37 changed files
with
5,528 additions
and
56 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
/* | ||
* Copyright 2011 The LibYuv Project Authors. All rights reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. An additional intellectual property rights grant can be found | ||
* in the file PATENTS. All contributing project authors may | ||
* be found in the AUTHORS file in the root of the source tree. | ||
*/ | ||
|
||
#ifndef INCLUDE_LIBYUV_H_ | ||
#define INCLUDE_LIBYUV_H_ | ||
|
||
#include "libyuv/basic_types.h" | ||
#include "libyuv/compare.h" | ||
#include "libyuv/convert.h" | ||
#include "libyuv/convert_argb.h" | ||
#include "libyuv/convert_from.h" | ||
#include "libyuv/convert_from_argb.h" | ||
#include "libyuv/cpu_id.h" | ||
#include "libyuv/mjpeg_decoder.h" | ||
#include "libyuv/planar_functions.h" | ||
#include "libyuv/rotate.h" | ||
#include "libyuv/rotate_argb.h" | ||
#include "libyuv/row.h" | ||
#include "libyuv/scale.h" | ||
#include "libyuv/scale_argb.h" | ||
#include "libyuv/scale_row.h" | ||
#include "libyuv/version.h" | ||
#include "libyuv/video_common.h" | ||
|
||
#endif // INCLUDE_LIBYUV_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,118 @@ | ||
/* | ||
* Copyright 2011 The LibYuv Project Authors. All rights reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. An additional intellectual property rights grant can be found | ||
* in the file PATENTS. All contributing project authors may | ||
* be found in the AUTHORS file in the root of the source tree. | ||
*/ | ||
|
||
#ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ | ||
#define INCLUDE_LIBYUV_BASIC_TYPES_H_ | ||
|
||
#include <stddef.h> // for NULL, size_t | ||
|
||
#if defined(_MSC_VER) && (_MSC_VER < 1600) | ||
#include <sys/types.h> // for uintptr_t on x86 | ||
#else | ||
#include <stdint.h> // for uintptr_t | ||
#endif | ||
|
||
#ifndef GG_LONGLONG | ||
#ifndef INT_TYPES_DEFINED | ||
#define INT_TYPES_DEFINED | ||
#ifdef COMPILER_MSVC | ||
typedef unsigned __int64 uint64; | ||
typedef __int64 int64; | ||
#ifndef INT64_C | ||
#define INT64_C(x) x ## I64 | ||
#endif | ||
#ifndef UINT64_C | ||
#define UINT64_C(x) x ## UI64 | ||
#endif | ||
#define INT64_F "I64" | ||
#else // COMPILER_MSVC | ||
#if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) | ||
typedef unsigned long uint64; // NOLINT | ||
typedef long int64; // NOLINT | ||
#ifndef INT64_C | ||
#define INT64_C(x) x ## L | ||
#endif | ||
#ifndef UINT64_C | ||
#define UINT64_C(x) x ## UL | ||
#endif | ||
#define INT64_F "l" | ||
#else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) | ||
typedef unsigned long long uint64; // NOLINT | ||
typedef long long int64; // NOLINT | ||
#ifndef INT64_C | ||
#define INT64_C(x) x ## LL | ||
#endif | ||
#ifndef UINT64_C | ||
#define UINT64_C(x) x ## ULL | ||
#endif | ||
#define INT64_F "ll" | ||
#endif // __LP64__ | ||
#endif // COMPILER_MSVC | ||
typedef unsigned int uint32; | ||
typedef int int32; | ||
typedef unsigned short uint16; // NOLINT | ||
typedef short int16; // NOLINT | ||
typedef unsigned char uint8; | ||
typedef signed char int8; | ||
#endif // INT_TYPES_DEFINED | ||
#endif // GG_LONGLONG | ||
|
||
// Detect compiler is for x86 or x64. | ||
#if defined(__x86_64__) || defined(_M_X64) || \ | ||
defined(__i386__) || defined(_M_IX86) | ||
#define CPU_X86 1 | ||
#endif | ||
// Detect compiler is for ARM. | ||
#if defined(__arm__) || defined(_M_ARM) | ||
#define CPU_ARM 1 | ||
#endif | ||
|
||
#ifndef ALIGNP | ||
#ifdef __cplusplus | ||
#define ALIGNP(p, t) \ | ||
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \ | ||
((t) - 1)) & ~((t) - 1)))) | ||
#else | ||
#define ALIGNP(p, t) \ | ||
((uint8*)((((uintptr_t)(p) + ((t) - 1)) & ~((t) - 1)))) /* NOLINT */ | ||
#endif | ||
#endif | ||
|
||
#if !defined(LIBYUV_API) | ||
#if defined(_WIN32) || defined(__CYGWIN__) | ||
#if defined(LIBYUV_BUILDING_SHARED_LIBRARY) | ||
#define LIBYUV_API __declspec(dllexport) | ||
#elif defined(LIBYUV_USING_SHARED_LIBRARY) | ||
#define LIBYUV_API __declspec(dllimport) | ||
#else | ||
#define LIBYUV_API | ||
#endif // LIBYUV_BUILDING_SHARED_LIBRARY | ||
#elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ | ||
(defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ | ||
defined(LIBYUV_USING_SHARED_LIBRARY)) | ||
#define LIBYUV_API __attribute__ ((visibility ("default"))) | ||
#else | ||
#define LIBYUV_API | ||
#endif // __GNUC__ | ||
#endif // LIBYUV_API | ||
|
||
#define LIBYUV_BOOL int | ||
#define LIBYUV_FALSE 0 | ||
#define LIBYUV_TRUE 1 | ||
|
||
// Visual C x86 or GCC little endian. | ||
#if defined(__x86_64__) || defined(_M_X64) || \ | ||
defined(__i386__) || defined(_M_IX86) || \ | ||
defined(__arm__) || defined(_M_ARM) || \ | ||
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) | ||
#define LIBYUV_LITTLE_ENDIAN | ||
#endif | ||
|
||
#endif // INCLUDE_LIBYUV_BASIC_TYPES_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,78 @@ | ||
/* | ||
* Copyright 2011 The LibYuv Project Authors. All rights reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. An additional intellectual property rights grant can be found | ||
* in the file PATENTS. All contributing project authors may | ||
* be found in the AUTHORS file in the root of the source tree. | ||
*/ | ||
|
||
#ifndef INCLUDE_LIBYUV_COMPARE_H_ | ||
#define INCLUDE_LIBYUV_COMPARE_H_ | ||
|
||
#include "libyuv/basic_types.h" | ||
|
||
#ifdef __cplusplus | ||
namespace libyuv { | ||
extern "C" { | ||
#endif | ||
|
||
// Compute a hash for specified memory. Seed of 5381 recommended. | ||
LIBYUV_API | ||
uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed); | ||
|
||
// Scan an opaque argb image and return fourcc based on alpha offset. | ||
// Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown. | ||
LIBYUV_API | ||
uint32 ARGBDetect(const uint8* argb, int stride_argb, int width, int height); | ||
|
||
// Sum Square Error - used to compute Mean Square Error or PSNR. | ||
LIBYUV_API | ||
uint64 ComputeSumSquareError(const uint8* src_a, | ||
const uint8* src_b, int count); | ||
|
||
LIBYUV_API | ||
uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a, | ||
const uint8* src_b, int stride_b, | ||
int width, int height); | ||
|
||
static const int kMaxPsnr = 128; | ||
|
||
LIBYUV_API | ||
double SumSquareErrorToPsnr(uint64 sse, uint64 count); | ||
|
||
LIBYUV_API | ||
double CalcFramePsnr(const uint8* src_a, int stride_a, | ||
const uint8* src_b, int stride_b, | ||
int width, int height); | ||
|
||
LIBYUV_API | ||
double I420Psnr(const uint8* src_y_a, int stride_y_a, | ||
const uint8* src_u_a, int stride_u_a, | ||
const uint8* src_v_a, int stride_v_a, | ||
const uint8* src_y_b, int stride_y_b, | ||
const uint8* src_u_b, int stride_u_b, | ||
const uint8* src_v_b, int stride_v_b, | ||
int width, int height); | ||
|
||
LIBYUV_API | ||
double CalcFrameSsim(const uint8* src_a, int stride_a, | ||
const uint8* src_b, int stride_b, | ||
int width, int height); | ||
|
||
LIBYUV_API | ||
double I420Ssim(const uint8* src_y_a, int stride_y_a, | ||
const uint8* src_u_a, int stride_u_a, | ||
const uint8* src_v_a, int stride_v_a, | ||
const uint8* src_y_b, int stride_y_b, | ||
const uint8* src_u_b, int stride_u_b, | ||
const uint8* src_v_b, int stride_v_b, | ||
int width, int height); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
} // namespace libyuv | ||
#endif | ||
|
||
#endif // INCLUDE_LIBYUV_COMPARE_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,84 @@ | ||
/* | ||
* Copyright 2013 The LibYuv Project Authors. All rights reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. An additional intellectual property rights grant can be found | ||
* in the file PATENTS. All contributing project authors may | ||
* be found in the AUTHORS file in the root of the source tree. | ||
*/ | ||
|
||
#ifndef INCLUDE_LIBYUV_COMPARE_ROW_H_ | ||
#define INCLUDE_LIBYUV_COMPARE_ROW_H_ | ||
|
||
#include "libyuv/basic_types.h" | ||
|
||
#ifdef __cplusplus | ||
namespace libyuv { | ||
extern "C" { | ||
#endif | ||
|
||
#if defined(__pnacl__) || defined(__CLR_VER) || \ | ||
(defined(__i386__) && !defined(__SSE2__)) | ||
#define LIBYUV_DISABLE_X86 | ||
#endif | ||
// MemorySanitizer does not support assembly code yet. http://crbug.com/344505 | ||
#if defined(__has_feature) | ||
#if __has_feature(memory_sanitizer) | ||
#define LIBYUV_DISABLE_X86 | ||
#endif | ||
#endif | ||
|
||
// Visual C 2012 required for AVX2. | ||
#if defined(_M_IX86) && !defined(__clang__) && \ | ||
defined(_MSC_VER) && _MSC_VER >= 1700 | ||
#define VISUALC_HAS_AVX2 1 | ||
#endif // VisualStudio >= 2012 | ||
|
||
// clang >= 3.4.0 required for AVX2. | ||
#if defined(__clang__) && (defined(__x86_64__) || defined(__i386__)) | ||
#if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4)) | ||
#define CLANG_HAS_AVX2 1 | ||
#endif // clang >= 3.4 | ||
#endif // __clang__ | ||
|
||
#if !defined(LIBYUV_DISABLE_X86) && \ | ||
defined(_M_IX86) && (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2)) | ||
#define HAS_HASHDJB2_AVX2 | ||
#endif | ||
|
||
// The following are available for Visual C and GCC: | ||
#if !defined(LIBYUV_DISABLE_X86) && \ | ||
(defined(__x86_64__) || (defined(__i386__) || defined(_M_IX86))) | ||
#define HAS_HASHDJB2_SSE41 | ||
#define HAS_SUMSQUAREERROR_SSE2 | ||
#endif | ||
|
||
// The following are available for Visual C and clangcl 32 bit: | ||
#if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \ | ||
(defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2)) | ||
#define HAS_HASHDJB2_AVX2 | ||
#define HAS_SUMSQUAREERROR_AVX2 | ||
#endif | ||
|
||
// The following are available for Neon: | ||
#if !defined(LIBYUV_DISABLE_NEON) && \ | ||
(defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__)) | ||
#define HAS_SUMSQUAREERROR_NEON | ||
#endif | ||
|
||
uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count); | ||
uint32 SumSquareError_SSE2(const uint8* src_a, const uint8* src_b, int count); | ||
uint32 SumSquareError_AVX2(const uint8* src_a, const uint8* src_b, int count); | ||
uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count); | ||
|
||
uint32 HashDjb2_C(const uint8* src, int count, uint32 seed); | ||
uint32 HashDjb2_SSE41(const uint8* src, int count, uint32 seed); | ||
uint32 HashDjb2_AVX2(const uint8* src, int count, uint32 seed); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
} // namespace libyuv | ||
#endif | ||
|
||
#endif // INCLUDE_LIBYUV_COMPARE_ROW_H_ |
Oops, something went wrong.