Archives

[ev3]Software Launch Problem

[Problem]
When EV3 software was launched, it crashed on OS X.
EV3 Software를 실행시켰는데, 뭔가 실행되는 듯하다가 바로 꺼져버렸다.

[Hints]
MS Silverlight에 의한 문제일 수 있다.
The error is caused by the underlying MS Silverlight runtime.

[Solution]
1. Remove the installed Silverlight(설치된 silverlight를 제거한다.)
[shell]$ cd /Library/Internet\ Plug-Ins/
$ sudo rm -rf Silverlight.plugin/[/shell]
2. Install the latest Silverlight (최신 Silverlight를 설치한다.)

spacer

[EV3]wiimote.py 해설

[목표]
레고 마인드스톰 EV3로 만든 로봇을 wii remote로 조종하기

[준비물]
– Lego EV3 robot
– wii remote
– ev3dev가 설치된 microSD (설치방법은 ev3dev 설치)
– {shell}python-cwiid{/shell} 패키지(HowTo: Python Wiimote fun)가 필요함 (설치방법은 {shell}apt-get install python-cwiid{/shell}로 설치해야 함)
– 그리고 아래와 같은 파이썬 코드

[python]
# wii remote로 로봇을 조종하기 위한 전제 조건
# 1. 왼쪽 모터는 B 포트에, 오른쪽 모터는 C 포트에, 팔을 구동할 모터는 D포트에 연결되어 있어야 함
# 2. ‘python-cwiid’ 패키지가 필요함
# 3. 블루투스가 켜있어야 함
# 4. wii remote의 2번 버튼을 누르고 있으면 전진, 1번 버튼을 누르고 있으면 후진함

# Drive your robot with a wii remote!
# Left motor on port B, right motor on port C,
# vertical arm on port D.
# Requires the package ‘python-cwiid’.
# Make sure bluetooth is enabled in brickman
# before trying to use this. Hold 2 to go forward
# and 1 to go backward.

import time

import cwiid
import pyev3

def clamp(value, lower, upper):
return min(upper, max(value, lower))

print ‘press 1+2 on the wiimote now’
time.sleep(1)
w = cwiid.Wiimote() #wiimote제어를 가져온다.
print ‘connected?’
w.led = 6
w.rpt_mode = cwiid.RPT_ACC | cwiid.RPT_BTN

left_motor = pyev3.Motor(pyev3.OUTPUT_B) #좌측모터 제어를 가져온다.
left_motor.reset()
left_motor.run_mode = ‘forever’
left_motor.regulation_mode = ‘on’

right_motor = pyev3.Motor(pyev3.OUTPUT_C) #우측무터 제어를 가져온다.
right_motor.reset()
right_motor.run_mode = ‘forever’
right_motor.regulation_mode = ‘on’

arm = pyev3.Motor(pyev3.OUTPUT_D)
arm.reset()
arm.run_mode = ‘forever’
arm.regulation_mode = ‘off’

target_distance = 8
top_speed = 720

left_motor.run = 1
right_motor.run = 1

last_btn_state = 0
move = 0

try:
while True: #무한루프 시작
state = w.state

buttons = state[‘buttons’]
if buttons != last_btn_state:
if buttons & cwiid.BTN_MINUS:
top_speed -= 10
print top_speed
if buttons & cwiid.BTN_PLUS:
top_speed += 10
print top_speed
if buttons & cwiid.BTN_2:
move = 1
elif buttons & cwiid.BTN_1:
move = -1
else:
move = 0
if buttons & cwiid.BTN_LEFT:
arm.duty_cycle_sp = 100
arm.run = 1
elif buttons & cwiid.BTN_RIGHT:
arm.duty_cycle_sp = -100
arm.run = 1
else:
arm.run = 0
print top_speed, move
last_btn_state = buttons

if move:
acc = state[‘acc’]
tilt = (clamp(acc[1], 95, 145) – 120) / 25.0 # roughly between -0.5 and 0.5
turn = top_speed * tilt
turn = clamp(turn, -abs(top_speed), abs(top_speed))
left_motor.pulses_per_second_sp = int(top_speed – turn) * move
right_motor.pulses_per_second_sp = int(top_speed + turn) * move
else:
left_motor.pulses_per_second_sp = 0
right_motor.pulses_per_second_sp = 0
finally:
left_motor.run = 0
right_motor.run = 0
[/python]

[더 읽을거리]
ev3dev 설치

spacer

EV3에 ev3dev를 설치하다

선택 이유
– firmware가 아니다.
– linux이다.
– microSD(32GB이하 짜리를 이용해야 함. 이를 초과하면 인식하지 못함)에 설치한 다음, 꽂기만 하면 된다.

설치 순서(Getting Started with ev3dev)
1. 디스크 이미지 파일을 내려 받는다.
https://github.com/ev3dev/ev3dev/releases
여기에는 LEGO MINDSTORMS EV3({shell}ev3-{/shell}로 시작하는 파일 선택), Raspberry Pi({shell}rpi-{/shell}로 시작하는 이미지 파일 선택)와 Raspberry Pi 2({shell}rpi2-{/shell}로 시작하는 이미지 파일 선택)를 위한 것도 있다.
2. 디스크 이미지를 microSD에 옮긴다.
http://www.ev3dev.org/docs/tutorials/writing-sd-card-image-mac-command-line/
3. microSD를 ev3에 꽂고 작동시킨다.
처음 부팅할 때는 시간이 많이 걸린다.
4. ev3와 통신할 수 있도록 한다.
Connecting to the Internet via Bluetooth
user : robot
default passwd : maker
따라서 접속한 다음, {shell}passwd{/shell}명령어를 이용해서 비밀번호를 바꾸는 것이 좋다.

5. 통신을 통해서 프로그램을 설치하거나, 파일을 옮길 수 있다.

프로그램 실행하기
python 프로그램을 실행시키기 위해서는 셀스크립트를 만들어서 실행시킨다.(출처:Launch programs from brickman)
[shell]#!/bin/bash
python program.py[/shell]

spacer

Lego MindStorms

1. MindStorms이란?
WikiPedia

1) RCX
programming
Using LEGO Mindstorms RIS (RCX) KIT with Windows7
2) NXT 1.0 / NXT 2.0
Extreme NXT
종류와 차이점
종류와 차이(요약)
3) EV3
Lego Mindstorms EV3
YouTube 동영상 모음
PopSci
Hack Education

2. 마케팅 관련 글
해킹과 마케팅

3. 구입전 읽은 글들
1) 송은정씨 블로그
2) 레고 에듀케이션

4. 국내 판매처
1) 가가토이

5. Blog
LEGO Mindstorms NXT/RCX Sensor Input Page
thenxtstep

spacer