Hacking Roomba - Tod E.Kurt Part 8

Tham khảo tài liệu 'hacking roomba - tod part 8', kỹ thuật - công nghệ, cơ khí - chế tạo máy phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 192 Part II Fun Things to Do The implementation is straightforward the main hurdle is conceptual as you re using Roomba driving data without commanding the robot to move. Instead of simply drawing lines as pixels onto the screen an array of Line objects is created. Each Line holds an array of points that define the line. Each time draw is called determined by framerate the current line is added if the Spot button is being held down. Each press and release of the Spot button creates a new Line object and thus a new line to be drawn. Listing 10-1 RoombaSketch Line lines new Line numlines int l 0 int strokeW 5 void draw computeRoombaLocation same as before parseRoombaSensors updateRoombaState background 180 stroke 0 for int i 0 i numlines i lines i .draw translate rx ry rotate rangle image rpic -20 -20 void parseRoombaSensors if 0 if rx width 2 ry height 2 rangle 0 strokeW 5 if strokeW -- if strokeW 1 strokeW 1 if strokeW if strokeW 100 strokeW 100 if if drawing if rx rxo ry ryo lines l .addPoint int rx int ry strokeW else drawing true l l numlines lines l new Line Chapter 10 Using Roomba as an Input Device 193 Listing 10-1 Continued else if drawing drawing false Figure 10-2 shows how you might hold Roomba and draw with it while Figure 10-3 shows a drawing made with RoombaSketch. The ability to change the pen stroke width while drawing enables a much more fluid line than is possible with a normal mouse. You can create very organic drawings. Granted as Figure 10-2 shows using Roomba as a mouse requires a bit more physical movement than with a normal mouse but with some people complaining that computer users don t get enough exercise you can now point to the Roomba and say That s my mouse. Figure 10-2 Using Roomba as a mouse 194 Part II Fun Things to Do Figure 10-3 A drawing made with RoombaSketch Using Roomba as a Theremin The .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.