Ejemplo n.º 1
0
 void CheckUndefined(CellTarget cellTarget, List <CellTarget> cellTargets)
 {
     if (cellTarget.Index < cellTargets.Count - 1)
     {
         int i = cellTarget.Index;
         foreach (var target in cellTarget.ProgramTargets.Where(x => x.Kinematics.Configuration == RobotConfigurations.Undefined))
         {
             if (!cellTargets[i + 1].ProgramTargets[target.Group].IsJointMotion)
             {
                 _program.Errors.Add($"Undefined configuration (probably due to a singularity) in target {target.Index} of robot {target.Group} before a linear motion");
                 //IndexError = i;
             }
         }
     }
 }
Ejemplo n.º 2
0
    List <CellTarget> CreateCellTargets(IEnumerable <IToolpath> toolpaths)
    {
        var cellTargets = new List <CellTarget>();
        var enumerators = toolpaths.Select(e => e.Targets.GetEnumerator()).ToList();

        if (RobotSystem is RobotCell cell)
        {
            var pathsCount = enumerators.Count;
            var groupCount = cell.MechanicalGroups.Count;

            if (pathsCount != groupCount)
            {
                Errors.Add($"You supplied {pathsCount} toolpath(s), this robot cell requires {groupCount} toolpath(s).");
                goto End;
            }
        }

        while (enumerators.All(e => e.MoveNext()))
        {
            var programTargets = new List <ProgramTarget>(enumerators.Count);
            programTargets.AddRange(enumerators.Select((e, i) => new ProgramTarget(e.Current, i)));

            if (programTargets.Any(t => t.Target is null))
            {
                Errors.Add($"Target index {cellTargets.Count} is null or invalid.");
                goto End;
            }

            var cellTarget = new CellTarget(programTargets, cellTargets.Count);
            cellTargets.Add(cellTarget);
        }

        if (enumerators.Any(e => e.MoveNext()))
        {
            Errors.Add("All toolpaths must contain the same number of targets.");
            goto End;
        }

        if (cellTargets.Count == 0)
        {
            Errors.Add("The program must contain at least 1 target.");
        }

End:
        return(cellTargets);
    }
Ejemplo n.º 3
0
    void FixFirstTarget(CellTarget firstTarget)
    {
        var fix = firstTarget.ProgramTargets.Where(x => !x.IsJointTarget);

        if (fix.Any())
        {
            var kinematics = _robotSystem.Kinematics(firstTarget.ProgramTargets.Select(x => x.Target));

            foreach (var programTarget in fix)
            {
                var kinematic = kinematics[programTarget.Group];
                if (kinematic.Errors.Count > 0)
                {
                    _program.Errors.Add($"Errors in target {programTarget.Index} of robot {programTarget.Group}:");
                    _program.Errors.AddRange(kinematic.Errors);
                }

                programTarget.Target = new JointTarget(kinematic.Joints.RangeSubset(0, 6), programTarget.Target);
                _program.Warnings.Add($"First target in robot {programTarget.Group} changed to a joint motion using axis rotations");
            }
        }
    }
Ejemplo n.º 4
0
 internal IEnumerable <Target> Lerp(CellTarget prevTarget, RobotSystem robot, double t, double start, double end)
 {
     return(ProgramTargets.Select((x, i) => x.Lerp(prevTarget.ProgramTargets[i], robot, t, start, end)));
 }
Ejemplo n.º 5
0
    public static void Pose(this IMeshPoser poser, List <KinematicSolution> solutions, CellTarget cellTarget)
    {
        var tools = cellTarget.ProgramTargets.Map(t => t.Target.Tool);

        poser.Pose(solutions, tools);
    }