panda_gazebo.common.helpers
Module containing some additional helper functions used in the panda_gazebo package.
Module Contents
Functions
|
Converts a joint_state dictionary into a JointState msgs. |
|
Converts an action dictionary into a panda_gazebo |
Converts a :class:``panda_gazebo.msg.FollowJointTrajectoryActionGoal` action |
|
|
Converts a Controller_manager/list_controllers |
Translates the error code returned by the SimpleActionClient.get_result() |
|
|
Translates a MoveIt error code object into a human readable error message. |
|
De-capitalize the first letter of a string. |
|
Wrap one additional space around text if it is not already present. |
|
Function converts a list of values into human readable sentence. |
|
Removes empty dictionary keys from a dictionary and returns a cleaned up |
|
Removes non-unique items from a list. |
|
Returns the duplicates in a list. |
|
Function used to flatten a list containing sublists. It does this by calling |
|
Checks whether a topic contains an action server |
|
Calculates the norm of a quaternion. |
|
Normalizes a given quaternion. |
|
Calculates the norm of a vector. |
|
Normalizes a given vector. |
|
Shuts down the ROS node wait until it is shutdown and exits the script. |
Loads the joint limits of the Panda robot from the parameter server. |
- panda_gazebo.common.helpers.joint_state_dict_2_joint_state_msg(joint_state_dict, type='position')[source]
Converts a joint_state dictionary into a JointState msgs.
- Parameters:
- Returns:
A JoinState message.
- Return type:
sensor_msgs.msg.JointState
- Raises:
ValueError – If the type is not one of the expected values.
- panda_gazebo.common.helpers.action_dict_2_joint_trajectory_msg(action_dict, create_time_axis=True, time_axis_step=0.01)[source]
Converts an action dictionary into a panda_gazebo
FollowJointTrajectoryGoal
msgs.- Parameters:
- Returns:
- New FollowJointTrajectoryGoal
message.
- Return type:
- Raises:
ValuesError – When the action_dict is invalid.
- panda_gazebo.common.helpers.panda_action_msg_2_control_msgs_action_msg(panda_action_msg)[source]
Converts a :class:``panda_gazebo.msg.FollowJointTrajectoryActionGoal` action message into a control_msgs/FollowJointTrajectoryGoal action message.
- :param panda_action_msg
control_msgs.msg.FollowJointTrajectoryGoal
: Panda_gazebo follow joint trajectory goal message.
- Returns:
- Control_msgs follow joint
trajectory goal message.
- Return type:
control_msgs.msg.FollowJointTrajectoryGoal
- Raises:
TypeError – If panda_action_msg is not of type
panda_gazebo.msg.FollowJointTrajectoryGoal
.
- :param panda_action_msg
- panda_gazebo.common.helpers.controller_list_array_2_dict(controller_list_msgs)[source]
Converts a Controller_manager/list_controllers message into a controller information dictionary.
- Parameters:
controller_list_msgs (
controller_manager_msgs.srv.ListControllersResponse
) – Controller_manager/list_controllers service response message.- Returns:
Dictionary containing information about all the available controllers.
- Return type:
- Raises:
TypeError – If controller_list_msgs is not of type controller_manager_msgs.srv.ListControllersResponse.
- panda_gazebo.common.helpers.translate_actionclient_result_error_code(actionclient_retval)[source]
Translates the error code returned by the SimpleActionClient.get_result() function into a human readable error message.
- Parameters:
actionclient_retval (
control_msgs.msg.FollowJointTrajectoryResult
) – The result that is returned by theactionlib.simple_action_client.SimpleActionClient.get_result()
function.- Returns:
Error string that corresponds to the error code.
- Return type:
- Raises:
TypeError – If actionclient_retval is not of type control_msgs.msg.FollowJointTrajectoryResult.
- panda_gazebo.common.helpers.translate_moveit_error_code(moveit_error_code)[source]
Translates a MoveIt error code object into a human readable error message.
- panda_gazebo.common.helpers.lower_first_char(string)[source]
De-capitalize the first letter of a string.
- Parameters:
string (str) – The input string.
- Returns:
The de-capitalized string.
- Return type:
- Raises:
TypeError – If text is not of type str.
Note
This function is not the exact opposite of the capitalize function of the standard library. For example, capitalize(‘abC’) returns Abc rather than AbC.
- panda_gazebo.common.helpers.wrap_space_around(text)[source]
Wrap one additional space around text if it is not already present.
- panda_gazebo.common.helpers.list_2_human_text(input_list, separator=',', end_separator='&')[source]
Function converts a list of values into human readable sentence.
Example
Using this function a list of 4 items
[item1, item2, item3, item4]
becomesitem2, item3 and item4
.
- panda_gazebo.common.helpers.dict_clean(input_dict)[source]
Removes empty dictionary keys from a dictionary and returns a cleaned up dictionary. Empty meaning an empty list, string or dict or a None value.
- panda_gazebo.common.helpers.get_unique_list(input_list, trim=True)[source]
Removes non-unique items from a list.
- panda_gazebo.common.helpers.get_duplicate_list(input_list)[source]
Returns the duplicates in a list.
- panda_gazebo.common.helpers.flatten_list(input_list)[source]
Function used to flatten a list containing sublists. It does this by calling itself recursively.
- panda_gazebo.common.helpers.action_server_exists(topic_name)[source]
Checks whether a topic contains an action server is running.
- panda_gazebo.common.helpers.quaternion_norm(quaternion)[source]
Calculates the norm of a quaternion.
- panda_gazebo.common.helpers.normalize_quaternion(quaternion)[source]
Normalizes a given quaternion.
- Parameters:
quaternion (
geometry_msgs.msg.Quaternion
) – A quaternion.- Returns:
The normalized quaternion.
- Return type:
geometry_msgs.msg.Quaternion
- Raises:
TypeError – If quaternion is not of type Quaternion.
- panda_gazebo.common.helpers.normalize_vector(vector, force=True)[source]
Normalizes a given vector.
- panda_gazebo.common.helpers.ros_exit_gracefully(shutdown_msg=None, exit_code=0)[source]
Shuts down the ROS node wait until it is shutdown and exits the script.
- panda_gazebo.common.helpers.load_panda_joint_limits()[source]
Loads the joint limits of the Panda robot from the parameter server.
- Returns:
- Dictionary containing the joint position limits (i.e. min and max) for
each joint. Returns an empty dictionary if the joint limits could not be loaded.
- Return type: