ラベル Robot OS の投稿を表示しています。 すべての投稿を表示
ラベル Robot OS の投稿を表示しています。 すべての投稿を表示

2013年1月28日月曜日

My robot developing environment

最近、ストレス発散にブログを書く様になってしまいました。とにかく、まったく違う作業をするのは、ストレス発散です。


上の図は、自分の管理用の使っている変な図ですが、、、、

現在、3台のIntel CPUマシンと、8台のRaspberry Pi、Xtion, Kinect, Webcam 、Driver, 沢山のセンサー、サーボそしてモータで開発しています。ぐちゃぐちゃです。
それに、覚える事も多くて、、、、つらい。。。
まずは、システム系の開発と、4足歩行のメカニズム開発を先行させています。(車輪駆動は開発終了しました。あとは実機の組み立てだけです)

僕の場合は、「農作業工程を自動化する」その為に必用な「15万円のトマト収穫機を創り運用する」と言う発想が原点です。それが、全ての悪戦苦闘の始まり。
特に、ロボット開発の効率化を考えて、自分でロボット開発/運用の統合プラットフォームRDCSも作り出したもんだから、もう大変です。
通常は、ROSを使うべきです。でも、こういうのを一から作る事に、無類の喜びを感じてしまうのです。
ただ、RDCSは、ロボットを使った業務運用の統合管理の方の比重が高いので、ROSとはやっぱり大分違うと思います。

上図の下側は、Service Nodeで、比較的高性能なIntel系PCで、画像認識などの処理をロボットからの依頼で実施している。また、4DS(空間DB)などの共通情報もService Nodeで処理をする。課題は、ずばり「トマト認識」と「実時間処理」です。でも、12個/分のトマト収穫の為に必要なService処理は達成できそうです。まずは、ロジックがきちんとできれば良いでしょう。今年1年かけて、農場でトマト認識機能は改善します。
ハードは、年々高性能で安くなるのですから、、、、
Android端末も、ArchLinuxでサックと動かしたい。そうしたらもっと楽しいのに、、、、


8台のRaspberry Piは、夜になると怪しく赤く光ります。何かを待つかのように

peace!

2013年1月6日日曜日

What's RDCS?

We're going to release RDCS on April in 2014.

Goal
My goal is an automation of farming. 

Cooperative work with workers and robots
In order to automate many tasks of farming, I need some dozen robots.
But my budget is small. 
I decided to develop low cost robots by myself.  So I use  Raspberry Pis  and cheap outlet devices.
And I thought it was necessary the management system to operate some dozen robots. In addition, it must be a system that can assist in coordinating the work of workers and robots in my farm. I decided to develop the system that support a cooperative work with workers and robots.

 "RDCS" is an abbreviation of ”Robot Distributed cooperative System".
RDCS offers  the cooperative work space which share to work with workers and robots  in their  work-place. Therefore, RDCS manages the  some dozen low cost robots for a farming based on RDCS Work Definition Control.

My most priority of developing RDSC is the Safety of worker.
In the cooperative environment of worker and robots, the Safety of worker is the most important  matter. RDCS realize the Safety environment for worker and robots.
RDCSは、人とロボットが”安全に”協調して働く空間を提供します。その為に、RDCSは、WDCに基づいて多くの低コストロボットを制御します。RDCSにおいては、安全を全てにおいて最優先しています。

RDCS realizes the environment that low cost  robots can use high performance resource on network such as image processing service, space recognizing service and more.
Because of this, low cost robots can have high level functions.
And RDCS offers the integrated control to manage some dozen autonomous robots. 
Also, RDCS provides functions to support a cooperative work between workers and robots.

I understand that  to develop RDCS is very difficult to me.
But I love to create a new technology, because I am an engineer.
Challenge!
I believe that  the creation is the nature of humanity.     v(^o^)v





RDCSは、一連の作業を人と自律型ロボットが協調して行う事をサポートする統合運用管理システムです。もちろん、ロボット開発プラットフォームにもなりますが、元々の発想は運用重視からです。
単体のロボットだけでは、なにもできません。人と多くのロボットが協調して作業できなければ、ロボット導入の意味はありません。こういう、発想の研究がないんですよね。それは、至極当然かもしれません。
私は、組織の知識創造の研究をし、分析・構築メソッドや、知識創造支援システムなどの製品を開発しました。多くの大手企業に導入されて使われています。そのベースになった「組織活動プロセスモデル」を改良した新たなモデルをベースに「作業安全を重視した人とロボットの協調作業プロセス・環境のデザインと、マネジメントシステム」の開発をしています。モデルがなければ、デザインが出来ないし、デザインが出来なければ、PDCAが回せないので、改善できません。PDCAを回して、改善すると言う考え方は、日本の研究機関にはない考え方でしょう。
この様な視点には、学際的なアプローチや、実際のマネジメントの経験が必要となります。
私は、幸いな事に社会科学、経営学、工学、そしてコンピュータの分野を理解しており、かつマネジメントもしていたので、それらの経験が役立っているのだと思います。

ところで、近年の日本のコンピュータサイエンスが、どのような成果を産み出しているのか知りません。しかし、依然、新しいコンピュータ製品、ソフトの大半が海外製である事を考えれば、、、、、、
そして、Raspberry Piの開発動機の一つが、「イギリスのコンピュータ科学の学生の質が落ちたから」と言う事だそうです。日本は、どうなんでしょうか? また、学生だけなのでしょうか?

peace!

2012年10月3日水曜日

Performance testing Xtion on Raspberry Pi
Using a capturing server

Raspberry Pi is a good machine. But it don't have a capacity for 3D processing.  For this test, I use a Raspberry Pi as a capturing service (server).  And MacMini is 3D Processing service and viewing.
My test environment diagram is below.

Raspberry Piは、3D処理をするには性能がたりません。従って、Xtionを使ったcaputuring setverとして使い、空間認識などの処理をMacminiで処理します。そのテストをしました。
テストは、RDCS環境を使いまいた。RDCSは、分散コンピューティングをベースにしたロボットプラットフォームです。その機能を使ってテストをしました。
Micminiでpoint cloud処理をしています。さすがに瞬間的な処理です。


 Capturing Service        3D recognizing service
   Xtion
    Raspberry Pi                Mac MIni
----------------------------------------------------  Coordinator Layer
---------------------------------------------------- (Service Control)
             |                                |
----------------------------------------------------      Cooperative Layer
---------------------------------------------------- (Communication Control)

A performance testing was executed on RDCS.

RDCS is a robot platform based on a distributed computing model.
A lots of robot function (hardware, software) is connected by  "Cooperative Control" and "Coordinator".
"Cooperative Control" is a network communication control.  The control  connects computer , actuator, sensor and other robot device.
"Coordinator" offers robot required software. "Coordinator" integrates a lot robot software on RDCS.

This test flow is :

(1) 3D recognized service requests a data set ( image and depth ) to Capturing service.
(2) Capturing service on Raspberry Pi execute to capture image and depth.
(3) 3D recognized service receive a couple of capturing data.
(4) 3D processing and viewing

RESULT (sec)
(1)      0-1
(2)     8-10 (include the time which is Xtion initialize and terminate)
                   A Capture time is 1-2 sec.
(3)      0-1
(4)      0-1


This result means that a single robot don't have all function in it.
Therefore, it's able to develop a lightweight and low cost robot.
There are a lot of kinds wrok in farm. And my farm is large. Thus I need  a lot of robot. To do that,  I have to develop a low cost and multi-function robot.
My robots are structured by base robot and add-in function in order to realize a multi-function of robot.
And these robots have to been set up by commercialized product and builded  by component-based.

Now I'm developing a core component of robot  using 2 or 3 Raspberry Pi.
A core component of robot is structured by  6 components which are robot platform(RDCS), space recognition, obstacle detection, moving, fail-safe and recovery.
An effectivity of RDCS which I have developed was  confirmed by this testing.


この結果は、1台のロボットに全ての機能を集約しなくても良い事を示しています。
従って、軽量なかつ低価格のロボットを作る事ができます。
ロボットプラットフォーム、障害物検知、通信、移動、フェイルセーフと回復機能を持ったシンプルなロボットを、Raspberry Piを2、3個使って作れば良いと思います。その上に、アクチュエータなどのロボットのパーツを載せればよのではないでしょうか?
私の開発している、RDCSのアーキテクチャーの有効性を確認できました。




                                                     3D point cloud

Peace!

2012年9月28日金曜日

Performance testing Xtion on Raspberry Pi
Capturing RGB

Yesterday, I had done a performance testing.
A test program attached this post.
It's a processing time  from capturing  a  RBG data via OpenNI -Xtion  to writing a formated data.

A test path is below.
Xtion -> OpenNI (RGB, Depth) -> OpenCV (conversion format, writing) -> SD-card

(1)Capturer : 640x480, RGB24
(2)Pieces of writing format type are bmp, dib, jpd, jp2, png, pbm, pgm, ppm, ras, and tiff.

RESULT
(1) It's take 15-20 sec from capturing to writing SD-card.
        processing             time (sec)
     Initialize OpenNI            : 4 - 5
     Capture depth & RBG  : 0 - 1
     Merge                           : 3 - 4
     Convert & save            : 4 - 5
     Terminate                     : 4 - 5
     ( Processing time on MacMini (i5 2.5GHz 8G) is 2sec. )
   
(2) Processing time depends data format a little.
     Jpeg format is faster than png, 2-3 seconds.
(3) There aren't a difference  of processing time between clock speed 700MHz and 800MHz.

Next performance testing is a following process.
Capture (Raspberry Pi) ---  depth & RGB  (UDP) --> Receive (other machine).
This test use a function of Cooperative control of RDCS.

Peace!

/*****************************************************************************************
        Sample snapshot & save  program   (No Warranty)
******************************************************************************************/
OpenNI  1.5.4
Sensor  5.1.2.1
OpenCV 2.4
Xtion Pro Live

(1) Raspberry Pi  800MHz and 700MHz
Arch Linux arm 3.2.27-8-ARCH+
gcc (GCC) 4.7.1 20120721
It need a compiler option "-mcpu=arm1176jzf-s".

(2) Macmini
Darwin Kernel Version 12.2.0
llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658)

(3) Windows
No test.

//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <XnOS.h>
#include <opencv2/opencv.hpp>
#include <XnCppWrapper.h>
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>

#include <stdio.h>
//#include <stdlib.h>
#include <time.h>
#include <math.h>

using namespace std;
using namespace xn;
using namespace cv;
//---------------------------------------------------------------------------
// Defines
//---------------------------------------------------------------------------
#define SAMPLE_XML_PATH "../../Config/SamplesConfig.xml"

//#define PR1(A)
//#define PR2(A, B)
#define PR1(A) std::cout << A << endl;
#define PR2(A, B) std::cout << A << ":" << B << endl;
#define ER1(A) std::cout << A << endl;
#define ER2(A, B) std::cout << A << ":" << B << endl;

//---------------------------------------------------------------------------
// Globals
//---------------------------------------------------------------------------
XnStatus nRetVal = XN_STATUS_OK;

float* g_pDepthHist;
XnRGB24Pixel* g_pTexMap = NULL;
unsigned int g_nTexMapX = 0;
unsigned int g_nTexMapY = 0;
XnDepthPixel g_nZRes;

Context g_context;
xn::ScriptNode g_scriptNode;
xn::DepthGenerator g_depth;
xn::ImageGenerator g_image;
xn::DepthMetaData g_depthMD;
xn::ImageMetaData g_imageMD;


cv::Mat colorArr[3];
cv::Mat colorImage;

const XnRGB24Pixel* pImageRow;
const XnRGB24Pixel* pPixel;

void printTime(const char *msg) ;

//---------------------------------------------------------------------------
// Code
//---------------------------------------------------------------------------

/************************************************************************
*** Callback glutIdle
*************************************************************************/
void printTime(const char *msg) {
time_t timer;
struct tm *date;
char str[256];

timer = time(NULL);
date = localtime(&timer);
PR2(msg, asctime(date));
}
/************************************************************************
*** main
*************************************************************************/

int main(int argc, char* argv[])
{
XnStatus rc;
EnumerationErrors errors;
IplImage bgrIpl;
cv::Mat bgrImage;
int i, iFrame, iClean;
int iCnt = 0;

char framenumber[10];
std::stringstream ss;
std::string str_frame_number;



// -------------------------------------------------------------------------
// check argument.
// -------------------------------------------------------------------------
if (argc != 4) {
PR1("argument error. output file, format (jpg, png), count.");
return 1;
}
iFrame = atoi(argv[3]);
if (iFrame < 1 || iFrame > 100) {
ER1("frame 1-100.");
return 1;
}
if (!(strcmp(argv[2], "bmp") == 0 ||
strcmp(argv[2], "dib") == 0 ||
strcmp(argv[2], "jpg") == 0 ||
strcmp(argv[2], "jp2") == 0 ||
strcmp(argv[2], "png") == 0 ||
strcmp(argv[2], "pbm") == 0 ||
strcmp(argv[2], "pgm") == 0 ||
strcmp(argv[2], "ppm") == 0 ||
strcmp(argv[2], "ras") == 0 ||
strcmp(argv[2], "tiff") == 0
)) {
ER1("format error.");
return 1;
}

// -------------------------------------------------------------------------
// set up OpenNI camera.
// -------------------------------------------------------------------------
// read a device configuration file and initialyze
rc = g_context.InitFromXmlFile(SAMPLE_XML_PATH, g_scriptNode, &errors);
if (rc == XN_STATUS_NO_NODE_PRESENT){
XnChar strError[1024];
errors.ToString(strError, 1024);
ER1(strError);
return (rc);
}else if (rc != XN_STATUS_OK){
ER2("Open failed ", xnGetStatusString(rc));
return (rc);
}

// Searches for an existing created node of a specified type and returns a reference to it.
rc = g_context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_depth);
if (rc != XN_STATUS_OK){
ER1("No depth node exists! Check your XML.");
return 1;
}

// Searches for an existing created node of a specified type and returns a reference to it.
rc = g_context.FindExistingNode(XN_NODE_TYPE_IMAGE, g_image);
if (rc != XN_STATUS_OK){
ER1("No image node exists! Check your XML.");
return 1;
}

PR1("first genelation*******************");
g_depth.GetMetaData(g_depthMD);
g_image.GetMetaData(g_imageMD);
PR1("***********************************");

// Hybrid mode isn't supported in this sample
if (g_imageMD.FullXRes() != g_depthMD.FullXRes() || g_imageMD.FullYRes() != g_depthMD.FullYRes()){
ER1 ("The device depth and image resolution must be equal!");
return 1;
}

// RGB is the only image format supported.
if (g_imageMD.PixelFormat() != XN_PIXEL_FORMAT_RGB24){
ER1("The device image format must be RGB24");
return 1;
}

// Texture map init
g_nTexMapX = (((unsigned short)(g_depthMD.FullXRes()-1) / 512) + 1) * 512;
g_nTexMapY = (((unsigned short)(g_depthMD.FullYRes()-1) / 512) + 1) * 512;
g_pTexMap = (XnRGB24Pixel*)malloc(g_nTexMapX * g_nTexMapY * sizeof(XnRGB24Pixel));

g_nZRes = g_depthMD.ZRes();
g_pDepthHist = (float*)malloc(g_nZRes * sizeof(float));

rc = g_context.WaitAnyUpdateAll();
if (rc != XN_STATUS_OK){
ER2("Read failed ", xnGetStatusString(rc));
return 1;
}
// -------------------------------------------------------------------------
// main routine.
// -------------------------------------------------------------------------

for (i = 0; i < iFrame; i++) {
printTime("start generation");
g_depth.GetMetaData(g_depthMD);
g_image.GetMetaData(g_imageMD);
printTime("end generation");
}

printTime("start output");
g_depth.GetAlternativeViewPointCap().SetViewPoint(g_image);
pImageRow = g_imageMD.RGB24Data();

colorArr[0] = cv::Mat(g_imageMD.YRes(), g_imageMD.XRes(),CV_8U);
colorArr[1] = cv::Mat(g_imageMD.YRes(), g_imageMD.XRes(),CV_8U);
colorArr[2] = cv::Mat(g_imageMD.YRes(), g_imageMD.XRes(),CV_8U);

printTime("create new matrix");
PR2("g_imageMD.YRes", g_imageMD.YRes());
for (int y = 0; y < g_imageMD.YRes(); y++){
pPixel = pImageRow;
uchar* Bptr = colorArr[0].ptr<uchar>(y);
uchar* Gptr = colorArr[1].ptr<uchar>(y);
uchar* Rptr = colorArr[2].ptr<uchar>(y);
for(int x=0; x < g_imageMD.XRes() ;++x , ++pPixel){
Bptr[x] = pPixel->nBlue;
Gptr[x] = pPixel->nGreen;
Rptr[x] = pPixel->nRed;
}
pImageRow += g_imageMD.XRes();
}
printTime("start merge");
cv::merge(colorArr, 3, colorImage);

printTime("start save");
sprintf(framenumber,"%s.%s",argv[1], argv[2]);
ss << framenumber;
ss >> str_frame_number;
std::string str_aux = str_frame_number;
bgrIpl = colorImage;
cvSaveImage(str_aux.c_str(), &bgrIpl);
printTime("end output");
//g_context.Shutdown();

return 0;
}

2012年9月24日月曜日

Xtion vs Kinect, which is the best Robot EYE


The purpose of introducing robots into farming is to improve productivity through reducing labor and other cost. My robots have  to work without the help of farmers.
Therefore my robots must have  self-control feature. I think the most important technology to acquire self-control is to recognize the space. This technology is base on  space 3D scanning and 3D recognition.
To develop the technology, I did a lot of experiments with  Xtion and Kinect. I decided to adopt Xtion from the results of the experiment.
(1) small and light
(2) bus power
(3) near mode
(4) cross platform (Arch Linux, Ubuntu, OSX, WindowsXp)
(5) cooperative with OpenCV and PCL
(6) commercial use free

私は、実際に業務で使えるロボットを開発したと考えています。
それは、人件費の削減を通じた生産性の向上をはたすものでなければなりません。
そのようなロボットを実現ためには、空間認識が最も重要な技術であると考えています。その為に、3Dスキャナーとして、XtionとKinectを実験してきましたが、ロボットに適しているのは、Xtionという結果を得ました。

Xtion and Kinect


2012年9月21日金曜日

Developing Robots on Raspberry Pi
 Raspberry Piを使ったロボット開発の考え方


I use Raspberry Pi as robot controllers based on Robot Distributed Computing System  (RDCS). RDCS is an architecture to develop a robot system efficiently and simply.
An agricultural work is a combination of variety of tasks. In large farms, only one robot cannot execute many agricultural tasks. Therefore, we have to control many robots and sensors. For this purpose, we designed  RDCS that is a new robot system architecture. RDCS offer one cohesive integrated control for robots, sensors and variety  of agriculture informations.
RDCS have a databese called 4DS.  4DS is a 4 Dimension database. 4 Dimension data is a very important data for agriculture. 4DS  manage   variety information to require for agricutural production . For example,  geospatial data, growing data, cost data, other many data.
Robots use 4DS information as self-control data, and store a variety of data that is scanned  by robots in work.


Raspberry Pi は、いろいろな所で取り上げられているので、ここでは私のrobot開発における利用方法の概要を記述します。

私のロボットは、「分散コンピューティング上にハードウェアを置く」と、いう考え方で作っています。
これは、これまでのハード中心のロボット作りとは、考え方がまったくことなります。しかし、実際の農場での運用を考えると、そのような考え方に立脚しないと展開できないと考えています。robotが、単機能として物を運ぶ、果実を収穫すると言うのは、大事な機能です。しかし、農場では様々な仕事があり、かつそれぞれの仕事が連動しています。そのような状況のなかで、複数のロボットやセンサーなどを使う為には、全体を統合的に制御できるarchitectureが必要になります。

その分散コンピューティングのノードコンピュータとして、Raspberry Piを位置づけています。これまでは、H8などのマイコンボードをLegacy PCで制御するような構造になっていたと思います。マイコン+Legacy PCをRaspberry Piで置き換える考え方です。それにより、ロボット開発には多くのメリットがあります。軽量化、原価低減、電源の最小化などなど多くの効果が期待できます。これまでも、ARMベースの低価格コンピュータが販売されていましたが、一気に1/3の価格になってしまいまいた。また、GPIOがあるのでデバイスに直接につなげます。
ロボット開発において、軽量化は大変重要です。私は、これまで、Dell mini9を使っていましたが、それにしても2Kg程度あります。それがバッテリー込みで、500g位になります。収穫用のactuatorは、ロボットシステム全体からみると、ひとつのApplicationとして独立していますが、Actuator専用にRaspberry Piを割当てる事も容易にできます。

システム構造です。まだ、案レベルで、実装しながら変更します。
上の図は、私のRobot Distributed Computing Model (RDCM)の構造図です。
この構造モデルに従って、全ての機能が実装されます。この図では、ControllerにARMのCPUを使うこと以外は、デバイスの規定はありません。従って、柔軟に組合わせることができます。
また、このArchitectureでは、他のコンピュータシステムと連携させることができます。例えば、農業生産管理システムとの連携も、簡単にできます。distributed computingモデルを基本にしているという事は、そのような意味です。
これまでの、ロボットは、ロボット中心の考え方をしていますが、私のロボットは、業務で人間と同等の役割を担う事を前提にしています。従って、role-definitionがあります。それらを延長した形で、私のロボットはWork Control Definition(WCD)に基づいて動きます。

温度センサーにしても、「温度を計測する」roleに基づいて役割を実行して、全体業務に貢献します。これは、別な意味で重要で、定義された役割を実行するので、それは、同一の経営体のなかであれば、どこでもいいわけです。もちろん、そのための作り方はあるわけですが、STMの評価ボード、XBee、温度センサーと単三電池を組みわせれば良いだけです。市販のおんどxxなどに比べれば、格安にかつ自由度の高い構成がとれます。

Raspberry Piは、そのような中で、Nodo Computerとして重要な役割を担っています。しかし、Raspberry Piがないと動かないわけでありません。

私のように、640KBの世界で3D-CADプログラムを開発していた人間から見れば、256MBのメモリーの世界は、はかりしれない可能性を持ちます。

人は、欲張りになりすぎました。これはコンピュータの世界だけでなく、全てす。
もっと、Simplifyに、構造化して認識することが大切です。

Simplify、いい言葉です。
ところで、Raspberry PiのOSは、Arch Linuxです。SimplifyなOSです。私は、Raspberry PiでGUIは使いません。Raspberry Piにはその必要性がありません。画像を見たければ、distributed computing上のAndroidで見れば十分です。
Simplifyです。