code stringlengths 1 1.05M | repo_name stringlengths 6 83 | path stringlengths 3 242 | language stringclasses 222
values | license stringclasses 20
values | size int64 1 1.05M |
|---|---|---|---|---|---|
package entity;
import lombok.Data;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Data
public class AcademyEntity {
private String id;
private String academyName;
private String academyCode;
public static AcademyEntity mapToEntity(Map<String, Object> objectMap) {
... | 2301_81295389/student-java-web-backend | src/main/java/entity/AcademyEntity.java | Java | unknown | 810 |
package entity;
import lombok.Data;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Data
public class ClassEntity {
private String id;
private String specialtyId;
private String teacherId;
private String className;
private String classCode;
private String gra... | 2301_81295389/student-java-web-backend | src/main/java/entity/ClassEntity.java | Java | unknown | 1,105 |
package entity;
import lombok.Data;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Data
public class SpecialtyEntity {
private String id;
private String academyId;
private String specialtyName;
private String specialtyCode;
public static SpecialtyEntity mapToEn... | 2301_81295389/student-java-web-backend | src/main/java/entity/SpecialtyEntity.java | Java | unknown | 944 |
package entity;
import lombok.Data;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Data
public class StudentEntity {
private String id;
private String studentId;
private String academyId;
private String specialtyId;
private String classId;
private Stri... | 2301_81295389/student-java-web-backend | src/main/java/entity/StudentEntity.java | Java | unknown | 1,438 |
package entity;
import lombok.Data;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Data
public class TeacherEntity {
private String id;
private String academyId;
private String teacherName;
private Integer age;
private Integer gender;
private String phoneNum... | 2301_81295389/student-java-web-backend | src/main/java/entity/TeacherEntity.java | Java | unknown | 1,175 |
package entity;
import lombok.Data;
import java.util.Map;
@Data
public class UserEntity {
private String id;
private String username;
private String password;
public static UserEntity mapToEntity(Map<String,Object> objectMap) {
UserEntity user = new UserEntity();
user.setId((String... | 2301_81295389/student-java-web-backend | src/main/java/entity/UserEntity.java | Java | unknown | 497 |
package filter;
import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebFilter("/*")
public class CorsFilter implements Filter {
@Override
public void doFilter(Serv... | 2301_81295389/student-java-web-backend | src/main/java/filter/CorsFilter.java | Java | unknown | 1,359 |
package service;
import entity.AcademyEntity;
import java.util.List;
public interface AcademyService {
List<AcademyEntity> getAcademyInfo(String name);
int addAcademyInfo(AcademyEntity academy);
int updateAcademyInfo(AcademyEntity academy);
int deleteAcademy(String academyId);
int batchDelete... | 2301_81295389/student-java-web-backend | src/main/java/service/AcademyService.java | Java | unknown | 406 |
package service;
import entity.ClassEntity;
import entity.StudentEntity;
import dto.GetSameGradeClassDTO;
import vo.GetClassInfoVO;
import vo.GetSameGradeClassVO;
import java.util.List;
public interface ClassService {
List<GetClassInfoVO> getClassInfo(String name);
int addClassInfo(ClassEntity classEntity)... | 2301_81295389/student-java-web-backend | src/main/java/service/ClassService.java | Java | unknown | 780 |
package service;
import entity.SpecialtyEntity;
import vo.GetSpecialtyAndMaxCodeVO;
import vo.GetSpecialtyVO;
import java.util.List;
public interface SpecialtyService {
List<GetSpecialtyVO> getSpecialtyInfo(String name);
int addSpecialtyInfo(SpecialtyEntity specialty);
int updateSpecialtyInfo(Specialty... | 2301_81295389/student-java-web-backend | src/main/java/service/SpecialtyService.java | Java | unknown | 569 |
package service;
import entity.StudentEntity;
import dto.ChooseClassDTO;
import vo.GetStudentVO;
import java.util.List;
public interface StudentService {
List<GetStudentVO> getAll(String name);
void addStudent(StudentEntity student);
void deleteStudent(String id);
void updateStudent(StudentEntity... | 2301_81295389/student-java-web-backend | src/main/java/service/StudentService.java | Java | unknown | 423 |
package service;
import entity.TeacherEntity;
import vo.GetTeacherVO;
import java.util.List;
public interface TeacherService {
List<GetTeacherVO> getTeacherInfo(String name);
int addTeacherInfo(TeacherEntity teacher);
int updateTeacherInfo(TeacherEntity teacher);
int deleteTeacher(String teacherId... | 2301_81295389/student-java-web-backend | src/main/java/service/TeacherService.java | Java | unknown | 492 |
package service;
public interface UserService {
boolean getUserInfo(String userName, String password);
boolean registered(String userName, String password);
}
| 2301_81295389/student-java-web-backend | src/main/java/service/UserService.java | Java | unknown | 169 |
package service.impl;
import entity.AcademyEntity;
import dao.AcademyDao;
import dao.impl.AcademyDaoImpl;
import service.AcademyService;
import util.UUIDUtil;
import java.util.List;
import java.util.Map;
public class AcademyServiceImpl implements AcademyService {
private final AcademyDao academyDao = new Academ... | 2301_81295389/student-java-web-backend | src/main/java/service/impl/AcademyServiceImpl.java | Java | unknown | 1,270 |
package service.impl;
import entity.*;
import dao.ClassDao;
import dao.impl.ClassDaoImpl;
import dto.GetSameGradeClassDTO;
import service.*;
import util.UUIDUtil;
import vo.GetClassInfoVO;
import vo.GetSameGradeClassVO;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class Cla... | 2301_81295389/student-java-web-backend | src/main/java/service/impl/ClassServiceImpl.java | Java | unknown | 4,204 |
package service.impl;
import entity.AcademyEntity;
import entity.SpecialtyEntity;
import dao.SpecialtyDao;
import dao.impl.SpecialtyDaoImpl;
import service.AcademyService;
import service.SpecialtyService;
import util.UUIDUtil;
import vo.GetSpecialtyAndMaxCodeVO;
import vo.GetSpecialtyVO;
import java.util.List;
import... | 2301_81295389/student-java-web-backend | src/main/java/service/impl/SpecialtyServiceImpl.java | Java | unknown | 2,918 |
package service.impl;
import entity.AcademyEntity;
import entity.ClassEntity;
import entity.SpecialtyEntity;
import entity.StudentEntity;
import dao.StudentDao;
import dao.impl.StudentDaoImpl;
import dto.ChooseClassDTO;
import service.AcademyService;
import service.ClassService;
import service.SpecialtyService;
import... | 2301_81295389/student-java-web-backend | src/main/java/service/impl/StudentServiceImpl.java | Java | unknown | 3,005 |
package service.impl;
import entity.AcademyEntity;
import entity.TeacherEntity;
import dao.TeacherDao;
import dao.impl.TeacherDaoImpl;
import service.AcademyService;
import service.TeacherService;
import util.UUIDUtil;
import vo.GetTeacherVO;
import java.util.List;
import java.util.Map;
import java.util.stream.Collec... | 2301_81295389/student-java-web-backend | src/main/java/service/impl/TeacherServiceImpl.java | Java | unknown | 2,346 |
package service.impl;
import entity.UserEntity;
import dao.UserDao;
import dao.impl.UserDaoImpl;
import service.UserService;
import util.PasswordUtil;
import util.UUIDUtil;
public class UserServiceImpl implements UserService {
private final UserDao userDao = new UserDaoImpl();
@Override
public boolean get... | 2301_81295389/student-java-web-backend | src/main/java/service/impl/UserServiceImpl.java | Java | unknown | 987 |
package util;
import lombok.Data;
import java.io.Serializable;
@Data
public class BaseResult<T> implements Serializable {
private int code;
private String message;
private T data;
public BaseResult(int code, String message, T data) {
this.code = code;
this.message = message;
t... | 2301_81295389/student-java-web-backend | src/main/java/util/BaseResult.java | Java | unknown | 835 |
package util;
import java.io.InputStream;
import java.sql.*;
import java.util.*;
public class JDBCUtil {
private static final String driver;
private static final String url;
private static final String username;
private static final String password;
static {
try {
Properties ... | 2301_81295389/student-java-web-backend | src/main/java/util/JDBCUtil.java | Java | unknown | 3,865 |
package util;
import org.mindrot.jbcrypt.BCrypt;
public class PasswordUtil {
public static String hashPassword(String plainPassword) {
return BCrypt.hashpw(plainPassword, BCrypt.gensalt());
}
public static boolean checkPassword(String plainPassword, String hashedPassword) {
return BCrypt.c... | 2301_81295389/student-java-web-backend | src/main/java/util/PasswordUtil.java | Java | unknown | 366 |
package util;
import java.util.UUID;
public class UUIDUtil {
private UUIDUtil(){}
public static String getUUID() {
return UUID.randomUUID().toString().replace("-", "");
}
}
| 2301_81295389/student-java-web-backend | src/main/java/util/UUIDUtil.java | Java | unknown | 197 |
package vo;
import lombok.Data;
@Data
public class GetClassInfoVO {
private String classId;
private String academyName;
private String specialtyName;
private String teacherName;
private String className;
private String classCode;
private Integer studentNum;
private String grade;
}
| 2301_81295389/student-java-web-backend | src/main/java/vo/GetClassInfoVO.java | Java | unknown | 316 |
package vo;
import lombok.Data;
@Data
public class GetSameGradeClassVO {
private String className;
private String classId;
}
| 2301_81295389/student-java-web-backend | src/main/java/vo/GetSameGradeClassVO.java | Java | unknown | 135 |
package vo;
import lombok.Data;
@Data
public class GetSpecialtyAndMaxCodeVO {
private String id;
private String academyId;
private String specialtyName;
private String specialtyCode;
private String maxClassCode;
}
| 2301_81295389/student-java-web-backend | src/main/java/vo/GetSpecialtyAndMaxCodeVO.java | Java | unknown | 236 |
package vo;
import lombok.Data;
@Data
public class GetSpecialtyVO {
private String id;
private String academyId;
private String academyName;
private String academyCode;
private String specialtyName;
private String specialtyCode;
}
| 2301_81295389/student-java-web-backend | src/main/java/vo/GetSpecialtyVO.java | Java | unknown | 257 |
package vo;
import lombok.Data;
@Data
public class GetStudentVO {
private String id;
private String studentId;
private String academyId;
private String academyName;
private String specialtyId;
private String specialtyName;
private String classId;
private String className;
p... | 2301_81295389/student-java-web-backend | src/main/java/vo/GetStudentVO.java | Java | unknown | 452 |
package vo;
import lombok.Data;
@Data
public class GetTeacherVO {
private String teacherId;
private String academyName;
private String academyId;
private String teacherName;
private Integer age;
private Integer gender;
private String phoneNumber;
private String degree;//学历
}
| 2301_81295389/student-java-web-backend | src/main/java/vo/GetTeacherVO.java | Java | unknown | 314 |
FROM ghcr.io/commaai/openpilot-base:latest
RUN apt update && apt install -y vim net-tools usbutils htop ripgrep tmux wget mesa-utils xvfb libxtst6 libxv1 libglu1-mesa libegl1-mesa gdb bash-completion
RUN pip install ipython jupyter jupyterlab
RUN cd /tmp && \
ARCH=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd6... | 2301_81045437/openpilot | .devcontainer/Dockerfile | Dockerfile | mit | 736 |
#!/usr/bin/env bash
TARGET_USER=batman
source .devcontainer/.host/.env
# override display flag for mac hosts
if [[ $HOST_OS == darwin ]]; then
echo "Setting up DISPLAY override for macOS..."
cat <<EOF >> /home/$TARGET_USER/.bashrc
source .devcontainer/.host/.env
if [ -n "\$HOST_DISPLAY" ]; then
DISPLAY_NUM=\$(e... | 2301_81045437/openpilot | .devcontainer/container_post_create.sh | Shell | mit | 1,149 |
#!/usr/bin/env bash
source .devcontainer/.host/.env
# setup safe directories for submodules
SUBMODULE_DIRS=$(git config --file .gitmodules --get-regexp path | awk '{ print $2 }')
for DIR in $SUBMODULE_DIRS; do
git config --global --add safe.directory "$PWD/$DIR"
done
# virtual display for virtualgl
if [[ "$HOST_O... | 2301_81045437/openpilot | .devcontainer/container_post_start.sh | Shell | mit | 489 |
#!/usr/bin/env bash
# pull base image
if [[ -z $USE_LOCAL_IMAGE ]]; then
echo "Updating openpilot_base image if needed..."
docker pull ghcr.io/commaai/openpilot-base:latest
fi
# setup .host dir
mkdir -p .devcontainer/.host
# setup links to Xauthority
XAUTHORITY_LINK=".devcontainer/.host/.Xauthority"
rm -f $XAUTH... | 2301_81045437/openpilot | .devcontainer/host_setup | Shell | mit | 1,564 |
:: pull base image
IF NOT DEFINED USE_LOCAL_IMAGE ^
echo "Updating openpilot_base image if needed..." && ^
docker pull ghcr.io/commaai/openpilot-base:latest
:: setup .host dir
mkdir .devcontainer\.host
:: setup host env file
echo "" > .devcontainer\.host\.env | 2301_81045437/openpilot | .devcontainer/host_setup.cmd | Batchfile | mit | 261 |
import os
import subprocess
import sys
import sysconfig
import platform
import numpy as np
import SCons.Errors
SCons.Warnings.warningAsException(True)
# pending upstream fix - https://github.com/SCons/scons/issues/4461
#SetOption('warn', 'all')
TICI = os.path.isfile('/TICI')
AGNOS = TICI
Decider('MD5-timestamp')
... | 2301_81045437/openpilot | SConstruct | Python | mit | 10,822 |
Import('env', 'envCython', 'arch')
common_libs = [
'params.cc',
'swaglog.cc',
'util.cc',
'i2c.cc',
'watchdog.cc',
'ratekeeper.cc'
]
if arch != "Darwin":
common_libs.append('gpio.cc')
_common = env.Library('common', common_libs, LIBS="json11")
files = [
'clutil.cc',
]
_gpucommon = env.Library('gpuco... | 2301_81045437/openpilot | common/SConscript | Python | mit | 900 |
import jwt
import os
import requests
from datetime import datetime, timedelta
from openpilot.system.hardware.hw import Paths
from openpilot.system.version import get_version
API_HOST = os.getenv('API_HOST', 'https://api.commadotai.com')
class Api:
def __init__(self, dongle_id):
self.dongle_id = dongle_id
wi... | 2301_81045437/openpilot | common/api/__init__.py | Python | mit | 1,466 |
import os
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))
| 2301_81045437/openpilot | common/basedir.py | Python | mit | 104 |
#include "common/clutil.h"
#include <cassert>
#include <iostream>
#include <memory>
#include "common/util.h"
#include "common/swaglog.h"
namespace { // helper functions
template <typename Func, typename Id, typename Name>
std::string get_info(Func get_info_func, Id id, Name param_name) {
size_t size = 0;
CL_CH... | 2301_81045437/openpilot | common/clutil.cc | C++ | mit | 8,976 |
#pragma once
#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
#include <string>
#define CL_CHECK(_expr) \
do { \
assert(CL_SUCCESS == (_expr)); \
} while (0)
#define CL_CHECK_ERR(_expr) \
({ \
cl_int e... | 2301_81045437/openpilot | common/clutil.h | C++ | mit | 1,006 |
import numpy as np
class Conversions:
# Speed
MPH_TO_KPH = 1.609344
KPH_TO_MPH = 1. / MPH_TO_KPH
MS_TO_KPH = 3.6
KPH_TO_MS = 1. / MS_TO_KPH
MS_TO_MPH = MS_TO_KPH * KPH_TO_MPH
MPH_TO_MS = MPH_TO_KPH * KPH_TO_MS
MS_TO_KNOTS = 1.9438
KNOTS_TO_MS = 1. / MS_TO_KNOTS
# Angle
DEG_TO_RAD = np.pi / 180.
... | 2301_81045437/openpilot | common/conversions.py | Python | mit | 383 |
# remove all keys that end in DEPRECATED
def strip_deprecated_keys(d):
for k in list(d.keys()):
if isinstance(k, str):
if k.endswith('DEPRECATED'):
d.pop(k)
elif isinstance(d[k], dict):
strip_deprecated_keys(d[k])
return d
| 2301_81045437/openpilot | common/dict_helpers.py | Python | mit | 259 |
import platform
def suffix():
if platform.system() == "Darwin":
return ".dylib"
else:
return ".so"
| 2301_81045437/openpilot | common/ffi_wrapper.py | Python | mit | 113 |
import os
import tempfile
import contextlib
class CallbackReader:
"""Wraps a file, but overrides the read method to also
call a callback function with the number of bytes read so far."""
def __init__(self, f, callback, *args):
self.f = f
self.callback = callback
self.cb_args = args
self.total_re... | 2301_81045437/openpilot | common/file_helpers.py | Python | mit | 1,285 |
class FirstOrderFilter:
# first order filter
def __init__(self, x0, rc, dt, initialized=True):
self.x = x0
self.dt = dt
self.update_alpha(rc)
self.initialized = initialized
def update_alpha(self, rc):
self.alpha = self.dt / (rc + self.dt)
def update(self, x):
if self.initialized:
... | 2301_81045437/openpilot | common/filter_simple.py | Python | mit | 449 |
import subprocess
from openpilot.common.utils import cache
from openpilot.common.run import run_cmd, run_cmd_default
@cache
def get_commit(cwd: str = None, branch: str = "HEAD") -> str:
return run_cmd_default(["git", "rev-parse", branch], cwd=cwd)
@cache
def get_commit_date(cwd: str = None, commit: str = "HEAD") ... | 2301_81045437/openpilot | common/git.py | Python | mit | 1,389 |
#include "common/gpio.h"
#include <string>
#ifdef __APPLE__
int gpio_init(int pin_nr, bool output) {
return 0;
}
int gpio_set(int pin_nr, bool high) {
return 0;
}
int gpiochip_get_ro_value_fd(const char* consumer_label, int gpiochiop_id, int pin_nr) {
return 0;
}
#else
#include <fcntl.h>
#include <unistd.h>... | 2301_81045437/openpilot | common/gpio.cc | C++ | mit | 2,253 |
#pragma once
// Pin definitions
#ifdef QCOM2
#define GPIO_HUB_RST_N 30
#define GPIO_UBLOX_RST_N 32
#define GPIO_UBLOX_SAFEBOOT_N 33
#define GPIO_GNSS_PWR_EN 34 /* SCHEMATIC LABEL: GPIO_UBLOX_PWR_EN */
#define GPIO_STM_RST_N 124
#define GPIO_STM_BOOT0 134
#define GPIO_BMX_AC... | 2301_81045437/openpilot | common/gpio.h | C | mit | 1,068 |
import os
from functools import cache
def gpio_init(pin: int, output: bool) -> None:
try:
with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f:
f.write(b"out" if output else b"in")
except Exception as e:
print(f"Failed to set gpio {pin} direction: {e}")
def gpio_set(pin: int, high: bool) -> ... | 2301_81045437/openpilot | common/gpio.py | Python | mit | 1,481 |
#include "common/i2c.h"
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <cassert>
#include <cstdio>
#include <stdexcept>
#include "common/swaglog.h"
#include "common/util.h"
#define UNUSED(x) (void)(x)
#ifdef QCOM2
// TODO: decide if we want to install libi2c-dev everywhere
extern "C" {
#i... | 2301_81045437/openpilot | common/i2c.cc | C++ | mit | 1,900 |
#pragma once
#include <cstdint>
#include <mutex>
#include <sys/types.h>
class I2CBus {
private:
int i2c_fd;
std::mutex m;
public:
I2CBus(uint8_t bus_id);
~I2CBus();
int read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len);
int set_register(uint8_t d... | 2301_81045437/openpilot | common/i2c.h | C++ | mit | 376 |
import io
import os
import sys
import copy
import json
import time
import uuid
import socket
import logging
import traceback
from threading import local
from collections import OrderedDict
from contextlib import contextmanager
LOG_TIMESTAMPS = "LOG_TIMESTAMPS" in os.environ
def json_handler(obj):
# if isinstance(ob... | 2301_81045437/openpilot | common/logging_extra.py | Python | mit | 6,604 |
#pragma once
typedef struct vec3 {
float v[3];
} vec3;
typedef struct vec4 {
float v[4];
} vec4;
typedef struct mat3 {
float v[3*3];
} mat3;
typedef struct mat4 {
float v[4*4];
} mat4;
static inline mat3 matmul3(const mat3 &a, const mat3 &b) {
mat3 ret = {{0.0}};
for (int r=0; r<3; r++) {
for (int ... | 2301_81045437/openpilot | common/mat.h | C | mit | 1,677 |
"""
Utilities for generating mock messages for testing.
example in common/tests/test_mock.py
"""
import functools
import threading
from cereal.messaging import PubMaster
from cereal.services import SERVICE_LIST
from openpilot.common.mock.generators import generate_liveLocationKalman
from openpilot.common.realtime imp... | 2301_81045437/openpilot | common/mock/__init__.py | Python | mit | 1,227 |
from cereal import messaging
LOCATION1 = (32.7174, -117.16277)
LOCATION2 = (32.7558, -117.2037)
LLK_DECIMATION = 10
RENDER_FRAMES = 15
DEFAULT_ITERATIONS = RENDER_FRAMES * LLK_DECIMATION
def generate_liveLocationKalman(location=LOCATION1):
msg = messaging.new_message('liveLocationKalman')
msg.liveLocationKalma... | 2301_81045437/openpilot | common/mock/generators.py | Python | mit | 814 |
def clip(x, lo, hi):
return max(lo, min(hi, x))
def interp(x, xp, fp):
N = len(xp)
def get_interp(xv):
hi = 0
while hi < N and xv > xp[hi]:
hi += 1
low = hi - 1
return fp[-1] if hi == N and xv > xp[low] else (
fp[0] if hi == 0 else
(xv - xp[low]) * (fp[hi] - fp[low]) / (xp[hi] ... | 2301_81045437/openpilot | common/numpy_fast.py | Python | mit | 463 |
#include "common/params.h"
#include <dirent.h>
#include <sys/file.h>
#include <algorithm>
#include <cassert>
#include <csignal>
#include <unordered_map>
#include "common/queue.h"
#include "common/swaglog.h"
#include "common/util.h"
#include "system/hardware/hw.h"
namespace {
volatile sig_atomic_t params_do_exit = ... | 2301_81045437/openpilot | common/params.cc | C++ | mit | 12,199 |
#pragma once
#include <future>
#include <map>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "common/queue.h"
enum ParamKeyType {
PERSISTENT = 0x02,
CLEAR_ON_MANAGER_START = 0x04,
CLEAR_ON_ONROAD_TRANSITION = 0x08,
CLEAR_ON_OFFROAD_TRANSITION = 0x10,
DONT_LOG = 0x20,
DEV... | 2301_81045437/openpilot | common/params.h | C++ | mit | 1,899 |
from openpilot.common.params_pyx import Params, ParamKeyType, UnknownKeyName
assert Params
assert ParamKeyType
assert UnknownKeyName
if __name__ == "__main__":
import sys
params = Params()
key = sys.argv[1]
assert params.check_key(key), f"unknown param: {key}"
if len(sys.argv) == 3:
val = sys.argv[2]
... | 2301_81045437/openpilot | common/params.py | Python | mit | 449 |
# distutils: language = c++
# cython: language_level = 3
from libcpp cimport bool
from libcpp.string cimport string
from libcpp.vector cimport vector
cdef extern from "common/params.h":
cpdef enum ParamKeyType:
PERSISTENT
CLEAR_ON_MANAGER_START
CLEAR_ON_ONROAD_TRANSITION
CLEAR_ON_OFFROAD_TRANSITION
... | 2301_81045437/openpilot | common/params_pyx.pyx | Cython | mit | 3,168 |
#pragma once
#include <cassert>
#include <string>
#include "common/params.h"
#include "common/util.h"
#include "system/hardware/hw.h"
class OpenpilotPrefix {
public:
OpenpilotPrefix(std::string prefix = {}) {
if (prefix.empty()) {
prefix = util::random_string(15);
}
msgq_path = "/dev/shm/" + pref... | 2301_81045437/openpilot | common/prefix.h | C++ | mit | 1,113 |
import os
import shutil
import uuid
from openpilot.common.params import Params
from openpilot.system.hardware import PC
from openpilot.system.hardware.hw import Paths
from openpilot.system.hardware.hw import DEFAULT_DOWNLOAD_CACHE_ROOT
class OpenpilotPrefix:
def __init__(self, prefix: str = None, clean_dirs_on_exi... | 2301_81045437/openpilot | common/prefix.py | Python | mit | 1,807 |
#pragma once
#include <condition_variable>
#include <mutex>
#include <queue>
template <class T>
class SafeQueue {
public:
SafeQueue() = default;
void push(const T& v) {
{
std::unique_lock lk(m);
q.push(v);
}
cv.notify_one();
}
T pop() {
std::unique_lock lk(m);
cv.wait(lk, [th... | 2301_81045437/openpilot | common/queue.h | C++ | mit | 892 |
#include "common/ratekeeper.h"
#include <algorithm>
#include "common/swaglog.h"
#include "common/timing.h"
#include "common/util.h"
RateKeeper::RateKeeper(const std::string &name, float rate, float print_delay_threshold)
: name(name),
print_delay_threshold(std::max(0.f, print_delay_threshold)) {
interval... | 2301_81045437/openpilot | common/ratekeeper.cc | C++ | mit | 1,041 |
#pragma once
#include <cstdint>
#include <string>
class RateKeeper {
public:
RateKeeper(const std::string &name, float rate, float print_delay_threshold = 0);
~RateKeeper() {}
bool keepTime();
bool monitorTime();
inline double frame() const { return frame_; }
inline double remaining() const { return remai... | 2301_81045437/openpilot | common/ratekeeper.h | C++ | mit | 518 |
"""Utilities for reading real time clocks and keeping soft real time constraints."""
import gc
import os
import time
from collections import deque
from setproctitle import getproctitle
from openpilot.system.hardware import PC
# time step for each process
DT_CTRL = 0.01 # controlsd
DT_MDL = 0.05 # model
DT_TRML = ... | 2301_81045437/openpilot | common/realtime.py | Python | mit | 2,603 |
import time
import functools
from openpilot.common.swaglog import cloudlog
def retry(attempts=3, delay=1.0, ignore_failure=False):
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
for _ in range(attempts):
try:
return func(*args, **kwargs)
except Exc... | 2301_81045437/openpilot | common/retry.py | Python | mit | 737 |
import subprocess
def run_cmd(cmd: list[str], cwd=None, env=None) -> str:
return subprocess.check_output(cmd, encoding='utf8', cwd=cwd, env=env).strip()
def run_cmd_default(cmd: list[str], default: str = "", cwd=None, env=None) -> str:
try:
return run_cmd(cmd, cwd=cwd, env=env)
except subprocess.CalledPro... | 2301_81045437/openpilot | common/run.py | Python | mit | 351 |
import numpy as np
def get_kalman_gain(dt, A, C, Q, R, iterations=100):
P = np.zeros_like(Q)
for _ in range(iterations):
P = A.dot(P).dot(A.T) + dt * Q
S = C.dot(P).dot(C.T) + R
K = P.dot(C.T).dot(np.linalg.inv(S))
P = (np.eye(len(P)) - K.dot(C)).dot(P)
return K
class KF1D:
# this EKF assume... | 2301_81045437/openpilot | common/simple_kalman.py | Python | mit | 1,578 |
import os
import subprocess
from openpilot.common.basedir import BASEDIR
class Spinner:
def __init__(self):
try:
self.spinner_proc = subprocess.Popen(["./spinner"],
stdin=subprocess.PIPE,
cwd=os.path.join(BASEDIR, "selfd... | 2301_81045437/openpilot | common/spinner.py | Python | mit | 1,362 |
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]
s... | 2301_81045437/openpilot | common/stat_live.py | Python | mit | 1,883 |
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "common/swaglog.h"
#include <cassert>
#include <limits>
#include <mutex>
#include <string>
#include <zmq.h>
#include <stdarg.h>
#include "third_party/json11/json11.hpp"
#include "common/version.h"
#include "system/hardware/hw.h"
class SwaglogState {
public:
... | 2301_81045437/openpilot | common/swaglog.cc | C++ | mit | 4,451 |
#pragma once
#include "common/timing.h"
#define CLOUDLOG_DEBUG 10
#define CLOUDLOG_INFO 20
#define CLOUDLOG_WARNING 30
#define CLOUDLOG_ERROR 40
#define CLOUDLOG_CRITICAL 50
#ifdef __GNUC__
#define SWAG_LOG_CHECK_FMT(a, b) __attribute__ ((format (printf, a, b)))
#else
#define SWAG_LOG_CHECK_FMT(a, b)
#endif
void c... | 2301_81045437/openpilot | common/swaglog.h | C | mit | 3,309 |
import logging
import os
import time
import warnings
from pathlib import Path
from logging.handlers import BaseRotatingHandler
import zmq
from openpilot.common.logging_extra import SwagLogger, SwagFormatter, SwagLogFileFormatter
from openpilot.system.hardware.hw import Paths
def get_file_handler():
Path(Paths.swa... | 2301_81045437/openpilot | common/swaglog.py | Python | mit | 4,204 |
#include "catch2/catch.hpp"
#define private public
#include "common/params.h"
#include "common/util.h"
TEST_CASE("params_nonblocking_put") {
char tmp_path[] = "/tmp/asyncWriter_XXXXXX";
const std::string param_path = mkdtemp(tmp_path);
auto param_names = {"CarParams", "IsMetric"};
{
Params params(param_pat... | 2301_81045437/openpilot | common/tests/test_params.cc | C++ | mit | 774 |
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
| 2301_81045437/openpilot | common/tests/test_runner.cc | C++ | mit | 54 |
#include <zmq.h>
#include <iostream>
#include "catch2/catch.hpp"
#include "common/swaglog.h"
#include "common/util.h"
#include "common/version.h"
#include "system/hardware/hw.h"
#include "third_party/json11/json11.hpp"
std::string daemon_name = "testy";
std::string dongle_id = "test_dongle_id";
int LINE_NO = 0;
voi... | 2301_81045437/openpilot | common/tests/test_swaglog.cc | C++ | mit | 2,649 |
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <algorithm>
#include <climits>
#include <fstream>
#include <random>
#include <string>
#include "catch2/catch.hpp"
#include "common/util.h"
std::string random_bytes(int size) {
std::random_device rd;
std::independent_bits_engine<std::defau... | 2301_81045437/openpilot | common/tests/test_util.cc | C++ | mit | 4,300 |
#!/usr/bin/env python3
import os
import time
import subprocess
from openpilot.common.basedir import BASEDIR
class TextWindow:
def __init__(self, text):
try:
self.text_proc = subprocess.Popen(["./text", text],
stdin=subprocess.PIPE,
... | 2301_81045437/openpilot | common/text_window.py | Python | mit | 1,544 |
import datetime
from pathlib import Path
_MIN_DATE = datetime.datetime(year=2024, month=3, day=30)
def min_date():
# on systemd systems, the default time is the systemd build time
systemd_path = Path("/lib/systemd/systemd")
if systemd_path.exists():
d = datetime.datetime.fromtimestamp(systemd_path.stat().st... | 2301_81045437/openpilot | common/time.py | Python | mit | 461 |
import signal
class TimeoutException(Exception):
pass
class Timeout:
"""
Timeout context manager.
For example this code will raise a TimeoutException:
with Timeout(seconds=5, error_msg="Sleep was too long"):
time.sleep(10)
"""
def __init__(self, seconds, error_msg=None):
if error_msg is None:
... | 2301_81045437/openpilot | common/timeout.py | Python | mit | 699 |
#pragma once
#include <cstdint>
#include <ctime>
#ifdef __APPLE__
#define CLOCK_BOOTTIME CLOCK_MONOTONIC
#endif
static inline uint64_t nanos_since_boot() {
struct timespec t;
clock_gettime(CLOCK_BOOTTIME, &t);
return t.tv_sec * 1000000000ULL + t.tv_nsec;
}
static inline double millis_since_boot() {
struct t... | 2301_81045437/openpilot | common/timing.h | C++ | mit | 1,237 |
Import('env', 'envCython')
transformations = env.Library('transformations', ['orientation.cc', 'coordinates.cc'])
transformations_python = envCython.Program('transformations.so', 'transformations.pyx')
Export('transformations', 'transformations_python')
| 2301_81045437/openpilot | common/transformations/SConscript | Python | mit | 255 |
import itertools
import numpy as np
from dataclasses import dataclass
import openpilot.common.transformations.orientation as orient
## -- hardcoded hardware params --
@dataclass(frozen=True)
class CameraConfig:
width: int
height: int
focal_length: float
@property
def size(self):
return (self.width, sel... | 2301_81045437/openpilot | common/transformations/camera.py | Python | mit | 6,121 |
#define _USE_MATH_DEFINES
#include "common/transformations/coordinates.hpp"
#include <iostream>
#include <cmath>
#include <eigen3/Eigen/Dense>
double a = 6378137; // lgtm [cpp/short-global-name]
double b = 6356752.3142; // lgtm [cpp/short-global-name]
double esq = 6.69437999014 * 0.001; // lgtm [cpp/short-global-nam... | 2301_81045437/openpilot | common/transformations/coordinates.cc | C++ | mit | 2,881 |
#pragma once
#include <eigen3/Eigen/Dense>
#define DEG2RAD(x) ((x) * M_PI / 180.0)
#define RAD2DEG(x) ((x) * 180.0 / M_PI)
struct ECEF {
double x, y, z;
Eigen::Vector3d to_vector(){
return Eigen::Vector3d(x, y, z);
}
};
struct NED {
double n, e, d;
Eigen::Vector3d to_vector(){
return Eigen::Vector... | 2301_81045437/openpilot | common/transformations/coordinates.hpp | C++ | mit | 874 |
from openpilot.common.transformations.orientation import numpy_wrap
from openpilot.common.transformations.transformations import (ecef2geodetic_single,
geodetic2ecef_single)
from openpilot.common.transformations.transformations import LocalCoord as LocalCoord_single
... | 2301_81045437/openpilot | common/transformations/coordinates.py | Python | mit | 853 |
import numpy as np
from openpilot.common.transformations.orientation import rot_from_euler
from openpilot.common.transformations.camera import get_view_frame_from_calib_frame, view_frame_from_device_frame
# segnet
SEGNET_SIZE = (512, 384)
# MED model
MEDMODEL_INPUT_SIZE = (512, 256)
MEDMODEL_YUV_SIZE = (MEDMODEL_INP... | 2301_81045437/openpilot | common/transformations/model.py | Python | mit | 2,461 |
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <eigen3/Eigen/Dense>
#include "common/transformations/orientation.hpp"
#include "common/transformations/coordinates.hpp"
Eigen::Quaterniond ensure_unique(Eigen::Quaterniond quat){
if (quat.w() > 0){
return quat;
} else {
return Eigen... | 2301_81045437/openpilot | common/transformations/orientation.cc | C++ | mit | 4,624 |
#pragma once
#include <eigen3/Eigen/Dense>
#include "common/transformations/coordinates.hpp"
Eigen::Quaterniond ensure_unique(Eigen::Quaterniond quat);
Eigen::Quaterniond euler2quat(Eigen::Vector3d euler);
Eigen::Vector3d quat2euler(Eigen::Quaterniond quat);
Eigen::Matrix3d quat2rot(Eigen::Quaterniond quat);
Eigen::... | 2301_81045437/openpilot | common/transformations/orientation.hpp | C++ | mit | 758 |
import numpy as np
from collections.abc import Callable
from openpilot.common.transformations.transformations import (ecef_euler_from_ned_single,
euler2quat_single,
euler2rot_single,
... | 2301_81045437/openpilot | common/transformations/orientation.py | Python | mit | 1,981 |
# cython: language_level=3
from libcpp cimport bool
cdef extern from "orientation.cc":
pass
cdef extern from "orientation.hpp":
cdef cppclass Quaternion "Eigen::Quaterniond":
Quaternion()
Quaternion(double, double, double, double)
double w()
double x()
double y()
double z()
cdef cppclas... | 2301_81045437/openpilot | common/transformations/transformations.pxd | Cython | mit | 1,502 |
# distutils: language = c++
# cython: language_level = 3
from openpilot.common.transformations.transformations cimport Matrix3, Vector3, Quaternion
from openpilot.common.transformations.transformations cimport ECEF, NED, Geodetic
from openpilot.common.transformations.transformations cimport euler2quat as euler2quat_c
... | 2301_81045437/openpilot | common/transformations/transformations.pyx | Cython | mit | 5,632 |
#include "common/util.h"
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <cassert>
#include <cerrno>
#include <cstring>
#include <dirent.h>
#include <fstream>
#include <iomanip>
#include <random>
#include <sstream>
#ifdef __linux__
#include <sys/prctl.h>
#include <sys/syscall.h>
#ifnd... | 2301_81045437/openpilot | common/util.cc | C++ | mit | 6,804 |
#pragma once
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <algorithm>
#include <atomic>
#include <chrono>
#include <csignal>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <vector>
// keep trying if x gets interrupted by a signal
#define HANDLE... | 2301_81045437/openpilot | common/util.h | C++ | mit | 4,943 |
from collections.abc import Callable
from functools import lru_cache
from typing import TypeVar
_RT = TypeVar("_RT")
class Freezable:
_frozen: bool = False
def freeze(self):
if not self._frozen:
self._frozen = True
def __setattr__(self, *args, **kwargs):
if self._frozen:
raise Exception(... | 2301_81045437/openpilot | common/utils.py | Python | mit | 513 |
#define COMMA_VERSION "0.9.7"
| 2301_81045437/openpilot | common/version.h | C | mit | 30 |
#include <string>
#include "common/watchdog.h"
#include "common/util.h"
const std::string watchdog_fn_prefix = "/dev/shm/wd_"; // + <pid>
bool watchdog_kick(uint64_t ts) {
static std::string fn = watchdog_fn_prefix + std::to_string(getpid());
return util::write_file(fn.c_str(), &ts, sizeof(ts), O_WRONLY | O_CRE... | 2301_81045437/openpilot | common/watchdog.cc | C++ | mit | 331 |
#pragma once
#include <cstdint>
bool watchdog_kick(uint64_t ts);
| 2301_81045437/openpilot | common/watchdog.h | C++ | mit | 67 |
import contextlib
import gc
import os
import pytest
import random
from openpilot.common.prefix import OpenpilotPrefix
from openpilot.system.manager import manager
from openpilot.system.hardware import TICI, HARDWARE
def pytest_sessionstart(session):
# TODO: fix tests and enable test order randomization
if sessio... | 2301_81045437/openpilot | conftest.py | Python | mit | 3,199 |