Skip to content

Commit 973d6d8

Browse files
committed
Merge pull request #4 from pet1330/to-fix
combined messages
2 parents 6b812f1 + bce6ae3 commit 973d6d8

File tree

9 files changed

+149
-99
lines changed

9 files changed

+149
-99
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@ if(NOT DISABLE_ROS)
3535
add_message_files(
3636
FILES
3737
PointArray.msg
38+
Tracker.msg
39+
TrackerArray.msg
3840
)
3941

4042
generate_messages(
41-
DEPENDENCIES geometry_msgs
43+
DEPENDENCIES
44+
geometry_msgs
45+
std_msgs
46+
whycon
4247
)
4348

4449
catkin_package(

launch/whycon.launch

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1+
<?xml version="1.0"?>
12
<launch>
2-
<group ns="camera">
3-
<node pkg="image_proc" type="image_proc" name="image_proc"/>
4-
</group>
5-
6-
<node name="whycon" type="whycon" pkg="whycon">
7-
<param name="targets" value="4"/>
8-
<param name="max_refine" value="5"/>
9-
<param name="max_attempts" value="5"/>
10-
11-
<!-- uncomment when already performed 3D->2D calibration -->
12-
<!--
13-
<param name="xscale" value="1"/>
14-
<param name="yscale" value="1"/>
15-
<param name="axis" value="axis/>
16-
-->
3+
4+
<node pkg="whycon" type="whycon" name="whycon_right" respawn="true" output="screen">
5+
<param name="targets" value="1" type="int"/>
6+
<param name="outer_diameter" value="0.03" type="double"/>
7+
<param name="inner_diameter" value="0.01" type="double"/>
8+
<param name="target_frame" value="right_hand_camera"/>
9+
<remap from="/camera/image_rect_color" to="/cameras/right_hand_camera/image"/>
10+
<remap from="/camera/camera_info" to="/cameras/right_hand_camera/camera_info"/>
1711
</node>
18-
</launch>
1912

13+
<node pkg="whycon" type="whycon" name="whycon_left" respawn="true" output="screen">
14+
<param name="targets" value="1" type="int"/>
15+
<param name="outer_diameter" value="0.03" type="double"/>
16+
<param name="inner_diameter" value="0.01" type="double"/>
17+
<param name="target_frame" value="left_hand_camera"/>
18+
<remap from="/camera/image_rect_color" to="/cameras/left_hand_camera/image"/>
19+
<remap from="/camera/camera_info" to="/cameras/left_hand_camera/camera_info"/>
20+
</node>
21+
22+
<!--<node pkg="zoidbot_tools" type="whycon_transform.py" name="whycon_transform" respawn="true" output="screen"/>-->
23+
24+
</launch>

msg/Tracker.msg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
string uuid # A unique label for that object or a universal ID
2+
geometry_msgs/Pose pose # The position and orientation of each object
3+
geometry_msgs/Point point # Image Coordinates
4+
float64 roundness # The circulatiry of the object
5+
float64 bwratio # The ratio between the inside and outside circle

msg/TrackerArray.msg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Header header
2+
whycon/Tracker[] tracked_objects # A list of detected objects from a single timestamp

src/lib/circle_detector.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,13 @@ cv::CircleDetector::Circle cv::CircleDetector::detect(const cv::Mat& image, bool
252252
vector<int>& queue = context->queue;
253253

254254
int pos = (height-1)*width;
255-
int ii = 0;
255+
int ii = 0;
256256
int start = 0;
257257
Circle inner, outer;
258258

259259
bool search_in_window = false;
260-
int local_x, local_y;
260+
int local_x = -1;
261+
int local_y = -1;
261262
if (previous_circle.valid){
262263
WHYCON_DEBUG("starting with previously valid circle at " << previous_circle.x << "," << previous_circle.y);
263264
ii = ((int)previous_circle.y)*width+(int)previous_circle.x;

src/lib/localization_system.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
#include <limits>
99
#include <whycon/circle_detector.h>
1010
#include <whycon/localization_system.h>
11-
using std::cout;
12-
using std::endl;
13-
using std::numeric_limits;
1411

1512
cv::LocalizationSystem::LocalizationSystem(int _targets, int _width, int _height, const cv::Mat& _K, const cv::Mat& _dist_coeff,
1613
float _outer_diameter, float _inner_diameter) :
@@ -31,7 +28,7 @@ cv::LocalizationSystem::LocalizationSystem(int _targets, int _width, int _height
3128
coordinates_transform = cv::Matx33f(1, 0, 0, 0, 1, 0, 0, 0, 1);
3229
precompute_undistort_map();
3330

34-
cout.precision(30);
31+
std::cout.precision(30);
3532
}
3633

3734
bool cv::LocalizationSystem::localize(const cv::Mat& image, bool reset, int attempts, int max_refine) {
@@ -159,21 +156,21 @@ bool cv::LocalizationSystem::set_axis(const cv::Mat& image, int max_attempts, in
159156
cv::Vec3f vecs[3];
160157
for (int i = 0; i < 3; i++) {
161158
vecs[i] = circle_poses[i + 1].pos - circle_poses[0].pos;
162-
cout << "vec " << i+1 << "->0 " << vecs[i] << endl;
159+
std::cout << "vec " << i+1 << "->0 " << vecs[i] << std::endl;
163160
}
164161
int min_prod_i = 0;
165-
float min_prod = numeric_limits<float>::max();
162+
float min_prod = std::numeric_limits<float>::max();
166163
for (int i = 0; i < 3; i++) {
167164
float prod = fabsf(vecs[(i + 2) % 3].dot(vecs[i]));
168-
cout << "prod: " << ((i + 2) % 3 + 1) << " " << i + 1 << " " << vecs[(i + 2) % 3] << " " << vecs[i] << " " << prod << endl;
165+
std::cout << "prod: " << ((i + 2) % 3 + 1) << " " << i + 1 << " " << vecs[(i + 2) % 3] << " " << vecs[i] << " " << prod << std::endl;
169166
if (prod < min_prod) { min_prod = prod; min_prod_i = i; }
170167
}
171168
int axis1_i = (((min_prod_i + 2) % 3) + 1);
172169
int axis2_i = (min_prod_i + 1);
173170
if (fabsf(circle_poses[axis1_i].pos(0)) < fabsf(circle_poses[axis2_i].pos(0))) std::swap(axis1_i, axis2_i);
174171
int xy_i = 0;
175172
for (int i = 1; i <= 3; i++) if (i != axis1_i && i != axis2_i) { xy_i = i; break; }
176-
cout << "axis ids: " << axis1_i << " " << axis2_i << " " << xy_i << endl;
173+
std::cout << "axis ids: " << axis1_i << " " << axis2_i << " " << xy_i << std::endl;
177174

178175
CircleDetector::Circle origin_circles_reordered[4];
179176
origin_circles_reordered[0] = origin_circles[0];
@@ -183,7 +180,7 @@ bool cv::LocalizationSystem::set_axis(const cv::Mat& image, int max_attempts, in
183180
for (int i = 0; i < 4; i++) {
184181
origin_circles[i] = origin_circles_reordered[i];
185182
circle_poses[i] = get_pose(origin_circles[i]);
186-
cout << "original poses: " << circle_poses[i].pos << endl;
183+
std::cout << "original poses: " << circle_poses[i].pos << std::endl;
187184
}
188185

189186
float dim_x = 1.0;
@@ -208,14 +205,14 @@ bool cv::LocalizationSystem::set_axis(const cv::Mat& image, int max_attempts, in
208205
cv::solve(A, b, x);
209206
x.push_back(1.0);
210207
coordinates_transform = x.reshape(1, 3);
211-
cout << "H " << coordinates_transform << endl;
208+
std::cout << "H " << coordinates_transform << std::endl;
212209

213210
// TODO: compare H obtained by OpenCV with the hand approach
214211
std::vector<cv::Vec2f> src(4), dsts(4);
215212
for (int i = 0; i < 4; i++) {
216213
src[i] = tmp[i];
217214
dsts[i] = targets[i];
218-
cout << tmp[i] << " -> " << targets[i] << endl;
215+
std::cout << tmp[i] << " -> " << targets[i] << std::endl;
219216
}
220217

221218
/*cv::Matx33f H = cv::findHomography(src, dsts, CV_LMEDS);

src/ros/whycon_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
int main(int argc, char** argv)
55
{
6-
ros::init(argc, argv, "whycon");
6+
ros::init(argc, argv, "whycon", ros::init_options::AnonymousName);
77
ros::NodeHandle n("~");
88

99
whycon::WhyConROS whycon_ros(n);

0 commit comments

Comments
 (0)