diff --git a/Shivam/Gazebo/my_robots/model.config b/Shivam/Gazebo/my_robots/model.config new file mode 100644 index 0000000..3d21fee --- /dev/null +++ b/Shivam/Gazebo/my_robots/model.config @@ -0,0 +1,15 @@ + + + My Robot + 1.0 + model.sdf + + + My Name + me@my.email + + + + My awesome robot. + + diff --git a/Shivam/Gazebo/my_robots/model.sdf b/Shivam/Gazebo/my_robots/model.sdf new file mode 100644 index 0000000..d2f9fc4 --- /dev/null +++ b/Shivam/Gazebo/my_robots/model.sdf @@ -0,0 +1,118 @@ + + + + false + + 0 0 0.1 0 0 0 + + + + + 0.4 0.2 0.1 + + + + + + + + .4 .2 .1 + + + + + + + + -0.15 0 -.05 0 0 0 + + + 0.05 + + + + + + + + -0.15 0 -0.05 0 0 0 + + + 0.05 + + + + + + 0 + 0 + 1.0 + 1.0 + + + + + + + + 0.1 0.13 0.1 0 1.5707 1.5707 + + + + 0.1 + 0.05 + + + + + + + 0.1 + 0.05 + + + + + + 0.1 -0.13 0.1 0 1.5707 1.5707 + + + + 0.1 + 0.05 + + + + + + + .1 + .05 + + + + + + + 0 0 -0.03 0 0 0 + left_wheel + chassis + + 0 1 0 + + + + + 0 0 0.03 0 0 0 + right_wheel + chassis + + 0 1 0 + + + + + + + + diff --git a/Shivam/Oops/Oops.cpp b/Shivam/Oops/Oops.cpp new file mode 100644 index 0000000..aadb593 --- /dev/null +++ b/Shivam/Oops/Oops.cpp @@ -0,0 +1,398 @@ +#include +#include +#include +#include +//#include "findCentroid.cpp" +//#include "blobDetect.cpp" +//#include "Oops_class.h" + +class pos + { + public: + pos() + { + x=0,y=0;colour=0; + } + int x; + int y; + int colour; + }; + +struct node +{ public: + int x; + int y; + node *next; +}; + +class queue +{ + node *front, *rear; +public: + queue(){front=NULL; + rear=NULL;} + int isEmpty(); + void enqueue(int, int); + void queueFront(int*, int*); + void dequeue(); + +}; + +class image + { int score1; + int score2; + pos currentpos1; + pos currentpos2; + + public: + int count; + cv::Mat img; + cv::Mat img_bin; + int **visited; + image(); + pos *centroid; + int bfs(); + int updatepos1(); + int updatepos2(); + void findCentroid(); + void printScore(); + }; + +image::image() + { + score1=0,score2=0; + count=0; + score1=0; + score2=0; + + + } +int image::bfs() +{ + queue q; + int x=0,y=0; + int cols=img_bin.cols, rows=img_bin.rows; + int count=1; + for(int j=0;j(j,i))==255) + { + if(visited[j][i]==-1) + { + q.enqueue(j,i); + q.queueFront(&y,&x); + visited[j][i]=0; + + while(!q.isEmpty()) + { + q.queueFront(&y,&x); + q.dequeue(); + for(int l=y-1;l<=y+1;l++) + for(int k=x-1;k<=x+1;k++) + { + if(k>0 && k0 && l(l,k)==255) + { + q.enqueue(l,k); + visited[l][k]=count; + + } + + } + visited[y][x]=count; + } + count++; + } + + + } + } + + return count; + +} + +void image::findCentroid() +{ + int *pixels= new int[count]; + int blobno=0; + int rows=img_bin.rows; + int cols=img_bin.cols; + for(int j=0;j(centre.x,centre.y); + if(point[0]>1500 && point[1]<100 && point[2]<100) + (centroid[i]).colour= 0; + else if(point[0]<100 && point[1]>150 && point[2]<100) + (centroid[i]).colour= 1; + else if(point[0]<100 && point[1]<100 && point[2]>150) + (centroid[i]).colour= 2; + } +} + + +float calcDist(pos a, pos b) //Calculating only the square of the distance +{ + float dist=0; + dist= (a.x- b.x)*(a.x- b.x) + (a.y- b.y)*(a.y- b.y); + return dist; +} +int image::updatepos1() +{ + float temp=0; + float minDist=2*(img.rows)*(img.cols)*(img.rows)*(img.cols); + pos nearestC; + int dice1=0; + std::cout<<"Enter throw "<>dice1; + std::cout<<"Player 1's throw is "<>dice2; + std::cout<<"Player 2's throw is "<next; + delete t; +} + +cv::Mat binary(cv::Mat img,float threshold) +{ cv::Mat img_bin; + //img=cv::imread("/home/aries/Desktop/1.jpg",0); + // cvtColor(img,img_gray,CV_RGB2GRAY); + cv::threshold(img,img_bin,threshold,255.0,cv::THRESH_BINARY); + cv::imwrite("img_bin3.jpg",img_bin); + return img_bin; +} + + + +int main() +{ + std::cout<<"Welcome!!"< +#include +#include +#include +#include +#include +#include + +const int threshDist=20, threshSlope=1; + +float distance(int x1, int y1, int x2, int y2) +{ + return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); +} + +int main() +{ + cv::Mat img= cv::imread("",1); + std::vectorlines; + int maxpoints=40, minpoints=10; + cv::HoughLinesP(img, lines,1,CV_PI/180,maxpoints,minpoints,40); + int count=lines.size(); + visited[count]; + for(int i=0;i