Skip to content

Instantly share code, notes, and snippets.

View BuckyI's full-sized avatar
🧠
浮云柳絮无根蒂,天地阔远随飞扬~

BuckyBuck BuckyI

🧠
浮云柳絮无根蒂,天地阔远随飞扬~
  • 22:26 (UTC +08:00)
View GitHub Profile
@BuckyI
BuckyI / main.py
Created April 24, 2024 01:48
pytorch demo to classify on iris dataset #prototype
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.nn.functional as F
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
iris = load_iris()
X = iris["data"]
y = iris["target"]
@BuckyI
BuckyI / complex_numbers.hpp
Created December 23, 2023 07:30
Complex number for C++
#include <stdexcept>
#include <cmath>
namespace complex_numbers
{
class Complex
{
private:
double _real;
double _imag;
public:
@BuckyI
BuckyI / least_square_fit.py
Last active January 27, 2024 14:40
use multiple sensor(observation) to get the unknown parameters 使用多个环境光传感器计算光源位置、强度
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit
X0 = 1 # 传感器摆放间距
def illuminate(idx, x, y, intensity):
"""模拟光敏传感器阵列的输出"""
theta = np.arctan2(idx * X0 - x, y) # incoming angle
@BuckyI
BuckyI / demo.py
Created October 10, 2023 09:37
A simple demo to use pykinect_azure to performe some operations. Reference: https://learn.microsoft.com/zh-cn/azure/kinect-dk/about-sensor-sdk
"""
Basic operations based on sensor SDK tutorial
https://learn.microsoft.com/zh-cn/azure/kinect-dk/about-sensor-sdk
Note some code utilize pykinect_azure's wrapper instead of low level SDK
"""
import cv2
import matplotlib.pyplot as plt
import pykinect_azure as pykinect
from pykinect_azure.k4a import _k4a
@BuckyI
BuckyI / README.md
Last active September 18, 2023 14:26
Draw mean-difference plot

Explain

Mean-Difference plot, or Bland–Altman plot can be used to compare the prediction accuracy.

Bland and Altman drive the point that any two methods that are designed to measure the same parameter (or property) should have good correlation when a set of samples are chosen such that the property to be determined varies considerably.

This is how they looks:

01

02

@BuckyI
BuckyI / CMakeLists.txt
Last active July 30, 2023 11:35
[learning] robot move
cmake_minimum_required(VERSION 3.8)
project(moverobot)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
@BuckyI
BuckyI / demo.launch.py
Last active July 23, 2023 08:42
[learning materials] some code in xxx_moveit_config package generated by moveit setup assistant
from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import generate_demo_launch
def generate_launch_description():
moveit_config = MoveItConfigsBuilder(
"ec66", package_name="elite_moveit_config"
).to_moveit_configs()
""""
What does `generate_demo_launch` do:
import os
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch.conditions import IfCondition, UnlessCondition
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from launch.actions import ExecuteProcess
from ament_index_python.packages import get_package_share_directory
from moveit_configs_utils import MoveItConfigsBuilder
@BuckyI
BuckyI / re.md
Last active April 1, 2023 12:00
正则表达式

正则表达式匹配

[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12} uuid

import re

string = "Hello.mp4"
re.sub(r"(.*?)\.", "\g<1> - YouTube.", string)
# 'Hello - YouTube.mp4'
@BuckyI
BuckyI / config.py
Last active June 26, 2023 11:55
logging
import logging
# 创建一个输出到本地的 Handler
# 首先通过 basicConfig 赋予 rootLogger 一个 StreamHandler
# 然后自定义一个 FileHandler 赋予 rootLogger
# 为什么不自定义一个 StreamHandler 再赋予 rotLogger 是因为感觉这样省事
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(levelname)s: %(message)s')
handler = logging.FileHandler("logname.log")
handler.setLevel(logging.INFO)