The Kinematic interface is not available on controller generations before YRC1000.
The kinematics interface converts positions to different coordinate systems.
Provides the conversions using the KinematicConversions enumeration.
enum class KinematicConversions
{
JointAngleToCartesianPos, // Convert Joint Angles(in degrees) To Cartesian Position.
PulseToJointAngle, // Convert Pulse position To Joint Angles(in degrees).
JointAngleToPulse, // Convert Joint Angles(in degrees) To Pulse.
PulseToCartesianPos, // Convert Pulse position To Cartesian Position.
CartesianPosToJointAngle,
CartesianPosToPulse
};
Name | Description |
---|---|
ConvertPosition | Converts the position data to the specified type. |
ConvertPositionFromCartesian | Converts the position data from the specified cartesian type. |
Converts the position data to the specified type. Possible conversions are
JointAngleToCartesianPos, PulseToJointAngle, JointAngleToPulse, PulseToCartesianPos.
StatusInfo ConvertPosition(ControlGroupId grp, PositionData& positionToConvert,
KinematicConversions conversionType, PositionData& convertedPosition)
grp
[in] The control group to convert the position for. See ControlGroupId.
positionToConvert
[in] The position data to convert. Position can be pulse or joint angle. See PositionData.
conversionType
[in] The type of conversion to perform. Available conversions for this function are JointAngleToCartesianPos, PulseToJointAngle, JointAngleToPulse, PulseToCartesianPos. See KinematicConversions.
convertedPosition
[out] The converted position data. See PositionData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
RobotPositionVariableData robotPositionData{};
PositionData positionToConvert{};
PositionData convertedPosition{};
PositionData jointAnglePosition{};
// get a position variable to convert.
status = c->Variables->RobotPositionVariable->Read(0, robotPositionData);
std::cout << "Starting position.\n******************" << std::endl;
std::cout << status << std::endl;
std::cout << robotPositionData.positionData << std::endl;
positionToConvert = robotPositionData.positionData;
//Convert pulse to joint angle
status = c->Kinematics->ConvertPosition(ControlGroupId::R1, positionToConvert
, KinematicConversions::PulseToJointAngle, jointAnglePosition);
std::cout << "\nPulse to joint angle.\n******************" << std::endl;
std::cout << status << std::endl;
std::cout << jointAnglePosition << std::endl;
status = c->Kinematics->ConvertPosition(ControlGroupId::R1, jointAnglePosition
, KinematicConversions::JointAngleToPulse, convertedPosition);
std::cout << "\nback to pulse.\n******************" << std::endl;
std::cout << status << std::endl;
std::cout << convertedPosition << std::endl;
//Convert pulse to cartesian
status = c->Kinematics->ConvertPosition(ControlGroupId::R1, positionToConvert
, KinematicConversions::PulseToCartesianPos, convertedPosition);
std::cout << "\nPulse to cartesian.\n******************" << std::endl;
std::cout << status << std::endl;
std::cout << convertedPosition << std::endl;
//Convert Joint angle to cartesian
status = c->Kinematics->ConvertPosition(ControlGroupId::R1, jointAnglePosition
, KinematicConversions::JointAngleToCartesianPos, convertedPosition);
std::cout << "\nJoint angle to cartesian.\n******************" << std::endl;
std::cout << status << std::endl;
std::cout << convertedPosition << std::endl;
YMConnect::CloseConnection(c);
Output
Starting position.
******************
Code (0): OK
Coordinate Type: Pulse
Tool Number: 0
Axes:
Axis S : 101707 pulses.
Axis L : -48901 pulses.
Axis U : -50003 pulses.
Axis R : 1954 pulses.
Axis B : -90211 pulses.
Axis T : 2769 pulses.
Axis E : 0 pulses.
Axis W : 0 pulses.
Pulse to joint angle.
******************
Code (0): OK
Coordinate Type: RobotCoordinate
Figure:
Front, Upper, Flip, S<180, L<180, U<180, R<180, B<180, T<180, E<180, W<180
Tool Number: 0
User Coordinate Number: 0
Axes:
Axis X : 70.8586 millimeters.
Axis Y : -37.6069 millimeters.
Axis Z : -35.1583 millimeters.
Axis Rx : 2.0145 degrees.
Axis Ry : -92.0295 degrees.
Axis Rz : 6.089 degrees.
Axis Re : 0 degrees.
Axis Rw : 0 degrees.
back to pulse.
******************
Code (0): OK
Coordinate Type: Pulse
Tool Number: 0
Axes:
Axis S : 101707 pulses.
Axis L : -48901 pulses.
Axis U : -50003 pulses.
Axis R : 1954 pulses.
Axis B : -90211 pulses.
Axis T : 2769 pulses.
Axis E : 0 pulses.
Axis W : 0 pulses.
Pulse to cartesian.
******************
Code (0): OK
Coordinate Type: RobotCoordinate
Figure:
Front, Upper, NoFlip, S<180, L<180, U<180, R<180, B<180, T<180, E<180, W<180
Tool Number: 0
User Coordinate Number: 0
Axes:
Axis X : 138.385 millimeters.
Axis Y : 387.986 millimeters.
Axis Z : 613.645 millimeters.
Axis Rx : 177.954 degrees.
Axis Ry : -0.2045 degrees.
Axis Rz : 76.8725 degrees.
Axis Re : 0 degrees.
Axis Rw : 0 degrees.
Joint angle to cartesian.
******************
Code (0): OK
Coordinate Type: RobotCoordinate
Figure:
Front, Upper, NoFlip, S<180, L<180, U<180, R<180, B<180, T<180, E<180, W<180
Tool Number: 0
User Coordinate Number: 0
Axes:
Axis X : 138.385 millimeters.
Axis Y : 387.986 millimeters.
Axis Z : 613.646 millimeters.
Axis Rx : 177.954 degrees.
Axis Ry : -0.2046 degrees.
Axis Rz : 76.8725 degrees.
Axis Re : 0 degrees.
Axis Rw : 0 degrees.
Converts the position data from the specified cartesian type.
Possible conversions are CartesianPosToJointAngle and CartesianPosToPulse.
StatusInfo ConvertPositionFromCartesian(ControlGroupId grp, PositionData& positionToConvert,
KinematicConversions conversionType, KinematicType type,
const CoordinateArray& prevAngle, PositionData& convertedPosition)
grp
[in] Group with position to convert. See ControlGroupId.
positionToConvert
[in] The position data to convert. Must be cartesian. See PositionData.
conversionType
[in] The type of conversion to perform. Available conversions for this function are CartesianPosToJointAngle and CartesianPosToPulse. See KinematicConversions.
type
[in] optional parameter that specifies how to solve inverse kinamatics.
Default: Calculate using parameter S2C430 value. 2:Delta, 1:Figure
Delta: Calculate by prevAngle. If this type is selected, prevAngle must be provided.
Figure: Calculate by the figure set in the position to convert.
See KinematicType.
prevAngle
[in] requred angle when conversions are done with with KinematicType Delta. Otherwise ignored.
convertedPosition
[out] The converted position data. See PositionData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
RobotPositionVariableData robotPositionData{};
PositionData positionToConvert{};
PositionData cartesianPosition{};
PositionData toPulseFromCartesian{};
PositionData toJointAngleFromCartesian{};
// get a position variable to convert.
status = c->Variables->RobotPositionVariable->Read(0, robotPositionData);
std::cout << "Starting position.\n******************" << std::endl;
std::cout << status << std::endl;
std::cout << robotPositionData.positionData << std::endl;
positionToConvert = robotPositionData.positionData;
//Convert pulse to cartesian
status = c->Kinematics->ConvertPosition(ControlGroupId::R1, positionToConvert
, KinematicConversions::PulseToCartesianPos, cartesianPosition);
std::cout << "\nPulse to cartesian.\n******************" << std::endl;
std::cout << status << std::endl;
std::cout << cartesianPosition << std::endl;
//Convert cartesian to pulse
status = c->Kinematics->ConvertPositionFromCartesian(ControlGroupId::R1, cartesianPosition
, KinematicConversions::CartesianPosToPulse, KinematicType::Figure, CoordinateArray{}, toPulseFromCartesian);
std::cout << "\nCartesian to pulse.\n******************" << std::endl;
std::cout << status << std::endl;
std::cout << toPulseFromCartesian << std::endl;
//Convert cartesian to joint angle
status = c->Kinematics->ConvertPositionFromCartesian(ControlGroupId::R1, cartesianPosition
, KinematicConversions::CartesianPosToJointAngle, KinematicType::Figure, CoordinateArray{}, toJointAngleFromCartesian);
std::cout << "\nCartesian to joint angle.\n******************" << std::endl;
std::cout << status << std::endl;
std::cout << toJointAngleFromCartesian << std::endl;
YMConnect::CloseConnection(c);
Output
Starting position.
******************
Code (0): OK
Coordinate Type: Pulse
Tool Number: 0
Axes:
Axis S : 101707 pulses.
Axis L : -48901 pulses.
Axis U : -50003 pulses.
Axis R : 1954 pulses.
Axis B : -90211 pulses.
Axis T : 2769 pulses.
Axis E : 0 pulses.
Axis W : 0 pulses.
Pulse to cartesian.
******************
Code (0): OK
Coordinate Type: RobotCoordinate
Figure:
Front, Upper, NoFlip, S<180, L<180, U<180, R<180, B<180, T<180, E<180, W<180
Tool Number: 0
User Coordinate Number: 0
Axes:
Axis X : 138.385 millimeters.
Axis Y : 387.986 millimeters.
Axis Z : 613.645 millimeters.
Axis Rx : 177.954 degrees.
Axis Ry : -0.2045 degrees.
Axis Rz : 76.8725 degrees.
Axis Re : 0 degrees.
Axis Rw : 0 degrees.
Cartesian to pulse.
******************
Code (0): OK
Coordinate Type: Pulse
Tool Number: 0
Axes:
Axis S : 101707 pulses.
Axis L : -48901 pulses.
Axis U : -50003 pulses.
Axis R : 1954 pulses.
Axis B : -90211 pulses.
Axis T : 2769 pulses.
Axis E : 0 pulses.
Axis W : 0 pulses.
Cartesian to joint angle.
******************
Code (0): OK
Coordinate Type: RobotCoordinate
Figure:
Front, Upper, NoFlip, S<180, L<180, U<180, R<180, B<180, T<180, E<180, W<180
Tool Number: 0
User Coordinate Number: 0
Axes:
Axis X : 70.8585 millimeters.
Axis Y : -37.6069 millimeters.
Axis Z : -35.1583 millimeters.
Axis Rx : 2.0144 degrees.
Axis Ry : -92.0296 degrees.
Axis Rz : 6.0889 degrees.
Axis Re : 0 degrees.
Axis Rw : 0 degrees.