Commit bc64e198 authored by CANNERE Xavier's avatar CANNERE Xavier
Browse files

finition topic4

parent e98a71de
......@@ -170,7 +170,7 @@ Then build it, there is many errors don't worry, replace the content of ``packag
<?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>dolly_follow</name>
<name>pkg_follower</name>
<version>0.4.0</version>
<description>
Follow node for Dolly, the robot sheep.
......@@ -188,6 +188,10 @@ Then build it, there is many errors don't worry, replace the content of ``packag
<exec_depend>rclcpp</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>follower</exec_depend>
<exec_depend>gazebo_ros_pkgs</exec_depend>
<exec_depend>ros2launch</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
......@@ -200,7 +204,7 @@ And CMakeLists.txt by that::
cmake_minimum_required(VERSION 3.5)
project(dolly_follow)
project(pkg_follower)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
......@@ -210,6 +214,7 @@ And CMakeLists.txt by that::
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(gazebo QUIET)
find_package(ament_cmake REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rclcpp REQUIRED)
......@@ -232,6 +237,13 @@ And CMakeLists.txt by that::
install(TARGETS ${target}
DESTINATION lib/${PROJECT_NAME})
# install the launch directory
install(DIRECTORY
launch
worlds
DESTINATION share/${PROJECT_NAME}/
)
ament_package()
Now you can ``colcon build`` in the root of your workspace and your follower node compile correctly.
......@@ -239,4 +251,98 @@ Now you can ``colcon build`` in the root of your workspace and your follower nod
Step 4 : Create the launcher
----------------------------
First we'll create the world, you can create a ``worlds`` folder into the ``pkg_follower``, and create ``follower.world``. Into this files paste that::
<?xml version="1.0" ?>
<sdf version="1.6">
<world name="default">
<include>
<uri>model://sun</uri>
</include>
<include>
<uri>model://ground_plane</uri>
</include>
<include>
<uri>model://room</uri>
</include>
<include>
<pose>0 0 0 0 0 0</pose>
<uri>model://roversensor</uri>
</include>
</world>
</sdf>
Now create an other folder like ``worlds`` called ``launch``, and into this folder create ``follower.launch.py`` files and paste that into this files::
# Copyright 2019 Louise Poubel
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
def generate_launch_description():
pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
pkg_follower = get_package_share_directory('pkg_follower')
follower_path = '~/colcon_ws/src/pkg_follower'
# follow_path = '~/colcon_ws/build/pkg_follower'
# print(pkg_follower)
# Gazebo launch
gazebo = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_gazebo_ros, 'launch', 'gazebo.launch.py'),
)
)
# Follow node
follow = Node(
package='pkg_follower',
executable='follower',
output='screen',
#remappings=[
# ('cmd_vel', '/demo/cmd_vel'),
# ('/demo/laser/out', '/demo/laser_scan'),
#]
)
return LaunchDescription([
DeclareLaunchArgument(
'world',
default_value=[os.path.join(follower_path, 'worlds', 'follower.world'), ''],
description='SDF world file'),
gazebo,
follow
])
Step 5 : Test it!
-----------------
Now on a terminal (don't forget to source), type::
ros2 launch pkg_follower follower.launch.py
You can put shape in front of the rover to test, the rover should go to the nearest shape.
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