commit 98108f9e70cef7156eb659df1099138707b4da3f Author: Pimpest <82343504+Pimpest@users.noreply.github.com> Date: Wed Sep 25 01:43:15 2024 +0200 Simple ros2-controll mock setup diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ffbfbf3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.vscode/ +build/ +install/ +log/ \ No newline at end of file diff --git a/mg_wheel_interface/CMakeLists.txt b/mg_wheel_interface/CMakeLists.txt new file mode 100644 index 0000000..71437ab --- /dev/null +++ b/mg_wheel_interface/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.8) +project(mg_wheel_interface) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +install(DIRECTORY + launch assets + DESTINATION share/${PROJECT_NAME}/ +) + +ament_package() diff --git a/mg_wheel_interface/assets/mg_base.urdf b/mg_wheel_interface/assets/mg_base.urdf new file mode 100644 index 0000000..d65eb8b --- /dev/null +++ b/mg_wheel_interface/assets/mg_base.urdf @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + mock_components/GenericSystem + true + + + + + + + + + + + \ No newline at end of file diff --git a/mg_wheel_interface/assets/mg_base_controllers.yaml b/mg_wheel_interface/assets/mg_base_controllers.yaml new file mode 100644 index 0000000..67fe895 --- /dev/null +++ b/mg_wheel_interface/assets/mg_base_controllers.yaml @@ -0,0 +1,20 @@ +controller_manager: + ros__parameters: + update_rate: 100 + + diffdrive_controller: + type: diff_drive_controller/DiffDriveController + joint_state_publisher: + type: joint_state_broadcaster/JointStateBroadcaster + +diffdrive_controller: + ros__parameters: + left_wheel_names: ["left_motor"] + right_wheel_names: ["right_motor"] + + enable_odom_tf: true + odom_frame_id: odom + base_frame_id: base-link + + wheel_separation: 0.5 + wheel_radius: 0.1 \ No newline at end of file diff --git a/mg_wheel_interface/launch/launch.py b/mg_wheel_interface/launch/launch.py new file mode 100644 index 0000000..08adc49 --- /dev/null +++ b/mg_wheel_interface/launch/launch.py @@ -0,0 +1,47 @@ +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument, RegisterEventHandler, TimerAction +from launch.event_handlers import OnProcessStart +from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare + +from pathlib import Path + +def generate_launch_description(): + + basedir = FindPackageShare("mg_wheel_interface") + + urdfDescription = PathJoinSubstitution([basedir, "assets/mg_base.urdf"]) + yamlControllers = PathJoinSubstitution([basedir, "assets/mg_base_controllers.yaml"]) + + urdfDescription = Command([ + "cat ", + urdfDescription + ]) + + return LaunchDescription([ + Node( + package='robot_state_publisher', + executable='robot_state_publisher', + output="screen", + parameters=[{"robot_description": urdfDescription}] + ), + Node( + package="controller_manager", + executable="ros2_control_node", + parameters=[yamlControllers], + output="screen" + ), + Node( + package='controller_manager', + executable='spawner', + output="screen", + arguments=["joint_state_publisher"] + ), + Node( + package="controller_manager", + executable="spawner", + arguments=["diffdrive_controller", "--param-file", yamlControllers], + ) + ]) + diff --git a/mg_wheel_interface/package.xml b/mg_wheel_interface/package.xml new file mode 100644 index 0000000..6ea63c5 --- /dev/null +++ b/mg_wheel_interface/package.xml @@ -0,0 +1,28 @@ + + + + mg_wheel_interface + 0.0.1 + Interacts with the wheels + pimpest + Apache-2.0 + + ament_cmake + + pluginlib + hardware_interface + ros2launch + controller_manager + ros2_control + diff_drive_controller + robot_state_publisher + joint_state_broadcaster + rsl + + ament_lint_auto + ament_lint_common + + + ament_cmake + +