Do you have a code for my iRobot Create to dock it's home base perfectly? Thank you.
-
8 พฤษภาคม 2555 14:44I need to program iRobot Create to dock on it's home base and charge the robot but the problem is that the robot misses it to the side just a few millimeters and i can't program it to run straight up and charge the robot.
Please give me some help/advice or could you send me the codes if you ever have programmed it to dock the home base. Any help is grateful, thank you so much.
ตอบทั้งหมด
-
9 พฤษภาคม 2555 12:36ผู้ดูแล
Hi Samuel,
Are you using RDS to control your iRobot Create base? Can you provide more insight into your your current solution? I.e. what is the approach you take, what sensors do you use, etc.
As a general note, docking is a non-trivial problem, and you would do well to play with parameters such as varying approach speeds, control loop frequencies, using additional sensors, etc.
-
9 พฤษภาคม 2555 17:04
My approach has to be with Microsoft Visual C++. It is an assignment at my college and the iRobot has no additional sensors. Probability that it will dock the home base properly would be about 3/10, I've tried various speeds but it doesn't help ( If it's too fast it would drive too far sideways).
Thank you for your attention Mr.Shirakyan.
Here are the codes in case you are free to read them and tell me my errors.
---------------------------------------------------------------------------------
#include <stdio.h>
#include <iostream>
#include "RobotConnector.h"
#include "cv.h"
#include "highgui.h"
using namespace std;
#define Create_Comport "COM3"
CreateData robotData;
RobotConnector robot;
ofstream record;
double vx,vz;
int last = GetTickCount();
int ab=0;
int r1;
int side,traget;
int R,G,GF,RF,a;
void run()
{
switch(ab)
{
case 1 :// run around
vx = 1 , vz=0;
if (GetTickCount()-1300>last)
{ab=3;
last = GetTickCount();
}
break;
case 3 : // turn to target
if (traget == 1)
{
vx = 1 , vz = 0.8;
}
if(traget == 2)
{
ab = 4;
}
if(traget == 3)
{
vx = 1 , vz = -0.8;
//0.7 1000+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
if (GetTickCount() - 1100 >last)
{ab = 4;
last = GetTickCount();
}
break;
case 4 : //run run run
vx = 1 , vz = 0;
if (GetTickCount() - 700 >last)
{ab = 6;
last = GetTickCount();
}
break;
/* case 5 :
vx = 0 , vz = -0.5;
if (GetTickCount() - 500 >last)
{ab = 6;
last = GetTickCount();
}
break;
*/
case 6 :
switch(r1)
{
case(244):
if (R == 0)
{G =1 ;}
if (G == 1)
{
vx = 0.5, vz = 0.20 ;
}
else vx = -0.2, vz = -0.3 ;
break;
case(248):
if (G == 0)
{R = 1;}
if (R == 1)
{
vx = 0.5 , vz = -0.2 ;
}
else vx = -0.2, vz = 0.3 ;
break;
case(246):
vx = -0.02 , vz = -0.3;
if (G == 1 )
vx = 0.3, vz = -0.15;
break;
case(250):
vx = -0.02 , vz= 0.3;
if(R ==1)
vx = 0.3, vz =0.15;
break;
case(254):
//if ( point >=1 )
{
vx = vx+ 0.1 , vz = 0 ;
if (vx<=0.4)
{
vx=0.4;
}
if (vx >1)
{
vx = 0.7;
}
}
/*else
{
point = point+1;
}*/
break;
case(242): vx = vx+0.1 , vz = vz;
break ;
case(240): vx = 0.6 , vz = 0;
break ;
case(0): vx = vx - 0.1 , vz = vz;
break ;
case(255) : vx = 0.4 , vz = 0;
break ;
case(252) : vx = 1 , vz = 0;
break ;
}
if( !robot.ReadData(robotData) )
{
if(vz = 0)
{ if(vx > -0.1)
vx = vx-0.005;
if(vx < -0.1)
vx = vx+0.005;
}
else if(vz>0)
{vx = vx ,vz = vz-0.005;}
else vx = vx,vz=vz+0.005;
}
if (robotData.charger[0] == 1)
{RF = RF+1;}
if(robotData.charger[0]==0)
{RF=0;}
if(RF>=4)
{ab=7;}
break;
case 7:
vx=0, vz=0;
break;
}
}
int main()
{
record.open("../data/robot.txt");
if( !robot.Connect(Create_Comport) )
{ cout << "Error : Can't connect to robot @" << Create_Comport << endl;
//return -1;
}
bool isRecord = false;
int in = 0;
R = G = GF = RF = a = 0;
robot.DriveDirect(0, 0);
printf("Select side (1 = left 2 = right) :");
scanf("%d",&side);
printf("Select traget (1 = left 2 = middle 3 = right) :");
scanf("%d",&traget);
cvNamedWindow("Robot");
last = GetTickCount();
while(true)
{
char c = cvWaitKey(50);
r1 = robotData.infrared;
if( c == 27 ) break;
//vx = vz = 0.0;
run();
double vl = vx - vz;
double vr = vx + vz;
int velL = (int)(vl*Create_MaxVel);
int velR = (int)(vr*Create_MaxVel);
int color = (abs(velL)+abs(velR))/4;
color = (color < 0) ? 0 : (color > 255) ? 255 : color;
int inten = (robotData.cliffSignal[1] + robotData.cliffSignal[2])/8 - 63;
inten = (inten < 0) ? 0 : (inten > 255) ? 255 : inten;
robot.LEDs(velL > 0, velR > 0, color, inten);
if( !robot.DriveDirect(velL, velR) )
cout << "SetControl Fail" << endl;
if( !robot.ReadData(robotData) )
cout << "ReadData Fail" << endl;
if( isRecord )
record << robotData.cliffSignal[0] << "\t" << robotData.cliffSignal[1] << "\t" << robotData.cliffSignal[2] << "\t" << robotData.cliffSignal[3] << endl;
//cout << "Sensor line " << robotData.cliffSignal[0] << endl;
// cout << "Infrared" << robotData.infrared << endl;
cout << "traget" <<robotData.infrared<< endl;
cout << "side" << robotData.charger[0] << endl;
cout << R <<endl;
}
robot.Disconnect();
return 0;
}
-
10 พฤษภาคม 2555 5:09ผู้ดูแล
Hi Samuel,
Sorry, I am unfamiliar with iRobot Create base programming in your environment. This forum is dedicated to Microsoft RDS questions.
You will have more luck searching elsewhere, i.e. http://homesupport.irobot.com/app/answers/detail/a_id/406/~/irobot%E2%AE-create%E2%AE-programming
- ทำเครื่องหมายเป็นคำตอบโดย Greg ShirakyanMicrosoft, Moderator 10 พฤษภาคม 2555 5:09