Skip to content

Commit

Permalink
Added postprocessor for Fanuc robots (LS Format) (#267)
Browse files Browse the repository at this point in the history
* Added postprocessor for Fanuc robots (LS Format)

* Added speed calculation for joint movements on Fanuc robots

* Reverting changes in obsolete files
  • Loading branch information
AngelLM authored Feb 5, 2024
1 parent 0fbfab6 commit ac190db
Show file tree
Hide file tree
Showing 13 changed files with 445 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Robots.Grasshopper/Commands/CustomCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public CustomCommand() : base("Custom command", "CustomCmd", "Custom command wri
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddTextParameter("Name", "N", "Name", GH_ParamAccess.item, "CustomCommand");
pManager.AddTextParameter("Manufacturer", "M", "Robot manufacturer, options: ABB, KUKA, UR, Staubli, FrankaEmika, Doosan, Other, All. If you select 'All', the command will always be included irrespective of the manufacturer.", GH_ParamAccess.item, "All");
pManager.AddTextParameter("Manufacturer", "M", "Robot manufacturer, options: ABB, KUKA, UR, Staubli, FrankaEmika, Doosan, Fanuc, Other, All. If you select 'All', the command will always be included irrespective of the manufacturer.", GH_ParamAccess.item, "All");
pManager.AddTextParameter("Code", "C", "Command code", GH_ParamAccess.item);
pManager.AddTextParameter("Declaration", "D", "Variable declaration and assignment", GH_ParamAccess.item);
pManager[2].Optional = true;
Expand Down
1 change: 1 addition & 0 deletions src/Robots/Commands/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ protected override void Populate()
_commands.Add(Manufacturers.Staubli, (_, _) => $"putln(\"{_message}\")");
_commands.Add(Manufacturers.FrankaEmika, (_, _) => $"print(\"{_message}\")");
_commands.Add(Manufacturers.Doosan, (_, _) => $"tp_log(\"{_message}\")");
_commands.Add(Manufacturers.Fanuc, (_, _) => $":MESSAGE[\"{_message}\"] ;");
}

public override string ToString() => $"Command (Message \"{_message}\")";
Expand Down
7 changes: 7 additions & 0 deletions src/Robots/Commands/PulseDO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected override void Populate()
_commands.Add(Manufacturers.KUKA, CodeKuka);
_commands.Add(Manufacturers.UR, CodeUR);
_commands.Add(Manufacturers.Doosan, CodeDoosan);
_commands.Add(Manufacturers.Fanuc, CodeFanuc);

_declarations.Add(Manufacturers.UR, DeclarationUR);
}
Expand Down Expand Up @@ -63,6 +64,12 @@ string CodeDoosan(RobotSystem robotSystem, Target target)
return $"set_digital_output({number}, ON, {_length:0.###}, OFF)";
}

string CodeFanuc(RobotSystem robotSystem, Target target)
{
var number = GetNumber(robotSystem);
return $":DO[{number}]=PULSE, {_length:0.###}sec ;";
}

string GetNumber(RobotSystem robotSystem)
{
var io = robotSystem.IO;
Expand Down
7 changes: 7 additions & 0 deletions src/Robots/Commands/SetAO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected override void Populate()
_commands.Add(Manufacturers.UR, CodeUR);
_commands.Add(Manufacturers.Staubli, CodeStaubli);
_commands.Add(Manufacturers.Doosan, CodeDoosan);
_commands.Add(Manufacturers.Fanuc, CodeFanuc);

_declarations.Add(Manufacturers.ABB, DeclarationAbb);
_declarations.Add(Manufacturers.KUKA, DeclarationKuka);
Expand Down Expand Up @@ -86,6 +87,12 @@ string CodeDoosan(RobotSystem robotSystem, Target target)
return $"set_analog_output(ch={number}, val={Name})";
}

string CodeFanuc(RobotSystem robotSystem, Target target)
{
var number = GetNumber(robotSystem);
return $":AO[{number}]={Value} ;";
}

string GetNumber(RobotSystem robotSystem)
{
var io = robotSystem.IO;
Expand Down
9 changes: 9 additions & 0 deletions src/Robots/Commands/SetDO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected override void Populate()
_commands.Add(Manufacturers.UR, CodeUR);
_commands.Add(Manufacturers.Staubli, CodeStaubli);
_commands.Add(Manufacturers.Doosan, CodeDoosan);
_commands.Add(Manufacturers.Fanuc, CodeFanuc);
}

string CodeAbb(RobotSystem robotSystem, Target target)
Expand Down Expand Up @@ -66,6 +67,14 @@ string CodeDoosan(RobotSystem robotSystem, Target target)
return $"set_digital_output({number}, {textValue})";
}

string CodeFanuc(RobotSystem robotSystem, Target target)
{
var number = GetNumber(robotSystem);

string textValue = Value ? "ON" : "OFF";
return $":DO[{number}]={textValue} ;";
}

string GetNumber(RobotSystem robotSystem)
{
var io = robotSystem.IO;
Expand Down
1 change: 1 addition & 0 deletions src/Robots/Commands/Stop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ protected override void Populate()
_commands.Add(Manufacturers.UR, (_, _) => "pause program");
_commands.Add(Manufacturers.Doosan, (_, _) => "wait_nudge()");
//_commands.Add(Manufacturers.Staubli, (_, __) => "wait(true)");
_commands.Add(Manufacturers.Fanuc, (_, _) => ":ABORT ;");
}

public override string ToString() => "Command (Stop)";
Expand Down
6 changes: 6 additions & 0 deletions src/Robots/Commands/Wait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ protected override void Populate()
_commands.Add(Manufacturers.Staubli, CodeStaubli);
_commands.Add(Manufacturers.FrankaEmika, CodePython);
_commands.Add(Manufacturers.Doosan, CodeDoosan);
_commands.Add(Manufacturers.Fanuc, CodeFanuc);

_declarations.Add(Manufacturers.ABB, DeclarationAbb);
_declarations.Add(Manufacturers.KUKA, DeclarationKuka);
Expand Down Expand Up @@ -72,5 +73,10 @@ string CodeDoosan(RobotSystem robotSystem, Target target)
return $"wait({Name})";
}

string CodeFanuc(RobotSystem robotSystem, Target target)
{
return $":WAIT {Seconds:0.00}(sec) ;";
}

public override string ToString() => $"Command (Wait {Seconds} secs)";
}
9 changes: 9 additions & 0 deletions src/Robots/Commands/WaitDI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected override void Populate()
_commands.Add(Manufacturers.UR, CodeUR);
_commands.Add(Manufacturers.Staubli, CodeStaubli);
_commands.Add(Manufacturers.Doosan, CodeDoosan);
_commands.Add(Manufacturers.Fanuc, CodeFanuc);
}

string CodeAbb(RobotSystem robotSystem, Target target)
Expand Down Expand Up @@ -56,6 +57,14 @@ string CodeDoosan(RobotSystem robotSystem, Target target)
return $"wait_digital_input({number}, {value})";
}

string CodeFanuc(RobotSystem robotSystem, Target target)
{
var number = GetNumber(robotSystem);
if (value) { return $":WAIT (DI[{number}]) ;"; }
else{ return $":WAIT (!DI[{number}]) ;"; }

}

string GetNumber(RobotSystem robotSystem)
{
var io = robotSystem.IO;
Expand Down
2 changes: 2 additions & 0 deletions src/Robots/IO/FileIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ static RobotSystem CreateRobotSystem(XElement element, Plane basePlane, bool loa
Manufacturers.Staubli => new SystemStaubli(name, mechanicalGroups, io, basePlane, environment),
Manufacturers.FrankaEmika => new SystemFranka(name, (RobotFranka)mechanicalGroups[0].Robot, io, basePlane, environment),
Manufacturers.Doosan => new SystemDoosan(name, (RobotDoosan)mechanicalGroups[0].Robot, io, basePlane, environment),
Manufacturers.Fanuc => new SystemFanuc(name, mechanicalGroups, io, basePlane, environment),

_ => throw new ArgumentException($" Manufacturer '{manufacturer} is not supported.")
};
Expand Down Expand Up @@ -241,6 +242,7 @@ static Mechanism CreateMechanism(XElement element, bool loadMeshes)
Manufacturers.Staubli => new RobotStaubli(model, payload, basePlane, baseMesh, joints),
Manufacturers.FrankaEmika => new RobotFranka(model, payload, basePlane, baseMesh, joints),
Manufacturers.Doosan => new RobotDoosan(model, payload, basePlane, baseMesh, joints),
Manufacturers.Fanuc => new RobotFanuc(model, payload, basePlane, baseMesh, joints),
_ => throw new ArgumentException($" Manufacturer '{manufacturer}' not supported."),
},
"Positioner" => new Positioner(model, manufacturer, payload, basePlane, baseMesh, joints, movesRobot),
Expand Down
Loading

0 comments on commit ac190db

Please sign in to comment.