Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 8652a66

Browse files
author
Frida
committed
fix merges
2 parents 51df4d7 + 39e858b commit 8652a66

File tree

13 files changed

+895
-686
lines changed

13 files changed

+895
-686
lines changed

contour_filter/src/contour_filter.cpp

+259-352
Large diffs are not rendered by default.

contour_filter/src/contour_filter.h

+35-3
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,45 @@ enum Filter_mode
4545
Filter_mode mode;
4646

4747
//object contour parameters
48-
//double minArea = 1000.0;
49-
double minArea = 10.0;
48+
double minArea = 1000.0;
49+
//double minArea = 10.0;
5050
//double maxArea = 100000.0;
51-
double maxArea = 1000.0;
51+
double maxArea = 17000.0;
52+
53+
//object rectangle parameter
54+
//double minRatio = 4.3;
55+
const double minRatio = 5;
56+
57+
struct ObjectRectangle
58+
{
59+
unsigned int ROI_id;
60+
cv::Rect boundRect;
61+
};
62+
63+
struct DetectedObject : ObjectRectangle
64+
{
65+
std::vector<cv::Point> contours_poly;
66+
cv::RotatedRect rotatedRect;
67+
cv::Point mc;
68+
69+
// friend std::ostream & operator<<(std::ostream & stream, const DetectedObject &a)
70+
// {
71+
// stream << "id: "<<a.ROI_id<<"\ncontours_poly: "<<a.contours_poly.size()<<"\nboundRect: ["<<a.boundRect.tl()<<", "<<a.boundRect.br()<<"]"
72+
// <<"\nrotatedRect: "<<a.rotatedRect.angle<<"\nmc: "<<a.mc;
73+
// return stream;
74+
// }
75+
76+
};
5277

5378
//previous ROI
5479
cv::Rect prev_rect;
5580
int ROI_id_counter = 0;
5681

82+
//parameters for the shadow filter
83+
int SHADOW_FILTER_MASK_SIZE = 7;
84+
float SHADOW_FILTER_THRESHOLD = 0.02;
85+
86+
//contour translation between depth to color image
87+
int DEPTH_TO_COLOR_DX = -30;
88+
int DEPTH_TO_COLOR_DY = 0;
5789
#endif /* CONTOUR_FILTER_H_ */

explorer/CMakeLists.txt.user

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE QtCreatorProject>
3-
<!-- Written by QtCreator 2.8.1, 2013-12-04T22:47:17. -->
3+
<!-- Written by QtCreator 2.8.1, 2013-12-05T18:34:39. -->
44
<qtcreator>
55
<data>
66
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -158,8 +158,8 @@
158158
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
159159
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.EKF</value>
160160
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
161-
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
162-
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
161+
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
162+
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
163163
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
164164
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
165165
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>

explorer/launch/goto_targets.launch

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<node name="serial_node" pkg="rosserial_python" type="serial_node.py"/>
44
<node pkg="explorer" name="motors" type="motors"/>
5-
<node pkg="explorer" name="EKF" type="EKF">
5+
<node pkg="explorer" name="EKF" type="EKF" output="screen">
66
<param name="mode" value="1"/>
77
</node>
88
<node pkg="explorer" name="controller" type="controller" output="screen">

explorer/launch/test.launch

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<launch>
2+
3+
<node name="serial_node" pkg="rosserial_python" type="serial_node.py"/>
4+
<node pkg="explorer" name="motors" type="motors"/>
5+
<node pkg="explorer" name="EKF" type="EKF">
6+
<param name="mode" value="2"/>
7+
</node>
8+
<node pkg="explorer" name="controller" type="controller" output="screen">
9+
<param name="mode" value="2"/>
10+
</node>
11+
12+
<node pkg="obj_detection" name="recogntion_master" type="recognition_master"/>
13+
14+
<node pkg="robot_talk" name="robot_talk" type="robot_talk"/>
15+
16+
</launch>

explorer/src/EKF.cpp

+21-7
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,23 @@ void receive_sensors(const AnalogC::ConstPtr &msg)
5555
double s2 = a_short*pow(msg->ch2,b_short); // right
5656

5757
static double s0,x_s0,y_s0;
58-
if((s1 < 0.2) & !wall & (s1 < s2))
58+
if((s1 < 0.15) & !wall & (s1 < s2)) //0.2
5959
{
6060
init();
6161
x_s0 = x_s1;
6262
y_s0 = y_s1;
6363
right_sensor = false;
6464
wall = true;
65+
//y_wall_bar = 0;
6566
}
66-
if((s2 < 0.2) & !wall & (s2 < s1))
67+
if((s2 < 0.15) & !wall & (s2 < s1)) //0.2
6768
{
6869
init();
6970
x_s0 = x_s2;
7071
y_s0 = y_s2;
7172
right_sensor = true;
7273
wall = true;
74+
//y_wall_bar = 0;
7375
}
7476

7577
// Sensor measurement
@@ -92,7 +94,7 @@ void receive_sensors(const AnalogC::ConstPtr &msg)
9294
double s0_hat = (y_wall_bar-y_bar-x_s0*sin(theta_bar)-y_s0*cos(theta_bar))/cos(theta_bar);
9395
double diff = s0 - s0_hat;
9496

95-
if((diff*diff > 0.03*0.03) | (y_wall*y_wall > 0.3*0.3))
97+
if((diff*diff > 0.03*0.03) | (y_wall*y_wall > 0.25*0.25))
9698
{
9799
wall = false;
98100
}
@@ -219,7 +221,7 @@ double angle(double th)
219221
void init()
220222
{
221223
sigma = 1E-10 * MatrixXd::Identity(4,4);
222-
sigma(2,2) = 1E-6; //-4
224+
sigma(2,2) = 1E-6; //-4 //-6
223225
sigma(3,3) = 1E-6;
224226
R = 1E-10 * MatrixXd::Identity(4,4);
225227
R(3,3) = 1E-8;
@@ -246,6 +248,7 @@ int main(int argc, char** argv)
246248
// Init
247249
init();
248250

251+
printf("mode = %d\n",mode);
249252

250253
if(mode == GOTO_TARGETS)
251254
{
@@ -259,6 +262,17 @@ int main(int argc, char** argv)
259262
x_true = odometry.at(0);
260263
y_true = odometry.at(1);
261264
theta_true = odometry.at(2);
265+
266+
// Failed to go back to (0,0)
267+
double distance = sqrt((x_true)*(x_true)+(y_true)*(y_true));
268+
if(distance > 0.1)
269+
{
270+
x_true = 0;
271+
y_true = 0;
272+
theta_true = 0;
273+
}
274+
275+
printf("x = %f, y = %f, theta = %f\n",x_true,y_true,theta_true);
262276
}
263277

264278

@@ -275,10 +289,10 @@ int main(int argc, char** argv)
275289
{
276290
// Save last odometry
277291
std::vector<double> odometry;
292+
odometry.push_back(x_true + x*cos(theta_true) - y*sin(theta_true));
293+
odometry.push_back(y_true + x*sin(theta_true) + y*cos(theta_true));
294+
odometry.push_back(angle(theta_true + theta));
278295
odometry.resize(3);
279-
odometry.push_back(x_true);
280-
odometry.push_back(y_true);
281-
odometry.push_back(theta_true);
282296

283297
std::ofstream os("/home/robo/explorer/last_odometry.dat",std::ios::binary);
284298
os.write(reinterpret_cast<const char*>(&(odometry[0])),odometry.size()*sizeof(double));

0 commit comments

Comments
 (0)