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

Decorate MoveItConfigs with dataclass #1308

Merged
merged 1 commit into from
Jun 3, 2022
Merged
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
153 changes: 26 additions & 127 deletions moveit_configs_utils/moveit_configs_utils/moveit_configs_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
"""

from pathlib import Path
from typing import Optional, List
from typing import Optional, List, Dict
import logging
import re
from dataclasses import dataclass, field
from ament_index_python.packages import get_package_share_directory

from launch_param_builder import ParameterBuilder, load_yaml, load_xacro
Expand Down Expand Up @@ -83,134 +84,32 @@ def get_pattern_matches(folder, pattern):
return matches


class MoveItConfigs(object):
@dataclass(slots=True)
class MoveItConfigs:
"""Class containing MoveIt related parameters."""

__slots__ = [
"__package_path",
"__robot_description",
"__robot_description_semantic",
"__robot_description_kinematics",
"__planning_pipelines",
"__trajectory_execution",
"__planning_scene_monitor",
"__move_group_capabilities",
"__joint_limits",
"__moveit_cpp",
"__cartesian_limits",
]

def __init__(self):
# A pathlib Path to the moveit config package
self.package_path = None
# A dictionary that has the contents of the URDF file.
self.robot_description = {}
# A dictionary that has the contents of the SRDF file.
self.robot_description_semantic = {}
# A dictionary IK solver specific parameters.
self.robot_description_kinematics = {}
# A dictionary that contains the planning pipelines parameters.
self.planning_pipelines = {}
# A dictionary contains parameters for trajectory execution & moveit controller managers.
self.trajectory_execution = {}
# A dictionary that have the planning scene monitor's parameters.
self.planning_scene_monitor = {}
# A dictionary containing move_group's non-default capabilities.
self.move_group_capabilities = {}
# A dictionary containing the overridden position/velocity/acceleration limits.
self.joint_limits = {}
# A dictionary containing MoveItCpp related parameters.
self.moveit_cpp = {}
# A dictionary containing the cartesian limits for the Pilz planner.
self.cartesian_limits = {}

@property
def package_path(self):
return self.__package_path

@package_path.setter
def package_path(self, value):
self.__package_path = value

@property
def robot_description(self):
return self.__robot_description

@robot_description.setter
def robot_description(self, value):
self.__robot_description = value

@property
def robot_description_semantic(self):
return self.__robot_description_semantic

@robot_description_semantic.setter
def robot_description_semantic(self, value):
self.__robot_description_semantic = value

@property
def robot_description_kinematics(self):
return self.__robot_description_kinematics

@robot_description_kinematics.setter
def robot_description_kinematics(self, value):
self.__robot_description_kinematics = value

@property
def planning_pipelines(self):
return self.__planning_pipelines

@planning_pipelines.setter
def planning_pipelines(self, value):
self.__planning_pipelines = value

@property
def trajectory_execution(self):
return self.__trajectory_execution

@trajectory_execution.setter
def trajectory_execution(self, value):
self.__trajectory_execution = value

@property
def planning_scene_monitor(self):
return self.__planning_scene_monitor

@planning_scene_monitor.setter
def planning_scene_monitor(self, value):
self.__planning_scene_monitor = value

@property
def move_group_capabilities(self):
return self.__move_group_capabilities

@move_group_capabilities.setter
def move_group_capabilities(self, value):
self.__move_group_capabilities = value

@property
def joint_limits(self):
return self.__joint_limits

@joint_limits.setter
def joint_limits(self, value):
self.__joint_limits = value

@property
def moveit_cpp(self):
return self.__moveit_cpp

@moveit_cpp.setter
def moveit_cpp(self, value):
self.__moveit_cpp = value

@property
def cartesian_limits(self):
return self.__cartesian_limits

@cartesian_limits.setter
def cartesian_limits(self, value):
self.__cartesian_limits = value
# A pathlib Path to the moveit config package
package_path: Optional[str] = None
# A dictionary that has the contents of the URDF file.
robot_description: Dict = field(default_factory=dict)
# A dictionary that has the contents of the SRDF file.
robot_description_semantic: Dict = field(default_factory=dict)
# A dictionary IK solver specific parameters.
robot_description_kinematics: Dict = field(default_factory=dict)
# A dictionary that contains the planning pipelines parameters.
planning_pipelines: Dict = field(default_factory=dict)
# A dictionary contains parameters for trajectory execution & moveit controller managers.
trajectory_execution: Dict = field(default_factory=dict)
# A dictionary that have the planning scene monitor's parameters.
planning_scene_monitor: Dict = field(default_factory=dict)
# A dictionary containing move_group's non-default capabilities.
move_group_capabilities: Dict = field(default_factory=dict)
# A dictionary containing the overridden position/velocity/acceleration limits.
joint_limits: Dict = field(default_factory=dict)
# A dictionary containing MoveItCpp related parameters.
moveit_cpp: Dict = field(default_factory=dict)
# A dictionary containing the cartesian limits for the Pilz planner.
cartesian_limits: Dict = field(default_factory=dict)

def to_dict(self):
parameters = {}
Expand Down