Programming Rapiro Robot using Simulink

Simulink models for talking to Arduino and Raspberry Pi inside Rapiro
다운로드 수: 1.3K
업데이트 날짜: 2018/1/23

라이선스 보기

Background on Rapiro:
Rapiro is a humanoid robot. Rapiro comes with 12 servo motors one for its neck, one in the waist, four for the legs, and the final six for its two arms. It also has a servo motor controller board that is Arduino compatible. We can program the Arduino and control the motor movements using Simulink. It acts as the spine or the nerve center for the Rapiro.
Rapiro uses the Arduino uno board. It has a processor atmega 328P. However the Arduino uno that Simulink supports should use atmega 328. The Simulink Arduino Servo write/Read library block accepts pin numbers from 0 to 13(This is not the microcontroller pin number, it is the digital pin number you see on the Arduino board).
In the RAPIRO arduino, Pin numbers 14, 15 and 16 are used for Servo functionality which are actually mapped as analog Inputs and pin 17 should be high if we have to send power to the motors. These pins have no direct mapping to the Simulink read/write blocks. So to use those pins please follow the instructions:

Place the ServoPinMapping.mat file in the same folder where RAPIRO Simulink model is placed. This mat file contains MATLAB workspace variables A0, A1 ,A2,A3 initialised to 14, 15 ,16 and 17 respectively.

Open the Simulink model and go to file -> Model Properties ->Callbacks ->Add “load(‘ServoPinMapping.mat’)” in preload function. This will load the mat file in the Matlab workspace. Now you will be able to use pins numbers 14 through 17 in Simulink.

We can use the raspberry pi to act as its brain and the camera to act as its eye. From MATLAB R2014a release we have introduced MATLAB Support Package for Raspberry Pi hardware that provides a command line interface to capture images from the camera. However there is no direct support to use Simulink support package for raspberry pi camera. But there is a very simple workaround to get the Simulink block set to recognize raspberry pi camera. The latest release of the Raspbian Wheezy image has V4L2 drivers for the Camera Board. This means that you can use the V4L2 Video Capture block in the Simulink block library for Raspberry Pi to capture images from the Raspberry Pi Camera Board. Please watch the following webinar to see how to go about configuring the raspberry pi camera.

http://www.element14.com/community/videos/12408/l/how-to-program-a-rapiro-with-simulink

The models that are attached will show you how to use the raspberry pi to detect the green object and to make the Rapiro walk using Arduino.

Simulink Model: RapiroWalk
Description: This model is to make the Rapiro walk and is deployed on the Arduino. It consists of two major blocks called Legs and Leg_Motors. The Legs block provides the input required for the walking motion. The Leg_Motors block consists of servo write blocks that is used to control the speed and rotation of the 4 servo motors.
Required MathWorks products: MATLAB and Simulink release R2014a, or later. Simulink support package for Arduino hardware.

Simulink Model: RapiroGreenBall
Description: This model is to demonstrate the use of Raspberry pi camera to detect a green object in the background. This model is deployed on the raspberry pi. It consists of a video capture block that captures an RGB video. The colorThresholding block to recognize a green object in the background. The block analysis block to detect the presence of blobs i.e. presence of a green object. The draw rectangles block to draw a rectangular bounding box around the detect blob and the video display block to display the RGB video as well as the bounding box on the screen
Required MathWorks products: MATLAB and Simulink release R2014a, or later. Computer Vision System Toolbox. Simulink support package for Raspberry Pi hardware.

The next two models are to make the Arduino and Raspberry Pi communicate with each other
Simulink Model: RapiroRaspFinal
Description: This model is deployed on the Raspberry Pi. To the green ball detection model we add one more block called the GPIO write. As soon as a blob is detected we send a logical value of 1 to the GPIO pin. This pin is connected to the pin 3 of the Arduino
Required MathWorks products: MATLAB and Simulink release R2014a, or later. Computer Vision System Toolbox. Simulink support package for Arduino and Raspberry Pi hardware

Simulink Model: RapiroArduino
Description: This model is deployed onto the Arduino. It consists of a digital input block and is set to pin number 3. This pin of Arduino is physically connected to the GPIO pin of raspberry pi. As soon as the pin turns high a signal is sent to the Arduino which in turn sends commands to motors and thus making the rapiro walk. . As soon as the green ball is taken away from the line of sight of the raspberry pi camera the GPIO pin stops sending data to the Arduino and rapiro stops walking.
Required MathWorks products: MATLAB and Simulink release R2014a, or later. Simulink support package for Arduino and Raspberry Pi hardware

인용 양식

MathWorks Robotics and Autonomous Systems Team (2024). Programming Rapiro Robot using Simulink (https://www.mathworks.com/matlabcentral/fileexchange/47211-programming-rapiro-robot-using-simulink), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2014a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
커뮤니티
 Power Electronics Control 커뮤니티에 더 많은 파일이 있습니다

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.1

Clarified requirement for Computer Vision System Toolbox for two of the examples.
Updated license

1.0.0.0