Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hunter Gazebo Package Development #4

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions hunter_base/config/hardware_controllers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
controller_manager:
ros__parameters:
update_rate: 50
use_sim_time: false

diff_drive_controller:
type: hunter_controller/HunterController
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

diff_drive_controller:
ros__parameters:

publish_rate: 50.0

base_frame_id: base_link

left_wheel_names: ['front_left_wheel_joint', 'back_left_wheel_joint']
right_wheel_names: ['front_right_wheel_joint', 'back_right_wheel_joint']
wheel_separation: 0.525
wheel_radius: 0.14

use_stamped_vel: false

# open_loop: false

# wheels_per_side: x
# wheel_separation_multiplier: x
# left_wheel_radius_multiplier: x
# right_wheel_radius_multiplier: x

# odom_frame_id: x
# pose_covariance_diagonal: x
# twist_covariance_diagonal: x
# open_loop: x
# enable_odom_tf: x

# cmd_vel_timeout: x
# publish_limited_velocity: x
# velocity_rolling_window_size: x


# linear.x.has_velocity_limits: false
# linear.x.has_acceleration_limits: false
# linear.x.has_jerk_limits: false
# linear.x.max_velocity: NAN
# linear.x.min_velocity: NAN
# linear.x.max_acceleration: NAN
# linear.x.min_acceleration: NAN
# linear.x.max_jerk: NAN
# linear.x.min_jerk: NAN

# angular.z.has_velocity_limits: false
# angular.z.has_acceleration_limits: false
# angular.z.has_jerk_limits: false
# angular.z.max_velocity: NAN
# angular.z.min_velocity: NAN
# angular.z.max_acceleration: NAN
# angular.z.min_acceleration: NAN
# angular.z.max_jerk: NAN
# angular.z.min_jerk: NAN




# joint_broad:
# ros__parameters:
9 changes: 9 additions & 0 deletions hunter_base/hunter_base.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<library path="hunter_base">
<class name="hunter_base/DiffBotSystemHardware"
type="hunter_base::DiffBotSystemHardware"
base_class_type="hardware_interface::SystemInterface">
<description>
The ros2_control DiffBot example using a system hardware interface-type. It uses velocity command and position state interface. The example is the starting point to implement a hardware interface for differential-drive mobile robots.
</description>
</class>
</library>
133 changes: 133 additions & 0 deletions hunter_base/launch/hunter.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Copyright 2020 ros2_control Development Team
#
# 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.

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, RegisterEventHandler
from launch.conditions import IfCondition
from launch.event_handlers import OnProcessExit
from launch.substitutions import Command, FindExecutable, PathJoinSubstitution, LaunchConfiguration

from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
# Declare arguments
declared_arguments = []
declared_arguments.append(
DeclareLaunchArgument(
"gui",
default_value="true",
description="Start RViz2 automatically with this launch file.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"use_mock_hardware",
default_value="true",
description="Start robot with mock hardware mirroring command to its states.",
)
)

# Initialize Arguments
# gui = LaunchConfiguration("gui")
use_mock_hardware = LaunchConfiguration("use_mock_hardware")

# Get URDF via xacro
robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[FindPackageShare("hunter_description"), "description", "hunter_hardware.urdf.xacro"]
),
" ",
"use_mock_hardware:=",
use_mock_hardware,
]
)
robot_description = {"robot_description": robot_description_content}

robot_controllers = PathJoinSubstitution(
[
FindPackageShare("hunter_base"),
"config",
"hardware_controllers.yaml",
]
)
# rviz_config_file = PathJoinSubstitution(
# [FindPackageShare("ros2_control_demo_description"), "diffbot/rviz", "diffbot.rviz"]
# )

control_node = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_description, robot_controllers],
output="both",
)
robot_state_pub_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
remappings=[
("/diff_drive_controller/cmd_vel_unstamped", "/cmd_vel"),
],
)
# rviz_node = Node(
# package="rviz2",
# executable="rviz2",
# name="rviz2",
# output="log",
# arguments=["-d", rviz_config_file],
# condition=IfCondition(gui),
# )

joint_state_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"],
)

robot_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["diff_drive_controller", "--controller-manager", "/controller_manager"],
)

# Delay rviz start after `joint_state_broadcaster`
# delay_rviz_after_joint_state_broadcaster_spawner = RegisterEventHandler(
# event_handler=OnProcessExit(
# target_action=joint_state_broadcaster_spawner,
# on_exit=[rviz_node],
# )
# )

# Delay start of robot_controller after `joint_state_broadcaster`
delay_robot_controller_spawner_after_joint_state_broadcaster_spawner = RegisterEventHandler(
event_handler=OnProcessExit(
target_action=joint_state_broadcaster_spawner,
on_exit=[robot_controller_spawner],
)
)

nodes = [
control_node,
robot_state_pub_node,
joint_state_broadcaster_spawner,
# delay_rviz_after_joint_state_broadcaster_spawner,
delay_robot_controller_spawner_after_joint_state_broadcaster_spawner,
]

return LaunchDescription(declared_arguments +nodes)
61 changes: 61 additions & 0 deletions hunter_base/tmule/launch_real.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
session: teletop_robot
init_cmd: |
echo " "
echo " "
echo " "
echo "Running Initialisation" | awk '{ gsub("Running Initialisation", "\033[1;21m\033[1;30m&\033[0m"); print }' ;

#exec /bin/bash
cd @TMULE_CONFIG_DIR@ || true
set -o pipefail
function export_default () {
var_name="$1"
var_default="$2"
eval $var_name="${!var_name:-$var_default}"
export $var_name
echo " $0 -> $var_name=${!var_name}"
}

# source ROS
# source "/opt/ros/$(rosversion -d)/setup.bash"

# source the lcastor catkin workspace
source "$HOME/.bashrc"
# export_default CATKIN_WS "$HOME/ros_ws"

# robot specific arguments
# export_default TIAGO_EE "pal-gripper"
# export_default TIAGO_TYPE "titanium"

# world arguments
#export_default WORLD "small_office"
#export_default GZ_GUI "true"

# navigation specific arguments
# export_default GLOBAL_PLANNER "global_planner"
# export_default LOCAL_PLANNER "teb"
# export_default LOCALIZATION "amcl"
# export_default CONFIG_BASE_PATH "$(rospack find pal_navigation_cfg_tiago)"
# export_default MAP "$HOME/.pal/tiago_maps/configurations/$WORLD"
# export_default LASER_MODEL "sick-571"
# export_default RGBD_SENSORS "false"
# export_default BASE_TYPE "pmb2"

# PNP specific arguments
# export_default PNP_PLANS "$CATKIN_WS/src/LCASTOR/lcastor_plans"
# export_default PNP_ACTIONS "$CATKIN_WS/src/LCASTOR/lcastor_actions"
# export_default PNP_CONDITIONS "$CATKIN_WS/src/LCASTOR/lcastor_conditions"

windows:
- name: hunter_launch
tags: ['core']
panes:
- 'ros2 launch hunter_base hunter.launch.py'
# - name: joy
# tags: ['joy']
# panes:
# - 'ros2 run teleop_twist_joy teleop_node --ros-args -r /cmd_vel:=/diff_cont/cmd_vel_unstamped'
# - name: logi_joy
# tags: ['logi']
# panes:
# - 'ros2 run joystick_ros2 joystick_ros2'
Loading
Loading