This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

*/

밀리 초, 마이크로 초

시간 단위

ms, msec : milli-second, 10−3, 1/1,000 초
μs : micro-second, 10−6, 1/1,000,000 초 
ns : nano-second, 10−9, 1/1,000,000,000 초 


Linux 버전 확인

리눅스에서 버전 확인 하기

커널 확인

user@system:~$ uname -a
 

user@system:~$ cat /proc/version
 

배포판 정보 확인
user@system:~$ cat /etc/*release*
 

Python - Bytes, bytearray vs c struct variable

Python에서 bytes, bytearray 를 다룰 때 참고

Format string - Byte order, size, alignment

기본적으로 C 유형은 시스템의 기본 형식 및 바이트 순서로 표시
첫 번째 문자가 이들 중 하나가 아니면 '@'으로 가정
네이티브 바이트 순서는 호스트 시스템에 따라 big-endian 또는 little-endian으로 구분. 예를 들어 Intel x86 및 AMD64 (x86-64)는 little-endian.  Motorola 68000과 PowerPC G5는 big-endian



Format character



Example

>>> from struct import *
>>> pack('hhl', 1, 2, 3)
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> unpack('hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)

>>> pack('<hhl', 1, 2, 3)
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> pack('>hhl', 1, 2, 3)
b'\x00\x01\x00\x02\x00\x00\x00\x03'

>>> unpack('<hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)
>>> unpack('>hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(1, 2, 3)

Windows PC에서 endian을 지정하지 않고 했을 경우 => 네이티브로 판단하여 intel계열의 little-endian 으로 출력

>>> pack('hhl', 1, 2, 3) # Native'@'를 지정한 것으로 처리
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> unpack('hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)


Little-endian vs Big-endian

>>> pack('<hhl', 1, 2, 3)           # little-endian
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> pack('>hhl', 1, 2, 3)           # big-endian
b'\x00\x01\x00\x02\x00\x00\x00\x03'

>>> unpack('<hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')     # little-endian
(256, 512, 50331648)
>>> unpack('>hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')     # big-endian
(1, 2, 3)



Python - Type Error

Python에서 아래와 같은 오류가 발생할 경우

A Bytes-Like Object Is Required, Not ‘Str'

  bytes-likes 오브젝트가 필요하니 str 타입 말고 bytes 타입의 변수를 넣으라는 의미로 라이브러리등을 사용하다 보면 주로 발생하고 string type 과  bytes 타입은 아래와 같은 상관 관계가 있다.

str –> 디코딩 –> bytes

bytes –> 인코딩 –> str

text = "Hello"    
text_byte = text.encode('utf-8')
text_str = text_byte.decode('utf-8')
text_byte = "Hello".encode('utf-8')


참고


Python - VS Code에서 Qt Designer로 GUI 개발

VS Code에서 작업할 디렉토리를 선택(여기서는 test01폴더)하고 오른쪽 마우스를 클릭한다.
팝업 메뉴의 제일 아래쪽 PyQT: New Form을 선택하면 Qt Designer가 실행 된다.

새 폼(New form) 창이 뜨며 아래 5가지 Form 중에서 하나를 선택할 수 있다
  • Dialog with Buttons Bottom  - Dialog 타입, OK, Cancel 버튼이 하단 오른쪽에 위치
  • Dialog with Buttons Right - Dialog 타입, OK, Cancel 버튼이 오른쪽 상단에 위치
  • Dialog without Buttons - Dialog 타입, 버튼 없음
  • Main Window - Main window 타입, 상단에 메뉴바, 하단에 상태바
  • Widget - Widget 타입




 


참고

VS Code에서 Python 과 Qt5 사용하기

설치환경

  • OS : Windows 10
  • Python version : 3.7.9

설치순서

  1. CMD 실행
  2. 프롬프트상에 pip install qt5-tools 입력

  3. 설치된 PyQt의 버전을 확인 pip show pyqt5 입력
  4. vscode를 실행
  5. Extentions(Ctrl+Shift+X)에서 PyQt integration을 찾아 install

  6. vscode에서 새로운 파일(test.py)을 만들고 아래 코드를 넣는다.
    import sys
    from PyQt5.QtWidgets import QApplication, QWidget

    class MyApp(QWidget):

        def __init__(self):
            super().__init__()
            self.initUI()

        def initUI(self):
            self.setWindowTitle('My First Application')
            self.move(300, 300)
            self.resize(400, 200)
            self.show()


    if __name__ == '__main__':
       app = QApplication(sys.argv)
       ex = MyApp()
       sys.exit(app.exec_())
  7. 화면 오른쪽 상단의 삼각형 버튼을 눌러 코드를 실행한다.
  8. 화면 상에 창이 만들어졌는지 확인한다.

참고자료

ROBOT ARM 만들기

6축 로봇팔

  로봇팔에 대한 자료를 보고 한번 만들면서 공부해 보자는 생각에 자료를 정리한다. open source로 진행된 로봇 팔에 대한 아래와 같은 여러 자료들이 있다.
위에서 나온 대부분의 모델들은 3D 프린터를 이용하여 부품들을 인쇄하여 제작하도록 구성되어 있다.


사전 준비 사항

  • 3D 프린터 :  22x22 cm 이상 인쇄할 수 있는 프린터. 현재 보유하고 있는 델타 프린터로는 크기가 큰 부품들을 인쇄할 수 없어 새로운 Cartesian 타입(직교 타입)의 프린터를 만들었다.