Today's English

This text is also text!

Vocabulary


Basic

  • provision:
    The millionaire made a special provision for his sick grandson in his will.

  • conscious:
    He wasn’t conscious of the effect his speech had on the audience.

  • ridiculous:

  • essence: take the essence of various flower

  • preference: my preference is fish, but I will take the chicken

  • courtesy: They provided a free shuttle service as a courtesy to their customers.

  • prevention:

  • inconsiderate: It was inconsiderate of him to play loud music late at night.

  • delinquency: The government is working to reduce juvenile delinquency through education programs.

  • usher: The usher showed us to our seats.

  • pastime: Watching movies is one of my favorite pastimes.

  • sanction:
    制裁:The UN imposed sanctions on the country for violating international law.
    承認:The project received the necessary sanctions to proceed.

  • compel: The circumstances compelled her to make a difficult decision.

  • compulsory: The coach compelled the players to train harder.

  • conceive: She conceived an innovative idea for the project.

  • confine: Please confine your remarks to the main topic.

  • misery:

  • slam: He slammed the door behind him.

  • dismay: To my dismay, the event was canceled at the last

  • dye:

  • doctrine

  • reassure

  • decent

  • immense

  • fragile

  • immerse

  • neatly

  • endorse

  • stake

  • radical

  • conviction

  • vertict

  • exploit:

  • formidable: The team faced a formidable task of completing the project within a week. 手強い、難しい
    She has a formidable talent for music. 非常に優れた、素晴らしい

  • intimidate:

  • stiff : My neck feels stiff from sitting too long.


ROS2 programming

This text is also text!


ワークスペース


1
source /opt/ros/foxy/setup.bash

I2Cでディスプレイ接続

This text is also text!

準備


1
sudo i2cdetect -y 1
1
2
3
4
5
6
7
8
9
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

基本使い方


1
2
3
4
5
6
7
8
9
10
11
import board
from busio import I2C
from adafruit_ssd1306 import SSD1306_I2C

# I2Cオブジェクトを正しく初期化
i2c = I2C(scl=board.SCL, sda=board.SDA)

#
display = SSD1306_I2C(128, 64, i2c, addr=0x3C)
display.fill(1)
display.show()

Raspberry PiでUSBマイクを取り付けて音声を録音させる

This text is also text!

Preparation


usb マイクを差し入れる前後に lsusbコマンドで出力を確認します。

1
2
3
4
5
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 08bb:2902 Texas Instruments PCM2902 Audio Codec
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

以下arecord -lコマンドを実行して確認します。

ALSAからの認識を確認

Linuxのオーディオドライバ「ALSA」から見たUSBマイクの認識

1
2
3
4
5
$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

「card:1、device:0」としてと認識されていることがわかります。

ハードウェア・モジュールの認識確認

1
2
3
4
5
6
$ cat /proc/asound/modules
0 snd_bcm2835
1 snd_soc_rpi_simple_soundcard
2 snd_usb_audio
3 vc4
4 vc4

snd_usb_audioの優先順位を一番に上げます。

1
2
3
4
$sudo vi /etc/modprobe.d/alsa-base.conf
options snd slots=snd_usb_audio,snd_bcm2835
options snd_usb_audio index=0
options snd_bcm2835 index=1

その結果です

1
2
3
4
5
6
$ cat /proc/asound/modules
0 snd_usb_audio
1 snd_bcm2835
2 snd_soc_rpi_simple_soundcard
3 vc4
4 vc4

「aplay -L」コマンドを使用すると、ALSAで定義されているすべての PCM(サウンドデバイス) を一覧表示します

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 2: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 [HifiBerry DAC HiFi pcm5102a-hifi-0]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 3: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 4: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ nano ~/.asoundrc
pcm.!default { # サウンドデバイスのデフォルトを設定
type asym # Asym PCM
playback { # Playback slave definition
pcm {
type hw
card Headphones # [aplay -L]コマンドで確認したデバイスの名前
device 0 # [aplay -L]コマンドで確認したデバイスの番号
}
}
capture { # Capture slave definition
pcm {
type hw
card Device # [arecord -L]コマンドで確認したデバイスの名前
device 0 # [arecord -L]コマンドで確認したデバイスの番号
}
}
}

Recording


以下コマンドで録音します。

1
arecord test.wav

ノイズだらけです。。

【arecordのオプションパラメータ】
-c 1:チャネル数を指定します。(モノラル:1)
-d 5:録音時間を指定します。(5秒)
-f S16_LE:サンプリングのフォーマットを指定します。(S16_LE)
-r 44100:サンプリングレートを指定します。(44100Hz)
-t wav:ファイルフォーマットのタイプを指定します。(wav形式)

1
arecord -c 1 -d 10 -f S16_LE -r 44100 -t wav record.wav

割ときれいな音が録音できます。

Test

録音ファイルを再生して、音声を確認します。

1
aplay test.wav

音声ボリューム

[F4キー]を押して録音の設定画面に切り替えます。

1
alsamixer

Raspberry PiでBluetoothスピーカーを鳴らす

This text is also text!

Preparation


Amazon.co.jpで買ったEWA A106というスピーカーです

PulseAudioとPulseAudioのBluetoothスピーカーのモジュールをインストールします。

1
sudo apt-get install pulseaudio pulseaudio-module-bluetooth

Setting

PulseAudioの設定


PulseAudioを設定するため、/etc/pulse/default.paを編集します

1
sudo nano /etc/pulse/default.pa

ファイルの最後に次の行を追加します。

1
2
# automatically switch to newly-connected devices
load-module module-switch-on-connect

bluetooth権限追加

sudoなしでBluetoothが制御できるため、ユーザーをbluetoothグループに入れル必要があります。

1
2
sudo usermod -G bluetooth -a $USER
sudo reboot

## 動作
Bluetoothスピーカーをペアリングするためpulseaudioを起動します

1
pulseaudio --start

bluetoothctlコマンドを起動して以下操作します。

1
2
3
4
5
6
7
8
9
$ bluetoothctl
Agent registered
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# scan on
Discovery started
・・・
[NEW] Device 3D:8F:2B:2E:E4:07 EWA Audio A106
・・・

ペアリング

pairコマンドでペアリングします

1
2
[bluetooth]# pair 3D:8F:2B:2E:E4:07
Attempting to pair with 3D:8F:2B:2E:E4:07

Pairing successfulと出れば成功です。
ついでにtrustコマンドでTrustリストに登録します

1
2
3
[bluetooth]# trust 3D:8F:2B:2E:E4:07
[CHG] Device 3D:8F:2B:2E:E4:07 Trusted: yes
Changing 3D:8F:2B:2E:E4:07 trust succeeded

connectコマンドでスピーカーに接続します。

1
2
3
4
5
6
[bluetooth]# connect 3D:8F:2B:2E:E4:07
Attempting to connect to 3D:8F:2B:2E:E4:07
[CHG] Device 3D:8F:2B:2E:E4:07 Connected: yes
Connection successful
[CHG] Device 3D:8F:2B:2E:E4:07 ServicesResolved: yes
[EWA Audio A106]#

終了

以下のコマンドを実行してペアリングを終了します。

1
[EWA Audio A106]# quit

テスト

ファイルを再生して音を鳴らして確認しましょう。

1
$ aplay /usr/share/sounds/alsa/Front_Center.wav

音量調整

alsamixer コマンドで調整できます。
上下キーで音量を調整でき、F6 キーで出力先(ヘッドホンジャック、HDMI など)を変更できます。
また、M ボタンを押すとミュート/ミュート解除の切り替えができます

宗教と創造との関係

This text is also text!

# 文化与科学发展的关系

基督教世界

通过信仰激发对自然规律的探索,逐渐发展出系统性的科学方法,成为近代科学革命的核心。

  • 新教的兴起:
    从罗马天主教到新教的演化,经历了多个重要的宗教改革(如16世纪马丁·路德的宗教改革)。
    这些改革推动了宗教思想的多样化,也间接促进了科学与文化的自由发展。

  • 不断的自我调整:
    基督教通过适应社会需求(如推动教育、科学探索和社会福利),使其在现代科技和社会发展中具有重要的推动力。

伊斯兰世界

在其辉煌时期,将不同文化的知识(如希腊、波斯、印度)融会贯通,为人类文明的进步作出了重要贡献

  • 神与人的关系:
    伊斯兰宗教非常强调神与人之间的关系,突出神的绝对权威与控制。这种关系强化了宗教的信仰体系,但也可能限制个人的自主性和创新性。
  • 忽略人与人的关系:
    相较于中国文化注重人际关系,或基督教文化在神与人之外也强调伦理与社会责任,伊斯兰文化对人际关系的关注相对较少。

中国传统文化

注重实用性和经验积累,但在符号化、理论化的科学研究上较少涉及,导致在现代科学上进展相对较慢。

linux-kernel

This text is also text!



edu-math

This text is also text!

数学の受験についての心得


小学校から高校まで数学の受験では、以下3点がやれば、高得点が取れるはずです。

  1. 冷静に考える
    試験の時、そもそも問題の意味がわからない、あるいは、問題が読み間違えた。
    あるいは、問題がわかってケアミスで点数が失うという点が挙げられる

  2. 基本知識
    限られている時間で効率よく基本問題をできるように訓練する必要があります。
    問題をカテゴライズすべくところです。

  • 絶対できる問題:ノーミスで100%着実に点数を取る。しかも、熟練しているので早く処理すること
  • 頑張ればできる問題: 80%時間をかけてやること。工夫しながら納得まで理解する
  • とてもムズイ問題(IMOレベルの問題):上記問題ができた前提で10%の時間をかけてチャレンジすること
  1. 推理スキル
    数学の問題を解く過程では、推理スキルを養うことができます。大人になっても使う能力です。

devcon-mmdet3d

This text is also text!

ファイルの準備


Dockerfileの作成


Modify Dockerfile as follow.

[Dockerfile]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04

ENV DEBIAN_FRONTEND=noninteractive

# Install some basic utilities
RUN apt-get update && apt-get install wget -yq
RUN apt-get install build-essential g++ gcc -y
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get install libgl1-mesa-glx libglib2.0-0 -y
RUN apt-get install openmpi-bin openmpi-common libopenmpi-dev libgtk2.0-dev git -y

# Install conda
ENV CONDA_DIR /opt/conda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py38_23.11.0-1-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda

ENV PATH=$CONDA_DIR/bin:$PATH
RUN conda install python=3.8

### Install pytorch
RUN pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

### Pip install mmcv-full in conda
RUN /opt/conda/bin/pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html

RUN /opt/conda/bin/pip install mmdet==2.14.0 \
mmsegmentation==0.14.1 \
timm \
Pillow==8.4.0 \
tqdm \
torchpack \
mpi4py==3.0.3 \
numba==0.48.0 \
nuscenes-devkit==1.1.9

RUN conda install conda-build pyyaml numpy ipython cython typing typing_extensions mkl mkl-include ninja &&\
/opt/conda/bin/conda clean -ya

WORKDIR /root/workspace

devcontainer.jsonの作成

Modify devcontainer.json as follow.

[devcontainer.json]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
"name": "bev-playground",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"remoteUser": "root",
"workspaceFolder": "/workspace",
"remoteEnv": {
"TRT_LIBPATH": "/usr/lib/x86_64-linux-gnu",
"TRT_OSSPATH": "/workspace/TensorRT"
},
"runArgs": [
"--gpus",
"all",
"--shm-size",
"16gb"
],
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind",
"source=${localWorkspaceFolder}/dataset/can_bus,target=/workspace/VAD/data/can_bus,type=bind",
"source=${localWorkspaceFolder}/dataset/nuscenes,target=/workspace/VAD/data/nuscenes,type=bind",
],
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],
"settings": {
"python.defaultInterpreterPath": "/opt/conda/bin/python3"
}
}

Dockerビルド


VscodeでReopen containerをクリックして、コンテナをビルドし始めます。

mmdet3dインストール


コンテナでは、mmdet3dをインストールします。

[Dockerfile]
1
2
3
4
  git clone https://github.com/open-mmlab/mmdetection3d.git &&\
cd mmdetection3d &&\
git checkout -f v0.17.1 &&\
python setup.py develop

Troubleshooting


mmdet3dをインストールするとき、libやlibのバージョンが合わせない問題が発生しました。(更新予定)
以下のように修正してください。

1
2
3
4
5
6
7
scikit-image==0.21.0
networkx==3.1
pandas==2.0.3
numba==0.48.0
numpy==1.21.1
similaritymeasures==1.2.0
shaplely==1.8.5

vscode-devcon-1

This text is also text!

必要なツールのインストール


  • VSCode: 公式サイトからインストール
  • Docker Desktop: 公式サイトからインストール
  • VSCode拡張機能

プロジェクト構造の準備


1
2
3
4
5
6
7
project/
├── .devcontainer/
│ ├── devcontainer.json
│ ├── Dockerfile
├── src/
│ └── main.py
└── requirements.txt

各ファイルの作成


Dockerfileの作成

まず、Dockerfileを作成します。Docker imagesがビルドされます。

[dockerfile]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Dockerfile
FROM python:3.10-slim

# 必要なツールをインストール
RUN apt-get update && apt-get install -y \
curl \
git \
&& rm -rf /var/lib/apt/lists/*

# ワークスペースを設定
WORKDIR /workspace

# Python環境をセットアップ
COPY requirements.txt /workspace/
RUN pip install --no-cache-dir -r requirements.txt

devcontainer.jsonの作成

次に、devcontainerからdockerイメージをビルドし、Containerを起動するためdevcontainer.jsonで設定します。

マウント設定もここで設定します。

1
2
3
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind"
]
[devcontainer.json]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// .devcontainer/devcontainer.json
{
"name": "Python DevContainer",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"settings": {
"python.pythonPath": "/usr/local/bin/python"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],
"forwardPorts": [8000],
"postCreateCommand": "pip install --no-cache-dir -r requirements.txt",
"remoteUser": "root",
"workspaceFolder": "/workspace",
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind"
]
}

launch.jsonの作成

Debuggerを使ってデバックするためlaunch.jsonを作成します。

[launch.json]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Docker Debug",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/main.py",
"console": "integratedTerminal",
"justMyCode": true
}
]
}

その他のファイルの作成

requirements.txtの作成

[requirements.txt]
1
2
3
4
5
requests==2.31.0      # HTTPリクエストを送信するためのライブラリ
numpy==1.26.0 # 数値計算ライブラリ
pandas==2.1.1 # データ分析ライブラリ
scipy==1.11.3 # 科学技術計算ライブラリ
matplotlib==3.8.0 # グラフ描画ライブラリ

src/main.pyの作成

今回デバックしたいpythonファイルを作成します。

まとめ


以上、Vscode + Devcontainerのdocker containerの中でデバック環境を構築することができました。
必要なLibについて、Dockerfilerequirements.txtを追加・修正してカスタマイズしてください。