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

Add single and multiple marker board detection nodes #78

Open
wants to merge 1 commit into
base: kinetic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 11 additions & 1 deletion aruco_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,21 @@ add_executable(marker_publisher src/marker_publish.cpp
add_dependencies(marker_publisher ${PROJECT_NAME}_gencfg ${catkin_EXPORTED_TARGETS})
target_link_libraries(marker_publisher ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

add_executable(single_board src/single_board.cpp
src/aruco_ros_utils.cpp)
add_dependencies(single_board ${PROJECT_NAME}_gencfg)
target_link_libraries(single_board ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

add_executable(multi_board src/multi_board.cpp
src/aruco_ros_utils.cpp)
add_dependencies(multi_board ${PROJECT_NAME}_gencfg)
target_link_libraries(multi_board ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

#############
## Install ##
#############

install(TARGETS single double marker_publisher aruco_ros_utils
install(TARGETS single double marker_publisher single_board multi_board aruco_ros_utils
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
Expand Down
2 changes: 2 additions & 0 deletions aruco_ros/include/aruco_ros/aruco_ros_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ namespace aruco_ros
//FIXME: make parameter const as soon as the used function is also const
tf::Transform arucoMarker2Tf(const aruco::Marker& marker, bool rotate_marker_axis=true);

tf::Transform arucoBoard2Tf(const aruco::Board& board, bool rotate_board_axis=true);

}
#endif // ARUCO_ROS_UTILS_H
23 changes: 23 additions & 0 deletions aruco_ros/launch/multi_board.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<launch>

<arg name="markerSize" default="0.16"/> <!-- in m -->
<arg name="eye" default="left"/>
<arg name="board_config" default="$(find aruco_ros)/samples/multi_board.yml" />
<arg name="board_dir" default="$(find aruco_ros)/samples/" />
<arg name="ref_frame" default=""/> <!-- leave empty and the pose will be published wrt param parent_name -->
<arg name="corner_refinement" default="LINES" /> <!-- NONE, HARRIS, LINES, SUBPIX -->

<node pkg="aruco_ros" type="multi_board" name="aruco_multi_board">
<remap from="/camera_info" to="/stereo/$(arg eye)/camera_info" />
<remap from="/image" to="/stereo/$(arg eye)/image_rect_color" />
<param name="image_is_rectified" value="True"/>
<param name="marker_size" value="$(arg markerSize)"/>
<param name="reference_frame" value="$(arg ref_frame)"/> <!-- frame in which the marker pose will be refered -->
<param name="camera_frame" value="stereo_gazebo_$(arg eye)_camera_optical_frame"/>
<param name="board_config" value="$(arg board_config)" />
<param name="board_dir" value="$(arg board_dir)" />
<param name="corner_refinement" value="$(arg corner_refinement)" />
<param name="draw_markers" value="True" />
</node>

</launch>
23 changes: 23 additions & 0 deletions aruco_ros/launch/single_board.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<launch>

<arg name="markerSize" default="0.16"/> <!-- in m -->
<arg name="eye" default="left"/>
<arg name="board_config" default="$(find aruco_ros)/samples/board_1.yml" />
<arg name="board_frame" default="aruco_board_frame"/>
<arg name="ref_frame" default=""/> <!-- leave empty and the pose will be published wrt param parent_name -->
<arg name="corner_refinement" default="LINES" /> <!-- NONE, HARRIS, LINES, SUBPIX -->

<node pkg="aruco_ros" type="single_board" name="aruco_single_board">
<remap from="/camera_info" to="/stereo/$(arg eye)/camera_info" />
<remap from="/image" to="/stereo/$(arg eye)/image_rect_color" />
<param name="image_is_rectified" value="True"/>
<param name="marker_size" value="$(arg markerSize)"/>
<param name="reference_frame" value="$(arg ref_frame)"/> <!-- frame in which the marker pose will be refered -->
<param name="camera_frame" value="stereo_gazebo_$(arg eye)_camera_optical_frame"/>
<param name="board_frame" value="$(arg board_frame)" />
<param name="board_config" value="$(arg board_config)" />
<param name="corner_refinement" value="$(arg corner_refinement)" />
<param name="draw_markers" value="True" />
</node>

</launch>
Binary file added aruco_ros/samples/board_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions aruco_ros/samples/board_1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%YAML:1.0
aruco_bc_nmarkers: 4
aruco_bc_mInfoType: 1
aruco_bc_markers:
- { id: 000, corners:[ [ -0.17, -0.17, 0. ], [ -0.01, -0.17, 0. ], [ -0.01, -0.01, 0. ], [ -0.17, -0.01, 0. ] ] }
- { id: 001, corners:[ [ 0.01, -0.17, 0. ], [ 0.17, -0.17, 0. ], [ 0.17, -0.01, 0. ], [ 0.01, -0.01, 0. ] ] }
- { id: 002, corners:[ [ -0.17, 0.01, 0. ], [ -0.01, 0.01, 0. ], [ -0.01, 0.17, 0. ], [ -0.17, 0.17, 0. ] ] }
- { id: 003, corners:[ [ 0.01, 0.01, 0. ], [ 0.17, 0.01, 0. ], [ 0.17, 0.17, 0. ], [ 0.01, 0.17, 0. ] ] }
Binary file added aruco_ros/samples/board_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions aruco_ros/samples/board_2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%YAML:1.0
aruco_bc_nmarkers: 4
aruco_bc_mInfoType: 1
aruco_bc_markers:
- { id: 004, corners:[ [ -0.17, -0.17, 0. ], [ -0.01, -0.17, 0. ], [ -0.01, -0.01, 0. ], [ -0.17, -0.01, 0. ] ] }
- { id: 005, corners:[ [ 0.01, -0.17, 0. ], [ 0.17, -0.17, 0. ], [ 0.17, -0.01, 0. ], [ 0.01, -0.01, 0. ] ] }
- { id: 006, corners:[ [ -0.17, 0.01, 0. ], [ -0.01, 0.01, 0. ], [ -0.01, 0.17, 0. ], [ -0.17, 0.17, 0. ] ] }
- { id: 007, corners:[ [ 0.01, 0.01, 0. ], [ 0.17, 0.01, 0. ], [ 0.17, 0.17, 0. ], [ 0.01, 0.17, 0. ] ] }
4 changes: 4 additions & 0 deletions aruco_ros/samples/multi_board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
%YAML:1.0
aruco_boards:
- { frame_id: "/board1", filename: "board_1.yml"}
- { frame_id: "/board2", filename: "board_2.yml"}
36 changes: 36 additions & 0 deletions aruco_ros/src/aruco_ros_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,39 @@ tf::Transform aruco_ros::arucoMarker2Tf(const aruco::Marker &marker, bool rotate

return tf::Transform(tf_rot, tf_orig);
}

tf::Transform aruco_ros::arucoBoard2Tf(const aruco::Board &board, bool rotate_board_axis)
{
cv::Mat rot(3, 3, CV_64FC1);
cv::Mat Rvec64;
board.Rvec.convertTo(Rvec64, CV_64FC1);
cv::Rodrigues(Rvec64, rot);
cv::Mat tran64;
board.Tvec.convertTo(tran64, CV_64FC1);

// Rotate axis direction as to fit ROS (?)
if (rotate_board_axis)
{
cv::Mat rotate_to_ros(3, 3, CV_64FC1);
// -1 0 0
// 0 0 1
// 0 1 0
rotate_to_ros.at<double>(0, 0) = -1.0;
rotate_to_ros.at<double>(0, 1) = 0.0;
rotate_to_ros.at<double>(0, 2) = 0.0;
rotate_to_ros.at<double>(1, 0) = 0.0;
rotate_to_ros.at<double>(1, 1) = 0.0;
rotate_to_ros.at<double>(1, 2) = 1.0;
rotate_to_ros.at<double>(2, 0) = 0.0;
rotate_to_ros.at<double>(2, 1) = 1.0;
rotate_to_ros.at<double>(2, 2) = 0.0;
rot = rot * rotate_to_ros.t();
}
tf::Matrix3x3 tf_rot(rot.at<double>(0, 0), rot.at<double>(0, 1), rot.at<double>(0, 2),
rot.at<double>(1, 0), rot.at<double>(1, 1), rot.at<double>(1, 2),
rot.at<double>(2, 0), rot.at<double>(2, 1), rot.at<double>(2, 2));

tf::Vector3 tf_orig(tran64.at<double>(0, 0), tran64.at<double>(1, 0), tran64.at<double>(2, 0));

return tf::Transform(tf_rot, tf_orig);
}
Loading