-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Assisted teleop simple commander #3198
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
Merged
SteveMacenski
merged 14 commits into
ros-navigation:main
from
jwallace42:assisted_teleop_simple_commander
Sep 26, 2022
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
34459b9
add assisted teleop to python api
jwallace42 c76caea
cleanup
jwallace42 40a833f
assisted teleop demo
jwallace42 f8e9107
rename
jwallace42 886caae
lint
jwallace42 4dbee30
code review
jwallace42 4295649
trigger build
jwallace42 81b9077
flake8 fix
jwallace42 573a818
break cashe
jwallace42 f6bfb7f
moved all v11 to v12
jwallace42 acb38f8
lint fix
jwallace42 82805cf
remove package dep
jwallace42 0d13c89
change default time allowance
jwallace42 2cc7158
Merge branch 'main' into planner_metrics
jwallace42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
nav2_simple_commander/launch/assisted_teleop_example_launch.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Copyright (c) 2021 Samsung Research America | ||
| # Copyright (c) 2022 Joshua Wallace | ||
| # | ||
| # 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 ExecuteProcess, IncludeLaunchDescription | ||
| from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
| from launch_ros.actions import Node | ||
|
|
||
|
|
||
| def generate_launch_description(): | ||
| warehouse_dir = get_package_share_directory('aws_robomaker_small_warehouse_world') | ||
| nav2_bringup_dir = get_package_share_directory('nav2_bringup') | ||
| python_commander_dir = get_package_share_directory('nav2_simple_commander') | ||
|
|
||
| map_yaml_file = os.path.join(warehouse_dir, 'maps', '005', 'map.yaml') | ||
| world = os.path.join(python_commander_dir, 'warehouse.world') | ||
|
|
||
| # start the simulation | ||
| start_gazebo_server_cmd = ExecuteProcess( | ||
| cmd=['gzserver', '-s', 'libgazebo_ros_factory.so', world], | ||
| cwd=[warehouse_dir], output='screen') | ||
|
|
||
| start_gazebo_client_cmd = ExecuteProcess( | ||
| cmd=['gzclient'], | ||
| cwd=[warehouse_dir], output='screen') | ||
|
|
||
| urdf = os.path.join(nav2_bringup_dir, 'urdf', 'turtlebot3_waffle.urdf') | ||
| start_robot_state_publisher_cmd = Node( | ||
| package='robot_state_publisher', | ||
| executable='robot_state_publisher', | ||
| name='robot_state_publisher', | ||
| output='screen', | ||
| arguments=[urdf]) | ||
|
|
||
| # start the visualization | ||
| rviz_cmd = IncludeLaunchDescription( | ||
| PythonLaunchDescriptionSource( | ||
| os.path.join(nav2_bringup_dir, 'launch', 'rviz_launch.py')), | ||
| launch_arguments={'namespace': '', | ||
| 'use_namespace': 'False'}.items()) | ||
|
|
||
| # start navigation | ||
| bringup_cmd = IncludeLaunchDescription( | ||
| PythonLaunchDescriptionSource( | ||
| os.path.join(nav2_bringup_dir, 'launch', 'bringup_launch.py')), | ||
| launch_arguments={'map': map_yaml_file}.items()) | ||
|
|
||
| # start the demo autonomy task | ||
| demo_cmd = Node( | ||
| package='nav2_simple_commander', | ||
| executable='example_assisted_teleop', | ||
| emulate_tty=True, | ||
| output='screen') | ||
|
|
||
| ld = LaunchDescription() | ||
| ld.add_action(start_gazebo_server_cmd) | ||
| ld.add_action(start_gazebo_client_cmd) | ||
| ld.add_action(start_robot_state_publisher_cmd) | ||
| ld.add_action(rviz_cmd) | ||
| ld.add_action(bringup_cmd) | ||
| ld.add_action(demo_cmd) | ||
| return ld | ||
56 changes: 56 additions & 0 deletions
56
nav2_simple_commander/nav2_simple_commander/example_assisted_teleop.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #! /usr/bin/env python3 | ||
| # Copyright 2022 Joshua Wallace | ||
| # | ||
| # 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 time import sleep | ||
|
|
||
| from geometry_msgs.msg import PoseStamped | ||
| from nav2_simple_commander.robot_navigator import BasicNavigator | ||
| import rclpy | ||
|
|
||
| """ | ||
| Basic navigation demo to go to pose. | ||
| """ | ||
|
|
||
|
|
||
| def main(): | ||
| rclpy.init() | ||
|
|
||
| navigator = BasicNavigator() | ||
|
|
||
| # Set our demo's initial pose | ||
| initial_pose = PoseStamped() | ||
| initial_pose.header.frame_id = 'map' | ||
| initial_pose.header.stamp = navigator.get_clock().now().to_msg() | ||
| initial_pose.pose.position.x = 3.45 | ||
| initial_pose.pose.position.y = 2.15 | ||
| initial_pose.pose.orientation.z = 1.0 | ||
| initial_pose.pose.orientation.w = 0.0 | ||
| navigator.setInitialPose(initial_pose) | ||
|
|
||
| # Wait for navigation to fully activate, since autostarting nav2 | ||
| navigator.waitUntilNav2Active() | ||
|
|
||
| navigator.assistedTeleop(time_allowance=20) | ||
| while not navigator.isTaskComplete(): | ||
| # Publish twist commands to be filtered by the assisted teleop action | ||
| sleep(0.2) | ||
| pass | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| navigator.lifecycleShutdown() | ||
| exit(0) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.