get_current_joints_position()
  • 1 Minute to read

get_current_joints_position()


Article summary

Retrieves the current joints position of a specific arm.

Reference

Arguments

ArgumentsTypeDefault valueDescription
armstrThe arm to retrieve the current pose for.
unitsANGLE_UNITANGLE_UNIT.DEGREESUnit for angles (DEGREES or RADIANS).
as_dictboolFalseChange the output format of the method, review return section for more information.

Return

TypeDescription
dictRetrieves the current joint positions If as_dict parameter is set in True the function returns a dict with each name as key and current position as value, otherwise returns a dict with two keys names and values, where the items are a list with the joints names and a list with the current joints position.

Exceptions

  • RayaArmsException
  • RayaArmsInvalidArmOrGroupName

See the complete list of arms exceptions

Usage example

as_dict parameter in False

import json
...
self.arms = self.enable_controller('arms')
...
current_joints_position = await self.arms.get_current_joints_position('right_arm') 
print(json.dumps(current_joints_position, indent=2))
...

Output

{
  "names": [
    "arm_right_shoulder_rail_joint",
    "arm_right_shoulder_FR_joint",
    "arm_right_shoulder_RL_joint",
    "arm_right_bicep_twist_joint",
    "arm_right_bicep_FR_joint",
    "arm_right_elbow_twist_joint",
    "arm_right_elbow_FR_joint",
    "arm_right_wrist_joint"
  ],
  "values": [
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0
  ]
}

as_dict parameter in True

import json
...
self.arms = self.enable_controller('arms')
...
current_joints_position = await self.arms.get_current_joints_position('right_arm', as_dict=True) 
self.log.info(json.dumps(current_joints_position, indent=2))
...

Output:

{
  "arm_right_shoulder_rail_joint": 0.0,
  "arm_right_shoulder_FR_joint": 0.0,
  "arm_right_shoulder_RL_joint": 0.0,
  "arm_right_bicep_twist_joint": 0.0,
  "arm_right_bicep_FR_joint": 0.0,
  "arm_right_elbow_twist_joint": 0.0,
  "arm_right_elbow_FR_joint": 0.0,
  "arm_right_wrist_joint": 0.0
}

Was this article helpful?