Skip to content

Instantly share code, notes, and snippets.

@BuckyI
Last active July 23, 2023 08:42
Show Gist options
  • Save BuckyI/ed673a982d73b693148060a00e6b54c2 to your computer and use it in GitHub Desktop.
Save BuckyI/ed673a982d73b693148060a00e6b54c2 to your computer and use it in GitHub Desktop.
[learning materials] some code in xxx_moveit_config package generated by moveit setup assistant
from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import generate_demo_launch
def generate_launch_description():
moveit_config = MoveItConfigsBuilder(
"ec66", package_name="elite_moveit_config"
).to_moveit_configs()
""""
What does `generate_demo_launch` do:
Get a LaunchDescription, basically it collects many launch description
It includes:
* declare arguments:
* db = False, debug = False, use_rviz = True
* static_virtual_joint_tfs: broadcast virtual joints [static_virtual_joint_tfs.launch.py]
* robot_state_publisher: publish tf for links [rsp.launch.py]
* move_group [move_group.launch.py]
* moveit_rviz [moveit_rviz.launch.py] if "use_rviz"
* warehouse_db (optional) [warehouse_db.launch.py] if "db"
* ros2_control_node + controller spawners: Fake joint driver
* ros2_control_node: controller_manager/ros2_control_node (specified in ros2_controllers.yaml)
* spawners: [spawn_controllers.launch.py] (specified in moveit_controllers.yaml)
"""
return generate_demo_launch(moveit_config)
<robot name="ec66">
<!--GROUPS: Representation of a set of joints and links. This can be useful for specifying DOF to plan for, defining arms, end effectors, etc-->
<!--LINKS: When a link is specified, the parent joint of that link (if it exists) is automatically included-->
<!--JOINTS: When a joint is specified, the child link of that joint (which will always exist) is automatically included-->
<!--CHAINS: When a chain is specified, all the links along the chain (including endpoints) are included in the group. Additionally, all the joints that are parents to included links are also included. This means that joints along the chain and the parent joint of the base link are included in the group-->
<!--SUBGROUPS: Groups can also be formed by referencing to already defined group names-->
<group name="test_group">
<chain base_link="base_link" tip_link="flan"/>
</group>
<!--GROUP STATES: Purpose: Define a named state for a particular group, in terms of joint values. This is useful to define states like 'folded arms'-->
<group_state name="home" group="test_group">
<joint name="joint1" value="0"/>
<joint name="joint2" value="-1.57"/>
<joint name="joint3" value="1.57"/>
<joint name="joint4" value="0"/>
<joint name="joint5" value="0"/>
<joint name="joint6" value="0"/>
</group_state>
<!--DISABLE COLLISIONS: By default it is assumed that any link of the robot could potentially come into collision with any other link in the robot. This tag disables collision checking between a specified pair of links. -->
<disable_collisions link1="base_link" link2="link1" reason="Adjacent"/>
<disable_collisions link1="base_link" link2="link2" reason="Never"/>
<disable_collisions link1="base_link" link2="link4" reason="Never"/>
<disable_collisions link1="link1" link2="link2" reason="Adjacent"/>
<disable_collisions link1="link1" link2="link3" reason="Never"/>
<disable_collisions link1="link1" link2="link4" reason="Never"/>
<disable_collisions link1="link2" link2="link3" reason="Adjacent"/>
<disable_collisions link1="link2" link2="link4" reason="Never"/>
<disable_collisions link1="link3" link2="link4" reason="Adjacent"/>
<disable_collisions link1="link3" link2="link5" reason="Never"/>
<disable_collisions link1="link4" link2="link5" reason="Adjacent"/>
<disable_collisions link1="link4" link2="link6" reason="Never"/>
<disable_collisions link1="link5" link2="link6" reason="Adjacent"/>
</robot>
from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import generate_move_group_launch
def generate_launch_description():
moveit_config = MoveItConfigsBuilder(
"ec66", package_name="elite_moveit_config"
).to_moveit_configs()
"""
generate_move_group_launch:
Get a LaunchDescription includes:
- declare parameter:
- debug = false
- allow_trajectory_execution = True
- publish_monitored_planning_scene = True
- capabilities = ""
- disable_capabilities = ""
- monitor_dynamics = False
- node: moveit_ros_move_group/move_group
"""
return generate_move_group_launch(moveit_config)
# MoveIt uses this configuration for controller management
moveit_controller_manager: moveit_simple_controller_manager/MoveItSimpleControllerManager
moveit_simple_controller_manager:
controller_names:
- elite_robo_arm_controller
- elite_robot_hand_controller
elite_robo_arm_controller:
type: FollowJointTrajectory
action_ns: follow_joint_trajectory
default: true
joints:
- joint1
- joint2
- joint3
- joint4
- joint5
- joint6
action_ns: follow_joint_trajectory
default: true
elite_robot_hand_controller:
type: FollowJointTrajectory
action_ns: follow_joint_trajectory
default: true
joints:
- joint6
action_ns: follow_joint_trajectory
default: true
from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import generate_moveit_rviz_launch
def generate_launch_description():
moveit_config = MoveItConfigsBuilder(
"ec66", package_name="elite_moveit_config"
).to_moveit_configs()
"""
generate_moveit_rviz_launch:
Get a LaunchDescription
- delare arguments:
debug = False
rviz_config = config/moveit.rviz
- node: rviz2/rviz2
"""
return generate_moveit_rviz_launch(moveit_config)
# This config file is used by ros2_control
controller_manager:
ros__parameters:
update_rate: 100 # Hz
elite_robo_arm_controller:
type: joint_trajectory_controller/JointTrajectoryController
elite_robot_hand_controller:
type: position_controllers/GripperActionController
joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster
elite_robo_arm_controller:
ros__parameters:
joints:
- joint1
- joint2
- joint3
- joint4
- joint5
- joint6
command_interfaces:
- position
state_interfaces:
- position
- velocity
elite_robot_hand_controller:
ros__parameters:
joint: joint6
from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import generate_rsp_launch
def generate_launch_description():
moveit_config = MoveItConfigsBuilder(
"ec66", package_name="elite_moveit_config"
).to_moveit_configs()
"""
generate_rsp_launch:
Get a LaunchDescription for robot state publisher (rsp)
- delare arguments: publish_frequency = 15.0
- node: robot_state_publisher/robot_state_publisher
- with parameter: robot_description, publish_frequency
"""
return generate_rsp_launch(moveit_config)
from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import generate_spawn_controllers_launch
def generate_launch_description():
moveit_config = MoveItConfigsBuilder(
"ec66", package_name="elite_moveit_config"
).to_moveit_configs()
"""
generate_spawn_controllers_launch:
Get a LaunchDescription with controller_manager/spawner nodes for:
- each controller (specified in moveit_config.trajectory_execution['moveit_simple_controller_manager']['controller_names'])
- joint_state_broadcaster
Note:
moveit_config.trajectory_execution, by default (if no path specified)
search for a file `configs/xxx_controllers.yaml`, desired name:
- `moveit_controllers.yaml`
- `moveit2_controllers.yaml`
- `${robot_name}_controllers.yaml`
"""
return generate_spawn_controllers_launch(moveit_config)
from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import generate_static_virtual_joint_tfs_launch
def generate_launch_description():
moveit_config = MoveItConfigsBuilder(
"ec66", package_name="elite_moveit_config"
).to_moveit_configs()
"""
generate_static_virtual_joint_tfs_launch:
get a launch description
include node: tf2_ros/static_transform_publisher
publish all virtual_joints specified in srdf
"""
return generate_static_virtual_joint_tfs_launch(moveit_config)
from moveit_configs_utils import MoveItConfigsBuilder
from moveit_configs_utils.launches import generate_warehouse_db_launch
def generate_launch_description():
moveit_config = MoveItConfigsBuilder(
"ec66", package_name="elite_moveit_config"
).to_moveit_configs()
"""
generate_warehouse_db_launch:
Get a LaunchDescription for warehouse database
- delacre arguments: moveit_warehouse_database_path = default_warehouse_mongo_db
Moveit_warehouse_database is a SQLite database
used by MoveIt! to store information
about robot configurations, trajectories, and other data.
"""
return generate_warehouse_db_launch(moveit_config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment