Skip to content

ROS2 application that enable a robot with a camera to follow a line in the floor

Notifications You must be signed in to change notification settings

IliasElabbassi/ROS2_line_follower

Repository files navigation

information

architecture

installation prerequis

  • ROS2 Humble
  • Gazebo
  • ros-humble-gazebo-ros-pkgs
  • Xacro

installation

sudo apt install gazebo sudo apt install ros-humnle-gazebo-ros-pkgs sudo apt install ros-humnle-xacro

TODO

  • find better pid values
  • get contour with the biggest area [ done ]
  • add light automatically in the gazebo environement

misc

create package: ros2 pkg create linefollower

build: cd ros2_ws colcon build

gazebo :

sudo apt install ros-humble-gazebo-ros-pkgs

Our ros Package :

URDF robot creation :

create a robot model: https://docs.ros.org/en/humble/Tutorials/Intermediate/URDF/Building-a-Visual-Robot-Model-with-URDF-from-Scratch.html

  • clone this repo https://github.com/joshnewans/my_bot this a template for creating urdf xacro robots in ros2
  • create the robot joint and link using xacro to generate the XML URDF file

to build : colcon build --symlink-install

to launch our urdf use : ros2 launch bocchi_bot rsp.launch.py

Run the created robot in Gazebo :

launch urdf in gazeboas it is

  • launch robot_state_publisher in sim mode
  • launch gazebo with ROS compatibility
  • spawn robot in gazebo with spawn script

we need to launch with simulation time so it works well in gazebo

launch robot_state_publisher in sim mode : ros2 launch bocchi_bot rsp.launch.py use_sim_timem:=true

launch gazebo with ROS compatibility : sudo apt install ros--gazebo-ros-pkgs ros2 launch gazebo_ros gazebo.launch.py

spawn robot in gazebo with spawn script : ros2 run gazebo_ros spawn_entity.py -topic robot_description -entity bot_name

create a launch file that will do all the above in one and launch it: colcon build ros2 launch bocchi_bot launch_sim.launch.py

with world as parameter : ros2 launch bocchi_bot launch_sim.launch.py world:=./src/bocchi_bot/worlds/lfm1.world

call service server via cli : ros2 service call /getPidOutput line_follower_interfaces/srv/Angle "{angle: 30, side: 1}"

reset command velocity : ros2 topic pub --once /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}"

Trouble shoot

runtime_error
Node '/follow_line' has already been added to an executor.

the basic things that you will need to change are:

https://github.com/ROS-Spanish-Users-Group/ros2_documentation/blob/a3b6c8215c72c95caa2cc44963ff92219376ac27/source/How-To-Guides/Using-callback-groups.rst#L307

About

ROS2 application that enable a robot with a camera to follow a line in the floor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published