Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gazebo Tutorial and partial Oops assignment added. #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Shivam/Gazebo/my_robots/model.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<model>
<name>My Robot</name>
<version>1.0</version>
<sdf version='1.4'>model.sdf</sdf>

<author>
<name>My Name</name>
<email>me@my.email</email>
</author>

<description>
My awesome robot.
</description>
</model>
118 changes: 118 additions & 0 deletions Shivam/Gazebo/my_robots/model.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?xml version='1.0'?>
<sdf version='1.4'>
<model name="my_robot">
<static>false</static>
<link name='chassis'>
<pose>0 0 0.1 0 0 0</pose>

<visual name='visual'>
<geometry>
<box>
<size>0.4 0.2 0.1</size>
</box>
</geometry>
</visual>

<collision name='collision'>
<geometry>
<box>
<size>.4 .2 .1</size>
</box>
</geometry>
</collision>



<visual name='caster_visual'>
<pose>-0.15 0 -.05 0 0 0</pose>
<geometry>
<sphere>
<radius>0.05</radius>
</sphere>
</geometry>
</visual>



<collision name='caster_collision'>
<pose>-0.15 0 -0.05 0 0 0</pose>
<geometry>
<sphere>
<radius>0.05</radius>
</sphere>
</geometry>
<surface>
<friction>
<ode>
<mu>0</mu>
<mu2>0</mu2>
<slip1>1.0</slip1>
<slip2>1.0</slip2>
</ode>
</friction>
</surface>
</collision>
</link>

<link name='left_wheel'>
<pose>0.1 0.13 0.1 0 1.5707 1.5707</pose>
<visual name="left_wheel_visual">
<geometry>
<cylinder>
<radius>0.1</radius>
<length>0.05</length>
</cylinder>
</geometry>
</visual>
<collision name="left_collision">
<geometry>
<cylinder>
<radius>0.1</radius>
<length>0.05</length>
</cylinder>
</geometry>
</collision>
</link>
<link name="right_wheel">
<pose>0.1 -0.13 0.1 0 1.5707 1.5707</pose>
<collision name="right_collision">
<geometry>
<cylinder>
<radius>0.1</radius>
<length>0.05</length>
</cylinder>
</geometry>
</collision>
<visual name="visual">
<geometry>
<cylinder>
<radius>.1</radius>
<length>.05</length>
</cylinder>
</geometry>
</visual>
</link>

<joint type="revolute" name="left_wheel_hinge">
<pose>0 0 -0.03 0 0 0</pose>
<child>left_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 1 0</xyz>
</axis>
</joint>

<joint type="revolute" name="right_wheel_hinge">
<pose>0 0 0.03 0 0 0</pose>
<child>right_wheel</child>
<parent>chassis</parent>
<axis>
<xyz>0 1 0</xyz>
</axis>
</joint>


</model>
</sdf>


160 changes: 160 additions & 0 deletions Shivam/Oops/OOPs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#include <iostream>
#include <cv_bridge.h>
#include <opencv2>

struct pos
{
int x;
int y;
int colour;
};


struct node
{
int x;
int y;
struct node *next;
};


class image
{ int score1=0;
int score2=0;
img* a;
int** visited;
pos* c;

public:
pos current_pos1;
pos current_pos2;
pos findcentroid(img* a,int blobno,int** visited);
pos newposition(img*a);


};

pos image::findcentroid(img *img,int blobno,int **visited)
{

int tx=0,ty=0,n=0;
float cx,cy;
pos c;
int i,j;
for(i=0;i<img->height;i++)
for(j=0;j<img->width;j++)
if(visited[i][j]==blobno)
{
tx+=i;
ty+=j;
n++;
}

c.x=tx/n;
c.y=ty/n;
return c;
}

int** visitedlist(img* a,int *count)
{
int i,j,k,l,x,y;
*count=0;
int blobsize=500;
int height = a->height;
int width = a->width;
int **visited;
int** visited =new int*;
for(i=0;i<a->height;i++)
int visited[i]=new int;
for(i=0;i<a->height;i++)
for(j=0;j<a->width;j++)
visited[i][j]=-1;

for(i=1;i<a->height-1;i++)
for(j=1;j<a->width-1;j++){
if(colour(a,i,j,0)==255)
{
if(visited[i][j]==-1)
{

front=NULL;
enqueue(i,j);
queuefront(&x,&y);
while(!isEmpty())
{
queuefront(&x,&y);
dequeue();
}

for(k=x-1;k<=x+1;k++)
for(l=y-1;l<=y+1;l++)
{
if((k>0)&&(k<a->height)&&(l>0)&&(l<a->width))
if(colour(a,k,l,0)==255 && visited[k][l]==-1){
enqueue(k,l);
visited[k][l]=*count;
blobsize++;
}
}
visited[x][y]=*count;
}

}
}
}
return visited;
}



node *rear,*front;

int isEmpty()
{
if(front==NULL)
return 1;
else return 0;
}

void enqueue(int x,int y)
{
node* t;
node* t=new node;
t->x=x;
t->y=y;
t->next=NULL;
if(isEmpty()){
front=t;
rear=front;
}
else
{
rear->next=t;
rear=t;
rear->next=NULL;
}
}
void queuefront(int *x,int *y)
{
*x=front->x;
*y=front->y;
return;
}
void dequeue()
{
node* t;
if(isEmpty()){
cout<<"Queue Underflow"<endl;
return;
}
t=front;
front=t->next;
delete t;
}


int main()
{
image i;
return 0;
}
22 changes: 22 additions & 0 deletions Shivam/Oops/Oops.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include "blobDetect.h"
#include "Oops_class.h"

image image;

int main()
{ pos cu
int count=0;
cv::Mat bin,edit;
image.img = cv::imread("/home/aries/Desktop/1.jpg",0);
bin=binary(image.img,190.0);
count= bfs(image);
image.count=count;
findCentroid(int count) ;



return 0;
}
46 changes: 46 additions & 0 deletions Shivam/Oops/Oops_class.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef guard
#include <iostream>
#include "pos.h"

class image
{ int score1;
int score2;
pos currentpos1;
pos currentpos2;

public:
int count;
cv::Mat img;
int **visited;
image();
pos *centroid;
void updatepos1;
void updatepos2;
void centroidUpdate();
void findCentroid(image image);
pos newposition();


};

image::image()
{
score1=0,score2=0;
currentpos1=(0,0);
currentpos2=(0,0);
count=0;
score1=0;
score2=0;
int rows=img.rows;
int cols=img.cols;
visited= new int*[rows];
for(int j=0;j<rows;j++)
{ visited[j]= new int[cols];
for(int i=0;i<cols;i++)
visited[i][j]=-1;
}
centroid= new pos[count];

}

#endif
Loading