Skip to content

Python IndyDCP2 클라이언트

python IndyDCP2 client 는 IndyDCP2 Protocol(TCP/IP) 을 기반으로 Indy 를 제어할 수 있는 python class 입니다.

설치

python IndyDCP2 client 파일은 아래 터미널 명령을 통해 받을 수 있습니다.

pip3 install --upgrade pip
pip3 install neuromeka

Indy와의 연결 및 연결 해제

Indy 와의 모든 통신은 neuromeka 패키지에 선언되어 있는 IndyDCP2 클래스를 통해 수행할 수 있습니다. IndyDCP2 객체를 초기화하기 위해서는, Indy 의 모델명과 IP 주소를 입력해야 합니다.

주의

  • IndyDCP2 는 Client 중복 접속이 불가능하기 때문에 사용을 완료한 뒤에는 다음 접속을 위해 disconnect() 를 호출 해 연결을 종료해야 합니다
from neuromeka import IndyDCP2

step_ip = "192.168.0.100" # 연결한 로봇의 IP 주소
robot_name = "NRMK-Indy7" # 연결한 로봇 이름

indy = IndyDCP2(step_ip,robot_name)

indy.connect()

////////////////////////////
// Indy 작업이 들어갈 부분 //
///////////////////////////

indy.disconnect()

Python IndyDCP2 명령어 리스트

아래는 IndyDCP 전체 명령어 중 일부에 대한 사용 예시들을 나타냅니다.

함수 기능
stop_emergency(self) 비상정지 실행
reset_robot(self) 로봇 리셋
set_servo(self, arr) arr 값에 따라 서보 On/Off
set_brake(self, arr) arr 값에 따라 브레이크 On/Of
stop_motion(self) 로봇 모션 중지
go_home(self) 홈 포지션으로 이동
go_zero(self) 제로 포지션으로 이동
joint_move_to(self, q) 모든 관절 각도를 q의 값으로 이동
joint_move_by(self, q) 모든 관절 각도를 q의 값 만큼 상대적으로 이동
task_move_to(self, p) 로봇 엔드 이펙터를 p의 6 자유도 위치로 이동
task_move_by(self, p) 로봇 엔드 이펙터를 p 의 6 자유도 값 만큼 상대적으로 이동
start_current_program(self) 현재 로드된 로봇 프로그램 실행
pause_current_program(self) 현재 현재 실행중인 프로그램 일시정지
resume_current_program(self) 현재 일시정지된 프로그램 재개
stop_current_program(self) 현재 프로그램 중지
direct_teaching(self, mode) mode 에 따라 직접교시 On/Off
movec(self, via_p, end_p) via_point 와 end_point 를 이용하여 cirle 이동
set_movec_angle(self, angle) moveC 이동시 이동할 각도 설정
set_movec_vel(self, velocity) moveC 이동시 이동할 속도 설정
set_movec_acc(self, acceleration) moveC 이동시 이동할 가속도 설정
start_teleop(self, mode) mode 에 따라 TeleOperation 실행
stop_teleop(self) TeleOperation 정지
tele_movej(self, q) 모든 관절 각도를 q의 값으로 이동
(동작하고 있는 TeleOP Mode 에 따라 절대, 상대 움직임)
tele_movel(self, p) 로봇 엔드 이펙터를 p의 6 자유도 위치로 이동
(동작하고 있는 TeleOP Mode 에 따라 절대, 상대 움직임)
set_default_tcp(self, tcp) 기본 TCP값을 tcp 로 설정
active_sdk(self, key, date) sdk 를 keydata 로 활성화
set_custom_control_mode(self, mode) custom control 을 mode 로 활성화
get_custom_control_mode(self) 현재 적용된 custom control 모드를 가져오기
get_control_torque_jts(self) 현재 관절 토크 센서 값을 가져옵니다.
get_control_torque_jts_raw1(self) 현재 관절 토크 센서 raw_1 값을 가져옵니다.
get_control_torque_jts_raw2(self) 현재 관절 토크 센서 raw_2 값을 가져옵니다.

간단한 모션 예제

이 장에서는 간단한 로봇 동작을 하는 예제를 소개합니다. 홈위치로 이동 한 뒤 Int 0 변수에 0이 아닌 값이 들어 올 때 까지 대기 후 0이 들어오면 현재 위치로 부터 모든 joint 값을 10도씩 움직여줍니다. 해당 모션이 끝나면 다시 홈위치로 이동합니다. 명확한 예시를 위해, 로봇은 Indy7, IP 주소는 192.168.0.100 로 가정합니다.

Warning

코드를 실행할 경우 로봇이 움직입니다. 로봇 주변의 공간을 비워 주세요!
from neuromeka import IndyDCP2

step_ip = "192.168.0.100" # 연결한 로봇의 IP 주소
robot_name = "NRMK-Indy7" # 연결한 로봇 이름

indy = IndyDCP2(step_ip,robot_name)

indy.connect()

indy.go_home()# 홈위치 이동
indy.wait_for_move_finish() # 모션 완료 대기
while True:
    if indy.get_int_val(0) : #Int 0 변수에 값이 들어오는것 확인
        indy.joint_move_by([10,10,10,10,10,10]) # 모든 조인트를 +10° 상대 이동
        indy.wait_for_move_finish() #모션 완료 대기
        break
indy.go_home() # 홈위치 이동
indy.wait_for_move_finish() # 모션 완료 대기

indy.disconnect()