17 from copy
import deepcopy
19 from moveit_msgs.srv
import CheckIfRobotStateExistsInWarehouse
as HasState
20 from moveit_msgs.srv
import GetRobotStateFromWarehouse
as GetState
21 from moveit_msgs.srv
import SaveRobotStateToWarehouse
as SaveState
22 from moveit_msgs.srv
import ListRobotStatesInWarehouse
as ListState
23 from moveit_msgs.msg
import RobotState
28 self.
_get_state = rospy.ServiceProxy(
"/get_robot_state", GetState)
29 self.
_has_state = rospy.ServiceProxy(
"/has_robot_state", HasState)
30 self.
_list_states = rospy.ServiceProxy(
"/list_robot_states", ListState)
31 self.
_save_state = rospy.ServiceProxy(
"/save_robot_state", SaveState)
35 for name
in list_of_states:
40 state = self.
_get_state(name,
'').state.joint_state
42 position = state.position
43 self.
_dictionary[name] = {name: position[n]
for n, name
in enumerate(names)}
45 rospy.logerr(
"State %s not present in the warehouse." % name)
48 for entry
in dictionary_trajectory:
57 pp = pprint.PrettyPrinter()
58 with open(file_name,
"w")
as output:
59 output.write(
'warehouse_states = %s\n' % pp.pformat(self.
_dictionary))
63 for entry
in named_trajectory:
64 new_entry = deepcopy(entry)
65 if 'name' in new_entry:
67 new_entry[
'joint_angles'] = self.
_dictionary[new_entry[
'name']]
70 rospy.logwarn(
"Entry named %s not present in dictionary. Not replacing." % name)
71 new_trajectory.append(new_entry)
77 rospy.logwarn(
"State named %s already in warehouse, not re-adding." % name)
80 state.joint_state.name = self.
_dictionary[name].keys()
81 state.joint_state.position = self.
_dictionary[name].values()
def extract_list(self, list_of_states)
def __init__(self, start_dictionary={})
def convert_trajectory(self, named_trajectory)
def extract_from_trajectory(self, dictionary_trajectory)
def repopulate_warehouse(self)
def output_module(self, file_name)
def extract_one_state(self, name)