Commit 09d6bf14 authored by CANNERE Xavier's avatar CANNERE Xavier
Browse files

ajustement topic 6

parent 41d12beb
......@@ -3,6 +3,9 @@ ROS2 : Create a visual follower
We'll learn how launch ROS1 nodes with ROS2 nodes. In this example we'll see a follower robot with a camera (same concept as the sensorfollower but he will detect target with the color) in ROS2 with a node that allows object recognition.
.. note::
You can import from git the model of rover with camera for the simulations.
Step 1 : Create the visual follower package
-------------------------------------------
......@@ -678,18 +681,108 @@ You should have this final code::
Step 7 : Test it
----------------
Open Gazebo, take your model and put a can of coke in front of.
Replace the existant code on CMakeList.txt by::
cmake_minimum_required(VERSION 3.8)
project(pkg_visual)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(gazebo QUIET)
find_package(ament_cmake REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rclcpp REQUIRED)
find_package(OpenCV REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
add_executable(visual src/visual.cpp src/DetectionCnam_codels.cpp)
target_include_directories(visual PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(visual PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
ament_target_dependencies(
visual
"sensor_msgs"
"geometry_msgs"
"rclcpp"
"OpenCV"
"cv_bridge"
"image_transport"
)
install(TARGETS visual
DESTINATION lib/${PROJECT_NAME})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
install(DIRECTORY
launch
worlds
DESTINATION share/${PROJECT_NAME}/
)
ament_package()
Do the same on package.xml::
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>pkg_visual</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="Xavier.CANNERE@isae-supaero.fr">etdisc</maintainer>
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>sensor_msgs</depend>
<depend>geometry_msgs</depend>
<depend>rclcpp</depend>
<depend>OpenCV</depend>
<depend>cv_bridge</depend>
<depend>image_transport</depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<exec_depend>visual</exec_depend>
<exec_depend>gazebo_ros_pkgs</exec_depend>
<exec_depend>ros2launch</exec_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Now start the launcher with the following command::
ros2 launch pkg_visual visual.launch.py
.. image:: 1.png
:width: 600
:height: 350
:align: center
:alt: image non disponible
Type::
Gazebo open and the world launch. Now type::
ros2 run pkg_visual visual
Nothing happend, because parameters are wrong, let open the node and type these command to set parameters on an other terminal::
ros2 param set visual blue 20
......@@ -697,9 +790,11 @@ Nothing happend, because parameters are wrong, let open the node and type these
The robot should move on the can.
Step 8 : ROS1 Bridge
Bonus : ROS1 Bridge
--------------------
The Bridge allow you to use ROS1 nodes and ROS2 nodes in the same execution.
Start your node, then type on a new terminal::
. /opt/ros/noetic/setup.bash
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment