-
Notifications
You must be signed in to change notification settings - Fork 17
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
shivamvats
wants to merge
7
commits into
AGV-IIT-KGP:master
Choose a base branch
from
shivamvats:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d61d0b0
Gazebo Tutorial and partial Oops assignment added.
9ee6438
Getting segmentation fault with bfs. 1-2 functions still left as I am…
66b4da0
I have tried to reorganise the functions and classes. Still getting d…
4ee1291
Deleted redundant files
91c1eeb
Deleted
5be1f4f
Working
ced7c1f
Incomplete code to separate lanes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>[email protected]</email> | ||
</author> | ||
|
||
<description> | ||
My awesome robot. | ||
</description> | ||
</model> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <iostream> | ||
#include <opencv/highgui.h> | ||
#include <opencv/cv.h> | ||
#include "findCentroid.cpp" | ||
#include "blobDetect.cpp" | ||
#include "queue.h" | ||
|
||
image img_class; | ||
|
||
int main() | ||
{ | ||
int flag1=1, flag2=1; | ||
int count=0; | ||
cv::Mat bin,edit; | ||
bin=binary(img_class.img,190.0); | ||
img_class.img_bin=bin; | ||
count= img_class.bfs(); | ||
img_class.count=count; | ||
img_class.findCentroid(); | ||
while (flag1==1 && flag2==1) | ||
{ | ||
flag1=img_class.updatepos1(); | ||
flag2= img_class.updatepos2(); | ||
img_class.printScore(); | ||
} | ||
|
||
std::cout<<"GAME OVER"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef Oops_class_h | ||
#define Oops_class_h | ||
|
||
#include <iostream> | ||
#include <opencv/highgui.h> | ||
#include <opencv/cv.h> | ||
|
||
class pos | ||
{ | ||
public: | ||
pos() | ||
{ | ||
x=0,y=0;colour=0; | ||
} | ||
int x; | ||
int y; | ||
int colour; | ||
}; | ||
|
||
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; | ||
img = cv::imread("/home/aries/Desktop/1.jpg",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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifndef blobDetect_h | ||
#define blobDetect_h | ||
#include <iostream> | ||
#include <opencv/cv.h> | ||
#include <opencv/highgui.h> | ||
#include <opencv2/imgproc/imgproc.hpp> | ||
#include "Oops_class.h" | ||
#include "queue.h" | ||
|
||
|
||
|
||
cv::Mat binary(cv::Mat img,float threshold) | ||
{ cv::Mat img_gray,img_bin; | ||
img=cv::imread("/home/aries/Desktop/1.jpg",1); | ||
cvtColor(img,img_gray,CV_RGB2GRAY); | ||
cv::threshold(img_gray,img_bin,threshold,255.0,cv::THRESH_BINARY); | ||
cv::imwrite("img_bin3.jpg",img_bin); | ||
return img_bin; | ||
|
||
} | ||
|
||
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<img_bin.rows;j++) | ||
for(int i=0;i<img_bin.cols;i++) | ||
{ | ||
if((img_bin.at<uchar>(i,j))==0) | ||
{ | ||
if(visited[i][j]==-1) | ||
{ | ||
q.enqueue(i,j); | ||
q.queueFront(&x,&y); | ||
visited[i][j]=0; | ||
|
||
while(!q.isEmpty()) | ||
{ q.queueFront(&x,&y); | ||
q.dequeue(); | ||
for(int l=y-1;l<=y+1;l++) | ||
for(int k=x-1;k<=x+1;k++) | ||
{ | ||
if(k>0 && k<cols && l>0 && l<rows && visited[k][l]==-1 && img_bin.at<uchar>(i,j)==0) | ||
{ | ||
q.enqueue(k,l); | ||
visited[k][l]=count; | ||
|
||
} | ||
|
||
} | ||
visited[x][y]=count; | ||
} | ||
count++; | ||
std::cout<<count<<std::endl; | ||
} | ||
|
||
|
||
} | ||
} | ||
|
||
return count; | ||
|
||
} | ||
|
||
#endif | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have not included
Oops_class.h
in this file.