Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions _posts/2024-07-09-self-introduction.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
---
layout: post
title: "ブログを始めました"
title: "We started our blog"
date: 2024-07-08 07:00:00 +0900
tag: [free-talk, rotarymars's article]
thumbnail-img: "/assets/images/thumb.png"
author: "rotarymars"
---
こんにちは。TECHNOの rotarymars です。<br>
今日は、ブログの開設を記念して、グループメンバの紹介と、自己紹介をしていきたいと思います。
Hello. I'm rotarymars from TECHNO.

Today, I'd like to introduce our team members and myself to celebrate the launch of our blog.

I would like to introduce our team members.

# ROTARYMARS
### 主な担当
- センサー周りのプログラム
- 回路
### Main responsibilities
- Sensor-related programming
- Circuit design

### 軽めな自己紹介
このチームでプログラムや回路を今後担当していく予定のROTARYMARSです。<br>
回路についての知識が全く無いので、今勉強に励んでいるところです。<br>
勉強に良いサイトなどがあれば絶賛募集中です!
### Brief self-introduction
I'm ROTARYMARS, who will be responsible for programming and circuit design in this team.
I'm currently learning about circuits, and I'm looking for good sites to learn from.

# NISHIKAZU
### 主な担当
- 本体のプログラム
### Main responsibilities
- Main body programming

NISHIKAZU です。主にプログラミングなどのソフトウェア系を担当しています。
I'm NISHIKAZU, who will be responsible for software-related tasks in this team.

夜型で朝は苦手なので、夜に色々と活動しています。プログラムはとりあえず書いて動かしてみるタイプです。
I'm a night owl, so I'm active at night. I'm a type of programmer who writes and runs programs first.

数学より理科です。
I'm better at science than math.

# ALPAKA

### 主な担当
- ハード作り
### Main responsibilities
- Hardware design

ハード担当のALPAKAです。
I'm ALPAKA, who will be responsible for hardware design in this team.

回路を勉強している最中で、
I'm currently learning about circuits, and I'm looking for good sites to learn from.

ハード作りや回路の勉強は試行回数が一番大事だと信じています。
I believe that the number of trials is the most important for hardware design and circuit learning.

あと、音感は天性の才能だと確信しています
I'm sure that I have a natural talent for music.
48 changes: 22 additions & 26 deletions _posts/2024-07-23-ev3_ssh.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
---
layout: post
title: "SSHでEV3"
title: "SSH to EV3"
date: 2024-07-23 12:00:00 +0900
tag: [robot, EV3, rotarymars's article]
thumbnail-img: "/assets/images/ssh.png"
author: "rotarymars"
---
# この記事の概要
スペックの遅いパソコンでもサクサクEV3のコーディングしよう!
# Overview
Let's code EV3 on a low-spec computer!

# 前提
# Prerequisites

- EV3にmicropythonのイメージをSDCardにインストールされていて、SDCardがEV3に刺さっている。
- The EV3 has a microPython image installed on the SD card, and the SD card is inserted into the EV3.

- bluetoothまたは有線でEV3とつながっている。
- The EV3 is connected to the computer via Bluetooth or a cable.

- sshで通信するためのコマンドがインストールされている。
- The command to communicate via ssh is installed (e.g. `ssh` on Linux/FreeBSD).


# SSHとは?
[wikipedia](https://ja.wikipedia.org/wiki/Secure_Shell)によると、とにかく、相手側のShellに安全に通信して操作できる仕組みのことのようです。
# What is SSH?
According to [wikipedia](https://ja.wikipedia.org/wiki/Secure_Shell), it is a system that allows you to safely communicate with the other side's shell.


# 実際にやってみよう
# Let's try it

各OSのシェルを開いて、
Open the shell, you can enter by typing the following command.

```bash
ssh username@IPADDRESS
```

で入れます。

デフォルトでは、
By default, you can enter by

```bash
ssh robot@IPADDRESS
```

でできます。

IPADDRESSは下の写真のように左上に表示されます。
An IP address is displayed in the upper left corner of the picture below.

![ev3](/assets/images/ev3dev.png)

この場合、
In this case,

```bash
ssh robot@169.254.80.244
```
です。すると、下のようになって、パスワードを聞かれるので、makerと入力しましょう(デフォルトの場合)。

You will be asked for a password. Enter `maker` (the default password).


```bash
ssh robot@169.254.80.244
Expand All @@ -66,20 +65,17 @@ Last login: Wed Apr 15 10:24:02 2020 from 169.254.68.188
robot@hexagon:~$

```
これでつながります。

ここで、viなどで、pythonファイルを作ります。
You are connected by this way.

# 実行方法
# How to run

```bash
brickrun /usr/bin/pybricks-micropython /path/to/main.py
```

これで実行できます。

# 結論
# Conclusion

これでvscodeが使えない状況でも実行できるので、試してみてください。
Now you can run it even if you don't have vscode.

サムネイルの著作権はFreepikにあります。
The thumbnail is copyrighted by Freepik.
130 changes: 64 additions & 66 deletions _posts/2024-08-07-python-OS.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
---
layout: post
title: "Pythonでコマンドライン"
title: "Python Command Line"
date: 2024-08-07 12:00:00 +0900
tag: [python, free-talk, nishikazu's article]
thumbnail-img: "/assets/images/PythonOS.png"
author: "nishikazu"
---
# この記事の概要
__今回は雑談回です。__
# Overview
__This is a article for free talk.__

Pythonでコマンドプロンプトもどきを作ったので、それを紹介していきたいと思います。
I've created a command line like prompt in Python, so I'd like to introduce it.

(__コマンドラインについては、[こちら](https://qiita.com/momo1010/items/adcef12d0c631785499f)をお読みください。__
(__For more information about the command line, please read [this](https://qiita.com/momo1010/items/adcef12d0c631785499f).__
)
# 使用環境
# Environment
* * *
<dl>
<dt>-Windows11</dt>
<dd>(Windows10でも動きます。)</dd>
<dd>(It also works on Windows10.)</dd>
<dt>-Python3.12.4</dt>
<dd>最新版</dd>
<dd>Latest version</dd>
</dl>

* * *


上記の環境ではテストしています。
It is tested on the above environment.



# 使っていくモジュール
今回のコマンドラインを作っていく上で必要なモジュールです。
# Modules to use
These are the modules needed to create the command line.

__tkinterについては、[こちら](https://ja.wikipedia.org/wiki/Tkinter)をお読みください。__
__For more information about `tkinter`, please read [this](https://ja.wikipedia.org/wiki/Tkinter).__

__Windowsの場合、tkinterはデフォルトでインストールされますが、例えばDebian系で動かしたい場合は次のコマンドでPythonとは別にインストールして下さい。__
__In Windows, `tkinter` is installed by default, but if you want to run it on other systems, please install it separately from Python.__

For Debian-based systems, you can install it with the following command(You would like need a `sudo` because you are usually not a root user).

```
apt install python3-tk
```
<br>

|  |__モジュール名__|__使う目的__|
|  |__module name__|__purpose__|
|:--:|:-------------:|:---------:|
| 1 | tkinter | pythonでウィンドウを作り、テキストボックスを挿入するため。|
| 2 | OS | コマンドラインに必要なディレクトリの移動などをできるようにするため。|
| 3 | sys | パソコンの実行環境についての情報を扱うため。|
| 4 | shutil | ファイルをコピーするときに使うため。|
| 5 | webbrowser | URLを開けるようにするため。|
| 1 | tkinter | To create a window and insert a text box.|
| 2 | OS | To be able to move directories in the command line.|
| 3 | sys | To handle information about the computer's execution environment.|
| 4 | shutil | To use when copying files.|
| 5 | webbrowser | To open URLs.|


# ウィンドウの設定
### tkinterでウィンドウを作る
まずは、コマンドを入力するところと出力するところを作ります。
# Window settings
### Create a window with tkinter
First, let's create a place to input commands and a place to output the results.

```python
import tkinter as tk
Expand All @@ -75,59 +77,57 @@ output_text.pack(pady=10)
root.mainloop()

```
tkinterに付随してscrolledtextとmessageboxをインポートして使っています。

tkinter includes scrolledtext and messagebox, so we use them.


そして、__root = tk.Tk()__ を使って```root```という名前のウィンドウを作り、
Then, we create a window with ```root = tk.Tk()```.

```frame = tk.Frame(root)```でフレームを作っています。
We create a frame with ```frame = tk.Frame(root)```.

entryはコマンド入力欄、output_textはコマンド出力欄のためのスクロールバー付きのテキストボックスです。
`entry` is the input field for commands, and `output_text` is a text box with a scroll bar for the command output.

### ポイント
tkinterでは、最後の行の
### Point
In tkinter, the last line of
```
root.mainloop()
```
の命令でウィンドウを表示します。rootとは、今回設定したこのウィンドウの名前です。
displays the window. `root` is the name of the window we set up this time.

### 出力結果
### Output
<img width="300" src="/assets/images/tkinter_window_practice.png">

# コマンドの実装
# Command implementation

## 実装するコマンド一覧
## List of commands to implement

今回実装していくコマンドは次の通りです。
The commands we will implement this time are as follows.

* ls - ディレクトリの中のファイルを表示するfrom tkinter import scrolledtext, messagebox
* cd <path> - ディレクトリを変更する
* cat <filename> - コンテンツをコマンドライン上に表示する
* touch <filename> - 新しいファイルを作る
* rm <filename> - ファイルを削除する
* mkdir <dirname> - 新しいフォルダを作る
* cp <src> <dest> - ファイルをコピーする
* openurl <url> - URLをブラウザで開く
* shutdown [--now] - パソコンをシャットダウンする
* help - ヘルプを表示する
* exit - コマンドラインを終了する
* clear - コマンドラインの中身をクリアする
* ls - Display files in the directory(folder)
* cd <path> - Change directory(folder)
* cat <filename> - Display the contents on the command line
* touch <filename> - Create a new file
* rm <filename> - Delete a file
* mkdir <dirname> - Create a new directory(folder)
* cp <src> <dest> - Copy a file
* openurl <url> - Open URL in browser
* shutdown [--now] - Shutdown the system
* help - Show help
* exit - Exit the command line
* clear - Clear the command line

また、コマンドの送信はEnterキーと、Executeボタンでも行えるようにします。
We also allow the command to be sent by the Enter key and the Execute button.

## コマンドを受け付ける仕組み
まず最初に、各コマンドが使われたときに実行する関数を作っておきます。
## Command acceptance mechanism
First, let's create a function to be executed when each command is used.

**def list_files():、def change_directory(path):**
などです。

コマンドは、コマンドを受け付ける関数
**execute_command()**
に引数として入力欄の文字列を渡し、If文でどの関数を呼び出すかプログラムしています。
The command is passed to the function **execute_command()** as an argument, and the program determines which function to call by If statement.

# 実際のプログラム
# Actual program

それでは、こちらが実際にコマンドを組み込んだプログラムになります。
Here is the program with the command integrated.

```python
import os
Expand Down Expand Up @@ -306,19 +306,17 @@ output_text.tag_config('error', foreground='red')
root.mainloop()
```

少し長いプログラムになっていますが、
* コマンドの実行時に今いるフォルダのパスを表示する
* エラーメッセージは赤色で表示する
* シャットダウンのプログラムに即座に行うかどうかのオプションを追加する
* 隠しコマンドとして"python"と打つとアスキーアートが出てくるようにする
It is a little long, but
* Display the path of the current folder when the command is executed.
* Display error messages in red.
* Add an option to immediately shut down the program.
* Add a hidden command to display ASCII art when "python" is entered.

などの要素を加えています。
We have added these elements.

最後にこのプログラムを、
**C:\Users\<ユーザーネーム>**
のフォルダに保存して、デスクトップにショートカットを作れば、プログラムの起動時にコマンドプロンプトと同じディレクトリから始められます。
Finally, save this program in the folder **C:\Users\<USERNAME>**, and create a shortcut on the desktop, so the program will start in the same directory as the command prompt.

# 結論
pythonでも意外とシステムに直結した部分をいじることができました。また、ファイルのパスを指定できたり、ディレクトリの移動ができることには正直驚きました。
# Conclusion
You can do things that are directly related to the system even in Python. I was also surprised that you could specify the file path and move the directory.

PythonOS、ぜひ使ってみてください。
Please try PythonOS if you'd like!
Loading