-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
319 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,93 @@ | ||
# Copyright 2023 RT Corporation | ||
# | ||
# 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 sciurus17_description.robot_description_loader import RobotDescriptionLoader | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument | ||
from launch_ros.actions import SetParameter | ||
from launch.substitutions import LaunchConfiguration | ||
from launch_ros.actions import Node | ||
import yaml | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.substitutions import LaunchConfiguration | ||
from moveit_configs_utils import MoveItConfigsBuilder | ||
from moveit_configs_utils.launches import generate_move_group_launch | ||
from moveit_configs_utils.launches import generate_moveit_rviz_launch | ||
from moveit_configs_utils.launches import generate_static_virtual_joint_tfs_launch | ||
from moveit_configs_utils.launches import generate_rsp_launch | ||
from sciurus17_description.robot_description_loader import RobotDescriptionLoader | ||
from ament_index_python.packages import get_package_share_directory | ||
|
||
|
||
from ament_index_python.packages import get_package_share_directory | ||
|
||
|
||
def generate_launch_description(): | ||
ld = LaunchDescription() | ||
description_loader = RobotDescriptionLoader() | ||
|
||
ld.add_action( | ||
DeclareLaunchArgument( | ||
'loaded_description', | ||
default_value=description_loader.load(), | ||
description='Set robot_description text. \ | ||
It is recommended to use RobotDescriptionLoader() in sciurus17_description.' | ||
) | ||
) | ||
|
||
moveit_config = ( | ||
MoveItConfigsBuilder("sciurus17") | ||
.planning_scene_monitor( | ||
publish_robot_description=True, | ||
publish_robot_description_semantic=True, | ||
) | ||
.trajectory_execution(file_path="config/moveit_controllers.yaml") | ||
.planning_pipelines(pipelines=["ompl"]) | ||
.moveit_cpp( | ||
file_path=get_package_share_directory("sciurus17_moveit_config") | ||
+ "/config/moveit_cpp.yaml" | ||
) | ||
.to_moveit_configs() | ||
) | ||
|
||
moveit_config.robot_description = { | ||
'robot_description': LaunchConfiguration('loaded_description') | ||
} | ||
|
||
moveit_config.move_group_capabilities = { | ||
"capabilities": "" | ||
} | ||
|
||
declare_example_name = DeclareLaunchArgument( | ||
'example', default_value='pick_and_place_left_arm', | ||
description=('Set an example executable name: ' | ||
'[gripper_control, neck_control, waist_control,' | ||
'pick_and_place_right_arm_waist, pick_and_place_left_arm]') | ||
) | ||
|
||
example_node = Node( | ||
name=[LaunchConfiguration('example'), '_node'], | ||
package='sciurus17_examples_py', | ||
executable=LaunchConfiguration('example'), | ||
output='screen', | ||
parameters=[moveit_config.to_dict()], | ||
) | ||
|
||
ld.add_action(declare_example_name) | ||
ld.add_action(example_node) | ||
|
||
return ld |
This file contains 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,23 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>sciurus17_examples_py</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="[email protected]">ubuntu</maintainer> | ||
<license>TODO: License declaration</license> | ||
|
||
<exec_depend>rclpy</exec_depend> | ||
<exec_depend>std_msgs</exec_depend> | ||
<exec_depend>moveit</exec_depend> | ||
<exec_depend>moveit_py</exec_depend> | ||
|
||
<test_depend>ament_copyright</test_depend> | ||
<test_depend>ament_flake8</test_depend> | ||
<test_depend>ament_pep257</test_depend> | ||
<test_depend>python3-pytest</test_depend> | ||
|
||
<export> | ||
<build_type>ament_python</build_type> | ||
</export> | ||
</package> |
Empty file.
Empty file.
70 changes: 70 additions & 0 deletions
70
sciurus17_examples_py/sciurus17_examples_py/pick_and_place_left_arm.py
This file contains 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,70 @@ | ||
import time | ||
|
||
# generic ros libraries | ||
import rclpy | ||
from rclpy.logging import get_logger | ||
|
||
# moveit python library | ||
from moveit.core.robot_state import RobotState | ||
from moveit.planning import ( | ||
MoveItPy, | ||
MultiPipelinePlanRequestParameters, | ||
) | ||
|
||
def plan_and_execute( | ||
robot, | ||
planning_component, | ||
logger, | ||
single_plan_parameters=None, | ||
multi_plan_parameters=None, | ||
sleep_time=0.0, | ||
): | ||
"""Helper function to plan and execute a motion.""" | ||
# plan to goal | ||
logger.info("Planning trajectory") | ||
if multi_plan_parameters is not None: | ||
plan_result = planning_component.plan( | ||
multi_plan_parameters=multi_plan_parameters | ||
) | ||
elif single_plan_parameters is not None: | ||
plan_result = planning_component.plan( | ||
single_plan_parameters=single_plan_parameters | ||
) | ||
else: | ||
plan_result = planning_component.plan() | ||
|
||
# execute the plan | ||
if plan_result: | ||
logger.info("Executing plan") | ||
robot_trajectory = plan_result.trajectory | ||
robot.execute(robot_trajectory, controllers=[]) | ||
else: | ||
logger.error("Planning failed") | ||
|
||
time.sleep(sleep_time) | ||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
logger = get_logger("moveit_py.pick_and_place_left_arm") | ||
|
||
# instantiate MoveItPy instance and get planning component | ||
sciurus17 = MoveItPy(node_name="pick_and_place_left_arm") | ||
l_arm = sciurus17.get_planning_component("l_arm_group") | ||
logger.info("MoveItPy instance created") | ||
|
||
# set plan start state using predefined state | ||
l_arm.set_start_state_to_current_state() | ||
|
||
# set pose goal using predefined state | ||
l_arm.set_goal_state(configuration_name="l_arm_init_pose") | ||
|
||
# plan to goal | ||
plan_and_execute(sciurus17, l_arm, logger, sleep_time=3.0) | ||
|
||
# related Issue | ||
# https://github.com/moveit/moveit2/issues/2693 | ||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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,4 @@ | ||
[develop] | ||
script_dir=$base/lib/sciurus17_examples_py | ||
[install] | ||
install_scripts=$base/lib/sciurus17_examples_py |
This file contains 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,30 @@ | ||
import os | ||
from glob import glob | ||
|
||
from setuptools import find_packages, setup | ||
|
||
package_name = 'sciurus17_examples_py' | ||
|
||
setup( | ||
name=package_name, | ||
version='0.0.0', | ||
packages=find_packages(exclude=['test']), | ||
data_files=[ | ||
('share/ament_index/resource_index/packages', | ||
['resource/' + package_name]), | ||
('share/' + package_name, ['package.xml']), | ||
(os.path.join('share', package_name, 'launch'), glob(os.path.join('launch', '*launch.[pxy][yma]*'))), | ||
], | ||
install_requires=['setuptools'], | ||
zip_safe=True, | ||
maintainer='ubuntu', | ||
maintainer_email='[email protected]', | ||
description='TODO: Package description', | ||
license='TODO: License declaration', | ||
tests_require=['pytest'], | ||
entry_points={ | ||
'console_scripts': [ | ||
'pick_and_place_left_arm = sciurus17_examples_py.pick_and_place_left_arm:main', | ||
], | ||
}, | ||
) |
This file contains 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,25 @@ | ||
# Copyright 2015 Open Source Robotics Foundation, Inc. | ||
# | ||
# 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 ament_copyright.main import main | ||
import pytest | ||
|
||
|
||
# Remove the `skip` decorator once the source file(s) have a copyright header | ||
@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') | ||
@pytest.mark.copyright | ||
@pytest.mark.linter | ||
def test_copyright(): | ||
rc = main(argv=['.', 'test']) | ||
assert rc == 0, 'Found errors' |
This file contains 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,25 @@ | ||
# Copyright 2017 Open Source Robotics Foundation, Inc. | ||
# | ||
# 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 ament_flake8.main import main_with_errors | ||
import pytest | ||
|
||
|
||
@pytest.mark.flake8 | ||
@pytest.mark.linter | ||
def test_flake8(): | ||
rc, errors = main_with_errors(argv=[]) | ||
assert rc == 0, \ | ||
'Found %d code style errors / warnings:\n' % len(errors) + \ | ||
'\n'.join(errors) |
This file contains 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,23 @@ | ||
# Copyright 2015 Open Source Robotics Foundation, Inc. | ||
# | ||
# 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 ament_pep257.main import main | ||
import pytest | ||
|
||
|
||
@pytest.mark.linter | ||
@pytest.mark.pep257 | ||
def test_pep257(): | ||
rc = main(argv=['.', 'test']) | ||
assert rc == 0, 'Found code style errors / warnings' |
This file contains 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,26 @@ | ||
planning_scene_monitor_options: | ||
name: "planning_scene_monitor" | ||
robot_description: "robot_description" | ||
joint_state_topic: "/joint_states" | ||
attached_collision_object_topic: "/moveit_cpp/planning_scene_monitor" | ||
publish_planning_scene_topic: "/moveit_cpp/publish_planning_scene" | ||
monitored_planning_scene_topic: "/moveit_cpp/monitored_planning_scene" | ||
wait_for_initial_state_timeout: 10.0 | ||
|
||
planning_pipelines: | ||
pipeline_names: ["ompl"] | ||
|
||
plan_request_params: | ||
planning_attempts: 1 | ||
planning_pipeline: ompl | ||
max_velocity_scaling_factor: 1.0 | ||
max_acceleration_scaling_factor: 1.0 | ||
|
||
ompl_rrtc: # Namespace for individual plan request | ||
plan_request_params: # PlanRequestParameters similar to the ones that are used by the single pipeline planning of moveit_cpp | ||
planning_attempts: 1 # Number of attempts the planning pipeline tries to solve a given motion planning problem | ||
planning_pipeline: ompl # Name of the pipeline that is being used | ||
planner_id: "RRTConnectkConfigDefault" # Name of the specific planner to be used by the pipeline | ||
max_velocity_scaling_factor: 1.0 # Velocity scaling parameter for the trajectory generation algorithm that is called (if configured) after the path planning | ||
max_acceleration_scaling_factor: 1.0 # Acceleration scaling parameter for the trajectory generation algorithm that is called (if configured) after the path planning | ||
planning_time: 1.0 # Time budget for the motion plan request. If the planning problem cannot be solved within this time, an empty solution with error code is returned |