diff --git a/CustomRobots/CMakeLists.txt b/CustomRobots/CMakeLists.txt index bbdeab2e0..06762af18 100755 --- a/CustomRobots/CMakeLists.txt +++ b/CustomRobots/CMakeLists.txt @@ -81,6 +81,8 @@ install( Turtlebot2/turtlebot2_simulated/turtlebot2/launch Turtlebot2/turtlebot2_simulated/turtlebot2/rviz Turtlebot2/turtlebot2_simulated/turtlebot2/urdf + Turtlebot2/Turtlebot2_physical/kobuki_launch/config + Turtlebot2/Turtlebot2_physical/kobuki_launch/launch # F1 f1/models f1/params diff --git a/CustomRobots/Turtlebot2/Turtlebot2_physical/kobuki_instructions/README.md b/CustomRobots/Turtlebot2/Turtlebot2_physical/kobuki_instructions/README.md index feee51704..211eeb3bc 100644 --- a/CustomRobots/Turtlebot2/Turtlebot2_physical/kobuki_instructions/README.md +++ b/CustomRobots/Turtlebot2/Turtlebot2_physical/kobuki_instructions/README.md @@ -1,50 +1,65 @@ # Setup Kobuki base 1. Download Kobuki_base repositories with drivers and utils inside your workspace (inside src directory): -~~~ + +``` vcs import < /kobuki_instructions/repos -~~~ +``` 2. Ensure you have all dependencies: -~~~ + +``` cd && rosdep install --from-paths src --ignore-src -r -y -~~~ +``` 3. Build workspace: -~~~ + +``` cd && colcon_build --symlink-install -~~~ +``` 4. Source workspace: -~~~ + +``` source /install/setup.bash -~~~ +``` + # + ## Try Kobuki + Connect serial cable to the Robot and **Switch Kobuki ON**. - + Kobuki’s default means of communication is over usb (it can instead use the serial comm port directly, more on that later). On most linux systems, your Kobuki will appear on /dev/ttyUSBO as soon as you connect the cable. This is a typical serial2usb device port and if you happen to be using more than one such device, Kobuki may appear at ttyUSB1, ttyUSB1, … -~~~ + +``` ls /dev/ttyUSB0 -~~~ +``` + In order to provide a constant identifier for the connection, use the udev rule prepared in kobuki_ftdi: -~~~ + +``` sudo cp /src/kobuki_ftdi/60-kobuki.rules /etc/udev/rules.d sudo service udev reload sudo service udev restart -~~~ +``` + Check for existance of `/dev/kobuki` -~~~ + +``` ls /dev/kobuki -~~~ +``` Does kobuki appear as USB device? -~~~ + +``` lsusb 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC -~~~ +``` + Do you see it in dmesg when you insert the usb cable? -~~~ + +``` dmesg [ 118.984126] usb 3-1: new full-speed USB device number 5 using xhci_hcd [ 119.139253] usb 3-1: New USB device found, idVendor=0403, idProduct=6001 @@ -59,18 +74,20 @@ dmesg [ 119.152505] ftdi_sio 3-1:1.0: FTDI USB Serial Device converter detected [ 119.152530] usb 3-1: Detected FT232RL [ 119.152665] usb 3-1: FTDI USB Serial Device converter now attached to ttyUSB0 -~~~ +``` + and when you remove it? -~~~ + +``` dmesg [ 184.386124] usb 3-1: USB disconnect, device number 5 [ 184.386507] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0 [ 184.386547] ftdi_sio 3-1:1.0: device disconnected -~~~ +``` Get the serial number: -~~~ +``` sudo /install/kobuki_ftdi/lib/kobuki_ftdi/get_serial_number 1 device(s) found. @@ -78,17 +95,43 @@ sudo /install/kobuki_ftdi/lib/kobuki_ftdi/get_serial_number Manufacturer : Yujin Robot Product : iClebo Kobuki Serial Number: kobuki_A505QO28 -~~~ - +``` Finally try to move Kobuki robot: + 1. Launch Kobuki_node with specific configuration ( provided inside kobuki_launch package): -~~~ + +``` ros2 launch kobuki_launch kobuki_base.launch.py # check that ros topics appear: ros2 topic list # teleoperate robot: ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args --remap /cmd_vel:=/commands/velocity -~~~ +``` + +_Change topic names if necessary inside kobuki_ros/kobuki_node/src/kobuki_ros.cpp_ -*Change topic names if necessary inside kobuki_ros/kobuki_node/src/kobuki_ros.cpp* \ No newline at end of file +cd /home/ws +apt install ros-humble-image-geometry libuvc-dev nlohmann-json3-dev +apt install ros-humble-diagnostic-updater +apt install ros-humble-image-publisher +cd src/CustomRobots/Turtlebot2/Turtlebot2_physical +vcs import < kobuki_instructions/repos +cd .. +cd .. +rosdep install --from-paths src --ignore-src -r -y +cd src/CustomRobots/ +cd Turtlebot2/Turtlebot2_physical/ +mv ecl ../../../ecl +mv kobuki_core ../../../kobuki_core +mv kobuki_ftdi ../../../kobuki_ftdi +mv kobuki_ros ../../../kobuki_ros +mv kobuki_iterfaces ../../../kobuki_iterfaces +mv kobuki_ros_iterfaces ../../../kobuki_ros_iterfaces +mv sophus ../../../sophus +cd ../../.. +colcon build --symlink-install --packages-ignore kobuki_ftdi +cd src +git clone https://github.com/Juancams/ros_astra_camera.git +cd .. +colcon build --symlink-install --packages-ignore kobuki_ftdi diff --git a/CustomRobots/Turtlebot2/Turtlebot2_physical/kobuki_launch/launch/kobuki_base.launch.py b/CustomRobots/Turtlebot2/Turtlebot2_physical/kobuki_launch/launch/kobuki_base.launch.py index 1660f5836..2eb23afd3 100644 --- a/CustomRobots/Turtlebot2/Turtlebot2_physical/kobuki_launch/launch/kobuki_base.launch.py +++ b/CustomRobots/Turtlebot2/Turtlebot2_physical/kobuki_launch/launch/kobuki_base.launch.py @@ -3,10 +3,11 @@ from launch import LaunchDescription from launch_ros.actions import Node import yaml +from launch_ros.substitutions import FindPackageShare def generate_launch_description(): - shared_dir = get_package_share_directory("kobuki_launch") + shared_dir = FindPackageShare(package="custom_robots").find("custom_robots") params_file = os.path.join(shared_dir, "config", "kobuki_node_params.yaml") with open(params_file, "r") as f: diff --git a/Launchers/follow_person_real.launch.py b/Launchers/follow_person_real.launch.py new file mode 100644 index 000000000..77919a79f --- /dev/null +++ b/Launchers/follow_person_real.launch.py @@ -0,0 +1,119 @@ +import os +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.conditions import IfCondition, UnlessCondition +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import Command, LaunchConfiguration, PythonExpression +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare + + +def generate_launch_description(): + + # Set the path to the Gazebo ROS package + pkg_gazebo_ros = FindPackageShare(package="gazebo_ros").find("gazebo_ros") + + # Set the path to the Turtlebot2 ROS package + pkg_share_dir = FindPackageShare(package="custom_robots").find("custom_robots") + + # Set Turtlebot2 Arguments + x_turtlebot2_position = "0" + y_turtlebot2_position = "10" + z_turtlebot2_position = "0" + + declare_x_position_cmd = DeclareLaunchArgument( + "-x", + default_value=x_turtlebot2_position, + description="Position on the axis x of Turtlebot2", + ) + declare_y_position_cmd = DeclareLaunchArgument( + "-y", + default_value=y_turtlebot2_position, + description="Position on the axis y of Turtlebot2", + ) + declare_z_position_cmd = DeclareLaunchArgument( + "-z", + default_value=z_turtlebot2_position, + description="Position on the axis z of Turtlebot2", + ) + + world_file_name = "hospital_follow_person.world" + worlds_dir = "/opt/jderobot/Worlds" + world_path = os.path.join(worlds_dir, world_file_name) + + # Set the path to the SDF model files + gazebo_models_path = os.path.join(pkg_share_dir, "models") + os.environ["GAZEBO_MODEL_PATH"] = ( + f"{os.environ.get('GAZEBO_MODEL_PATH', '')}:{':'.join(gazebo_models_path)}" + ) + + ########### YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE ############## + # Launch configuration variables specific to simulation + headless = LaunchConfiguration("headless") + use_sim_time = LaunchConfiguration("use_sim_time") + use_simulator = LaunchConfiguration("use_simulator") + world = LaunchConfiguration("world") + + declare_simulator_cmd = DeclareLaunchArgument( + name="headless", + default_value="False", + description="Whether to execute gzclient", + ) + + declare_use_sim_time_cmd = DeclareLaunchArgument( + name="use_sim_time", + default_value="False", + description="Use simulation (Gazebo) clock if true", + ) + + declare_use_simulator_cmd = DeclareLaunchArgument( + name="use_simulator", + default_value="False", + description="Whether to start the simulator", + ) + + declare_world_cmd = DeclareLaunchArgument( + name="world", + default_value=world_path, + description="Full path to the world model file to load", + ) + + # Specify the actions + + # Start Gazebo server + start_gazebo_server_cmd = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_gazebo_ros, "launch", "gzserver.launch.py") + ), + condition=IfCondition(use_simulator), + launch_arguments={"world": world, "pause": "true"}.items(), + ) + + start_turtlebot2_cmd = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(pkg_share_dir, "launch", "kobuki_base.launch.py") + ), + launch_arguments={ + "-x": x_turtlebot2_position, + "-y": y_turtlebot2_position, + "-z": z_turtlebot2_position, + }.items(), + ) + + # Create the launch description and populate + ld = LaunchDescription() + + # Declare the launch options + ld.add_action(declare_simulator_cmd) + ld.add_action(declare_use_sim_time_cmd) + ld.add_action(declare_use_simulator_cmd) + ld.add_action(declare_world_cmd) + ld.add_action(declare_x_position_cmd) + ld.add_action(declare_y_position_cmd) + ld.add_action(declare_z_position_cmd) + + # Add any actions + ld.add_action(start_gazebo_server_cmd) + ld.add_action(start_turtlebot2_cmd) + + return ld diff --git a/database/universes.sql b/database/universes.sql index a47e2eb9c..1341d31b9 100644 --- a/database/universes.sql +++ b/database/universes.sql @@ -179,6 +179,7 @@ COPY public.universes (id, name, world_id, robot_id) FROM stdin; 52 Montreal Circuit Classic 52 0 53 Nurburgring Circuit Classic 53 0 54 Vacuums House Roof Classic 54 0 +55 Real Follow Person 55 0 \. @@ -243,6 +244,7 @@ COPY public.worlds (id, name, launch_file_path, tools_config, ros_version, type, 52 Montreal Circuit Classic /opt/jderobot/Launchers/montreal_circuit_classic.launch.py None ROS2 gazebo {0.0,0.0,0.0,0.0,0.0,0.0} 53 Nurburgring Circuit Classic /opt/jderobot/Launchers/nurburgring_circuit_classic.launch.py None ROS2 gazebo {0.0,0.0,0.0,0.0,0.0,0.0} 54 Vacuums House Roof Classic /opt/jderobot/Launchers/montecarlo_visual_loc_classic.launch.py None ROS2 gazebo {0.0,0.0,0.0,0.0,0.0,0.0} +55 Real Follow Person /opt/jderobot/Launchers/follow_person_real.launch.py None ROS2 physical {0.0,0.0,0.0,0.0,0.0,0.0} \. --