Skip to content

Commit

Permalink
use list input for better performance
Browse files Browse the repository at this point in the history
Blank mxA component
Up -> 1.6.5
  • Loading branch information
lin-ycv committed Apr 28, 2023
1 parent b36befa commit 8125475
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 54 deletions.
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#endif
[assembly: AssemblyCompany("Yu Chieh (Victor) Lin")]
[assembly: AssemblyProduct("RobotsExtended")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -36,7 +36,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.1")]
[assembly: AssemblyVersion("1.6.5")]
#pragma warning disable CS7035 // The specified version string does not conform to the recommended format - major.minor.build.revision
[assembly: AssemblyFileVersion("1.6.1")]
[assembly: AssemblyFileVersion("1.6.5")]
#pragma warning restore CS7035 // The specified version string does not conform to the recommended format - major.minor.build.revision
20 changes: 14 additions & 6 deletions RobotsExtended.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
</Compile>
<Compile Include="RobotsExtendedInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="src\Kuka\MxAutomation.cs" />
<Compile Include="src\Util\RenderColour.cs" />
<Compile Include="src\Util\RotateEuler.cs" />
<Compile Include="src\Util\UpdateFrame.cs" />
Expand Down Expand Up @@ -90,25 +91,32 @@
<ItemGroup>
<Reference Include="Eto, Version=2.6.0.0, Culture=neutral, PublicKeyToken=552281e97c755530, processorArchitecture=MSIL">
<HintPath>packages\RhinoCommon.7.14.22010.17001\lib\net48\Eto.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="GH_IO, Version=7.14.22010.17000, Culture=neutral, PublicKeyToken=6a29997d2e6b4f97, processorArchitecture=MSIL">
<HintPath>packages\Grasshopper.7.14.22010.17001\lib\net48\GH_IO.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Grasshopper, Version=7.14.22010.17000, Culture=neutral, PublicKeyToken=dda4f5ec2cd80803, processorArchitecture=MSIL">
<HintPath>packages\Grasshopper.7.14.22010.17001\lib\net48\Grasshopper.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Rhino.UI, Version=7.14.22010.17000, Culture=neutral, PublicKeyToken=552281e97c755530, processorArchitecture=MSIL">
<HintPath>packages\RhinoCommon.7.14.22010.17001\lib\net48\Rhino.UI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RhinoCommon, Version=7.14.22010.17000, Culture=neutral, PublicKeyToken=552281e97c755530, processorArchitecture=MSIL">
<HintPath>packages\RhinoCommon.7.14.22010.17001\lib\net48\RhinoCommon.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Robots, Version=1.6.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Robots.Rhino.1.6.1\lib\net48\Robots.dll</HintPath>
<Reference Include="Robots, Version=1.6.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Robots.Rhino.1.6.5\lib\net48\Robots.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Robots.Grasshopper, Version=1.6.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Robots.Rhino.1.6.1\lib\net48\Robots.Grasshopper.dll</HintPath>
<Reference Include="Robots.Grasshopper, Version=1.6.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Robots.Rhino.1.6.5\lib\net48\Robots.Grasshopper.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
Expand All @@ -131,8 +139,8 @@ Erase "$(TargetPath)"
if $(ConfigurationName) == Release (
del /Q "$(TargetDir)*.config"
del /Q "$(TargetDir)*.pdb"
)
rmdir /S /Q "$(TargetDir)\..\obj"</PostBuildEvent>
rmdir /S /Q "$(TargetDir)\..\obj"
)</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<FallbackCulture>en-US</FallbackCulture>
Expand Down
2 changes: 1 addition & 1 deletion packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<packages>
<package id="Grasshopper" version="7.14.22010.17001" targetFramework="net48" />
<package id="RhinoCommon" version="7.14.22010.17001" targetFramework="net48" />
<package id="Robots.Rhino" version="1.6.1" targetFramework="net48" />
<package id="Robots.Rhino" version="1.6.5" targetFramework="net48" />
</packages>
2 changes: 1 addition & 1 deletion src/Kuka/CVEL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CVEL : GH_Component
{
public CVEL()
: base("Speed Approximation", "CVEL",
"Commands the robot to maintain defined speed percentage by zoning (Custom Command)",
"Commands the robot to maintain defined speed percentage by zoning (Custom Command)\r\nShould be the first command if in a command group",
"Robots", "Commands")
{ }
public override GH_Exposure Exposure => GH_Exposure.secondary;
Expand Down
3 changes: 2 additions & 1 deletion src/Kuka/MergeKRL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,14 @@ protected override void SolveInstance(IGH_DataAccess DA)
bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) => false;
IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) => null;
bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) => false;
void IGH_VariableParameterComponent.VariableParameterMaintenance() { }
void IGH_VariableParameterComponent.VariableParameterMaintenance() {}
bool save = false;
bool fold = false;
readonly Param_String param = new Param_String { Name = "Directory", NickName = "P", Description = "Specify Path where file will be saved\nIf not specified, will try to save to Desktop", Optional = true };
readonly Param_Boolean param2 = new Param_Boolean { Name = "Save", NickName = "S", Description = "Button or toggle to specify saving", Optional = false };
private void SaveInputs(object sender, EventArgs e)
{
RecordUndoEvent("Enable/disable Save param");
save = !save;
if (save)
{
Expand Down
33 changes: 33 additions & 0 deletions src/Kuka/MxAutomation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Grasshopper.Kernel;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RobotsExtended.Kuka
{
public class MxAutomation : GH_Component
{
public MxAutomation() : base("mxAutomation","KUKA.mxA","KUKA mxAutomation. [Requires mxA package]", "Robots", "Components") { }
public override GH_Exposure Exposure => GH_Exposure.senary; //| GH_Exposure.obscure;
protected override Bitmap Icon => Properties.Resources.KukaVarProxyConnect;
public override Guid ComponentGuid => new Guid("{30263A03-866C-4BBF-A90A-5C3F0DC62926}");

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddTextParameter("", "IP", "IP Address of the controller to communicate with", GH_ParamAccess.item);

}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
}

protected override void SolveInstance(IGH_DataAccess DA)
{
// TO BE IMPLEMENTED
}
}
}
3 changes: 2 additions & 1 deletion src/Util/DefineJoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
}
private void ChangeInput(object sender, EventArgs e)
{
RecordUndoEvent("Toggle params");
external = !external;
if (external)
{
Expand Down Expand Up @@ -142,7 +143,7 @@ void IGH_VariableParameterComponent.VariableParameterMaintenance() { }
};
readonly int[,] limits = new int[2, 6]
{
{-185,-35,-120,-68,-119,-350},
{-185,-35,-68,-185,-119,-350},
{ 185, 135, 210, 185, 119, 350},
};
}
Expand Down
80 changes: 39 additions & 41 deletions src/Util/RotateEuler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Rhino.Render.Dithering;

namespace RobotsExtended.Util
{
Expand All @@ -17,62 +18,59 @@ public RotateEuler() : base("Rotate Euler", "RotEuler", "Rotate an object with (

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGeometryParameter("Geometry", "Geo", "Geometry or plane to rotate", GH_ParamAccess.item);
pManager.AddPlaneParameter("Rotation Plane", "Pln", "Plane to use for center or rotation", GH_ParamAccess.item);
pManager.AddNumberParameter("Z-Axis", "A", "Degree of rotation on Z-Axis", GH_ParamAccess.item);
pManager.AddNumberParameter("Y-Axis", "B", "Degree of rotation on Y-Axis", GH_ParamAccess.item);
pManager.AddNumberParameter("X-Axis", "C", "Degree of rotation on X-Axis", GH_ParamAccess.item);
// Switched to list input for better performance
pManager.AddGeometryParameter("Geometry", "Geo", "Geometry or plane to rotate", GH_ParamAccess.list);
pManager.AddPlaneParameter("Rotation Plane", "Pln", "Plane to use for center or rotation", GH_ParamAccess.list);
pManager.AddNumberParameter("Z-Axis", "A", "Degree of rotation on Z-Axis", GH_ParamAccess.list);
pManager.AddNumberParameter("Y-Axis", "B", "Degree of rotation on Y-Axis", GH_ParamAccess.list);
pManager.AddNumberParameter("X-Axis", "C", "Degree of rotation on X-Axis", GH_ParamAccess.list);
pManager[0].Optional = true;
pManager[1].Optional = true;
pManager[2].Optional = true;
pManager[3].Optional = true;
pManager[4].Optional = true;
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddGeometryParameter("Geometry", "G", "Rotated geometry", GH_ParamAccess.item);
pManager.AddTransformParameter("Transform", "X", "Transformation data", GH_ParamAccess.item);
pManager.AddGeometryParameter("Geometry", "G", "Rotated geometry", GH_ParamAccess.list);
pManager.AddTransformParameter("Transform", "X", "Transformation data", GH_ParamAccess.list);
}

protected override void SolveInstance(IGH_DataAccess DA)
{
IGH_GeometricGoo geo = null;
Plane pln = Plane.Unset;
double a = 0, b = 0, c = 0;
DA.GetData(0, ref geo);
DA.GetData(1, ref pln);
DA.GetData(2, ref a);
DA.GetData(3, ref b);
DA.GetData(4, ref c);
if (geo != null)
geo = geo.DuplicateGeometry();
if (pln == Plane.Unset && geo is GH_Plane p)
{
GH_Convert.ToPlane(p, ref pln, GH_Conversion.Both);
}
else if (geo == null && pln != Plane.Unset)
{
geo = GH_Convert.ToGeometricGoo(pln);
}
else if (pln == Plane.Unset || geo == null)
{
string e;
if (pln == Plane.Unset)
e = Grasshopper.CentralSettings.CanvasFullNames ? Params.Input[1].Name : Params.Input[1].NickName;
else
e = Grasshopper.CentralSettings.CanvasFullNames ? Params.Input[0].Name : Params.Input[0].NickName;
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Input parameter {e} failed to collect data");
return;
}
List<IGH_GeometricGoo> geo = new List<IGH_GeometricGoo>();
List<Plane> pln = new List<Plane>();
List<double>[] ro = new List<double>[3] { new List<double>(), new List<double>(), new List<double>() };

DA.GetDataList(0, geo);
DA.GetDataList(1, pln);
DA.GetDataList(2, ro[0]);
DA.GetDataList(3, ro[1]);
DA.GetDataList(4, ro[2]);

for (int i = 0; i < geo.Count; i++)
geo[i] = geo[i].DuplicateGeometry();
if (geo.Count == 0 && pln.Count > 0)
geo.AddRange(pln.Select(p=> GH_Convert.ToGeometricGoo(p)));
for(int i = 0; i < ro.Length; i++)
if (!ro[i].Any())
ro[i].Add(0);

List<Transform> transforms = new List<Transform>();
double r = Math.PI / 180;
Transform x = Transform.Rotation(a * r, pln.ZAxis, pln.Origin);
x *= Transform.Rotation(b * r, pln.YAxis, pln.Origin);
x *= Transform.Rotation(c * r, pln.XAxis, pln.Origin);
for (int i = 0; i < pln.Count; i++)
{
if (i > geo.Count) break;
Transform x = Transform.Rotation(ro[0][Math.Min(i, ro[0].Count-1)] * r, pln[i].ZAxis, pln[i].Origin);
x *= Transform.Rotation(ro[1][Math.Min(i, ro[1].Count - 1)] * r, pln[i].YAxis, pln[i].Origin);
x *= Transform.Rotation(ro[2][Math.Min(i, ro[2].Count - 1)] * r, pln[i].XAxis, pln[i].Origin);
transforms.Add(x);
geo[i].Transform(x);
}


DA.SetData(0, geo.Transform(x));
DA.SetData(1, x);
DA.SetDataList(0, geo);
DA.SetDataList(1,transforms);
}
}

Expand Down

0 comments on commit 8125475

Please sign in to comment.