When using the motion manager, set parameter S2C430 to 1 and S2C425 to 0.
The MotionManagerInterface is not available on controller generations before YRC1000.
The MotionManagerInterface is the way that YMConnect streams motions to the controller.
It does this by using structures derived from “Motion”. The three structures are LinearMotion, JointMotion and CircularMotion.
These motions consist of the Control Group Id, the speed, the destination coordinates, the “motion attributes” and the motions interpolation type.
PositionData destination;
//Destination position.
destination.axisData = { 333.987, 7.063, 564.243, 176.8934, -9.9171, 8.1798 };
//Set coordinate system to RobotCoordinate.
destination.coordinateType = CoordinateType::RobotCoordinate;
//A motion with the default motion attributes using the position data in destination.
//Speed of 25.0 mm/s. ControlGroupId R1.
LinearMotion r1Motion( ControlGroupId::R1, destination, 25 );
The intention of the motion structure is to be as easy to use as possible.
The MotionAttributes structure is designed such that it only needs to be configured if needed for the coordinate type or if the acceleration or deceleration needs to be set.
PositionData destination;
//Destination position.
destination.axisData = { 333.987, 7.063, 564.243, 176.8934, -9.9171, 8.1798 };
//Set coordinate system to UserCoordinate.
destination.coordinateType = CoordinateType::UserCoordinate;
destination.userCoordinateNumber = 1;
//A motion with the default motion attributes using user coordinate frame 1.
//Speed of 25.0 mm/s. ControlGroupId R1.
LinearMotion r1Motion( ControlGroupId::R1, destination, 25 );
The MotionManagerInterface has a trajectory that is made from Motion structures that you add.
Each Motion structure is a move to a point, similar to the way that move instructions work in a job.
Adding a point to the trajectory is done by using the AddPointToTrajectory function. This function can add up to four “Motion group targets” at a time for concurrent motion.
PositionData destination;
//Destination position.
destination.axisData = { 333.987, 7.063, 564.243, 176.8934, -9.9171, 8.1798 };
//Set coordinate system to RobotCoordinate.
destination.coordinateType = CoordinateType::RobotCoordinate;
//A motion with the default motion attributes using the position data in destination.
//Speed of 25.0 mm/s. ControlGroupId R1.
LinearMotion r1Motion( ControlGroupId::R1, destination, 25 );
//Add the motion to the trajectory.
status = c->MotionManager->AddPointToTrajectory(r1Motion);
Add as many points to the trajectory as needed and then call the MotionStart function to start motion.
The actual motion of the robot occurs when MotionStart function is called. It will continue executing motions in the trajectory until the MotionStop function is called or the entire trajectory has been completed.
If the trajectory is complete, but MotionStop has not been called, then motion will immediately occur when a point is added to the trajectory.
If MotionStart is called and the trajectory contains points, the motions will be executed until the trajectory is empty. It will then wait for motions to be added to the trajectory. Since MotionStart is already called, the motion will execute immediately.
PositionData destination;
//Destination position.
destination.axisData = { 333.987, 7.063, 564.243, 176.8934, -9.9171, 8.1798 };
//Set coordinate system to RobotCoordinate.
destination.coordinateType = CoordinateType::RobotCoordinate;
//A motion with the default motion attributes using the position data in destination.
//Speed of 25.0 mm/s. ControlGroupId R1.
LinearMotion r1Motion( ControlGroupId::R1, destination, 25 );
//Add the motion to the trajectory.
status = c->MotionManager->AddPointToTrajectory(r1Motion);
//Robot does not move yet.
status = c->MotionManager->MotionStart();
//Robot moves to the destination.
//Get a position variable.
RobotPositionVariableData positionVar{};
status = c->Variables->RobotPositionVariable->Read(1, positionVar);
//create a motion with the coordinate array from the position variable.
LinearMotion motion2(ControlGroupId::R1, positionVar.positionData, 25);
//Add the motion to the trajectory.
status = c->MotionManager->AddPointToTrajectory(motion2);
//Robot starts to move to the destination immediately since MotionStart has been called.
//immediately stop the robot.
status = c->MotionManager->MotionStop();
//Continue moving where the robot left off.
status = c->MotionManager->MotionStart();
void R1B1Motion()
{
StatusInfo status;
RobotPositionVariableData r1PositionData{};
BaseAxisPositionVariableData b1PositionData{};
auto c = YMConnect::OpenConnection("192.168.1.31", status, 500, 3, false);
if (c == nullptr)
{
std::cout << "Connection failed. Check IP address and try again." << std::endl;
return;
}
status = c->Variables->BasePositionVariable->Read(0, b1PositionData);
status = c->Variables->RobotPositionVariable->Read(0, r1PositionData);
LinearMotion r1Motion(ControlGroupId::R1, r1PositionData.positionData, 25.0);
JointMotion b1Motion(ControlGroupId::B1, b1PositionData.positionData, 25.0);
status = c->MotionManager->AddPointToTrajectory(r1Motion, b1Motion);
status = c->ControlCommands->SetServos(SignalStatus::ON);
status = c->MotionManager->MotionStart();
YMConnect::CloseConnection(c);
return;
The CircularMotion uses a "passing point" to create an arc.
StatusInfo status;
auto c = YMConnect::OpenConnection("192.168.1.32", status);
PositionData destination;
//Destination position.
destination.axisData = { 333.987, 7.063, 564.243, 176.8934, -9.9171, 8.1798 };
//Set coordinate system to RobotCoordinate.
destination.coordinateType = CoordinateType::RobotCoordinate;
//A motion with the default motion attributes using the position data in destination.
//Speed of 25.0 mm/s. ControlGroupId R1.
LinearMotion r1LinearMotion( ControlGroupId::R1, destination, 25 );
//Get a position variable which serves as the final destination point..
RobotPositionVariableData positionVar{};
status = c->Variables->RobotPositionVariable->Read(1, positionVar);
//Set a coordinate array for the passing point. These are arbitrary points for the sake of this example. Yours will be different.
CoordinateArray passingPoint{ 333.987, 7.063, 564.243, 176.8934, -9.9171, 8.1798 };
CircularMotion r1CircularMotion( ControlGroupId::R1, positionVar.positionData, passingPoint, 25);
status = c->MotionManager->AddPointToTrajectory(r1LinearMotion);
status = c->MotionManager->AddPointToTrajectory(r1CircularMotion);
status = c->MotionManager->MotionStart();
YMConnect::CloseConnection(c);
In this example, a LinearMotion object is constructed. A position variable is retrieved which will be the CircularMotion target destination. A coordinate array is set for the "passing point" which is used to calculate the arc of the circle. The passing point is illustrated in the graphic as AuxCoords. The points are than added to the trajectory. As seen in the graphic, first the robot will move to the LinearMotion Target. Next, the robot wil move to the CircularMotion Target over the arc generated by the passing point.
When selecting coordinates for your AuxCoords, ensure that they are in the same coordinate system as the Target position. For example, if the Target position is in pulse counts, the AuxCoords need to be pulse counts.
Name | Description |
---|---|
AddPointToTrajectory | Add a point to the trajectory. |
MotionStart | Start the motion. |
MotionStop | Stop the motion. |
ClearTrajectory | Clear the trajectory. |
Add a point to the trajectory.
StatusInfo AddPointToTrajectory(const Motion& firstGroupTarget, std::optional<Motion> secondGroupTarget = std::nullopt,
std::optional<Motion> thirdGroupTarget = std::nullopt, std::optional<Motion> fourthGroupTarget = std::nullopt);
firstGroupTarget
[in] The first motion group target. See Motion.
secondGroupTarget
[in] The optional second motion group target. See Motion.
thirdGroupTarget
[in] The optional third motion group target. See Motion.
fourthGroupTarget
[in] The optional fourth motion group target. See Motion.
0 if successful, otherwise a StatusInfo object with a description of error.
Start the motion at the first point in the trajectory or if it was paused mid-motion, continue motion
StatusInfo MotionStart();
0 if successful, otherwise a StatusInfo object with a description of error.
Stop the motion. Please Note that this does not clear the trajectory.
StatusInfo MotionStop(bool clearTrajectory = false);
clearTrajectory
[in] Clear out the trajectory. True: clear trajectory, False: don't clear. Defaults to false.
0 if successful, otherwise a StatusInfo object with a description of error.
Clear out the trajectory for all groups.
StatusInfo ClearAllTrajectory();
0 if successful, otherwise a StatusInfo object with a description of error.
When you call the AddPointToTrajectory
function, the point will be checked for a few different invalid values before stored in an internal buffer before being sent to the controller. If any of these checks fail, the point will be discarded and an error will be returned. As the points are processed asynchronously from the buffer into the controller, additional errors may be encountered. These will appear in the form of alarm 8015 on the pendant. When an alarm happens, the trajectory is cleared and motion stops. These are the possible alarm subcodes that can occur when this happens.:
Error Code | Readout on pendant | Remedy |
---|---|---|
255 | Motion fail. Check remote mode. | Ensure that the pendant is in remote control mode. |
254 | Servo Off. | Call ControlCommands->SetServo(SignalStatus::ON) |
253 | Hold Is On. | Take a look at what could be causing the hold or call ControlCommands->SetHold(SignalStatus::OFF) |
252 | Alarm Is Active. | Correct the currently activated alarm and try again. |
251 | Home Position Not Set. | Set The robot home position. |
250 | Home Position Not Checked. | The controller detected a significant difference in encoder data between power off and power on. More information and recovery can be seen here. https://www.youtube.com/watch?v=Ay3qbtOad50 |
249 | Not In Play Mode. | Similar to error 255, Ensure that the pendant is in remote control mode. |
248 | Job Currently Running. | There is a job currently running. End that job before commanding motion remotely. |
247 | Duplicate Playback Group. | You shouldnt see this error but if you do, let us know at https://github.com/Yaskawa-Global/YMConnect/discussions |
239 | Playback Interrupted. | Something stopped the execution of the current trajectory. |
224 | Group Does Not Exist. | You shouldn't see this error but if you do, its because a point that was submitted uses a group that doesn't exist on the controller. |
223 | Base Grp Motion is missing. | When a robot is atatched to a base, a point needs to be provided for that base along with the robot. You can do this by supplying a motion for both groups in the AddPointToTrajectory function. |
222 | Interpolation Out Of Range - Unreachable point | ensure that the position data in a Motion for an external axis is of coordinate type pulse. |
221 | User Coordinate System Out Of Range | User frame number is out of range. Valid numbers are 1-63. |
220 | Task Number Out Of Range | You shouldnt see this error but if you do, let us know at https://github.com/Yaskawa-Global/YMConnect/discussions |
219 | Task And Base Number Unmatched | You shouldnt see this error but if you do, let us know at https://github.com/Yaskawa-Global/YMConnect/discussions |
211 | Tool Number Out Of Range | Check the tool number in the position data that you submitted and make sure that it is a valid tool number. |
210 | Tool Set Inhibited | You shouldnt see this error but if you do, let us know at https://github.com/Yaskawa-Global/YMConnect/discussions |
209 | Acceleration Value Out Of Range | Valid range is 20.00%-100.00% |
208 | Deceleration Value Out Of Range | Valid range is 20.00%-100.00% |