├── Properties └── AssemblyInfo.cs ├── README.md └── src ├── .gitignore ├── ControlPanel.Designer.cs ├── ControlPanel.cs ├── ControlPanel.resx ├── Egm.cs ├── EgmSmallTest.csproj ├── EgmSmallTest.sln ├── Program.cs ├── README.md ├── Robotstudio ├── Glider program.rspag └── Modfil glider.mod └── app.config /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("EgmSmallTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("EgmSmallTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a1e09c77-22a2-4e5a-84d4-9e491bbf734c")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EGM-Slider 2 | 3 | This program uses a simulated sensor to adjust the height of an ABB robotic arm with Externally Guided Motion implemented. 4 | The robot moves in a square and the height is adjusted using a slider. The robot must be compatible with RobotWare 6.x. 5 | All tests were done on an IRB140 industrial robotic arm. 6 | 7 | Program.cs is built upon the example code given by ABB. 8 | 9 | EGM.cs is autogenerated code from the egm.proto -file. 10 | 11 | More information on Externally Guided Motion can be found in: Application manual - Controller software IRC5, which is a manual released by ABB. 12 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opensdf 80 | *.sdf 81 | *.cachefile 82 | 83 | # Visual Studio profiler 84 | *.psess 85 | *.vsp 86 | *.vspx 87 | *.sap 88 | 89 | # TFS 2012 Local Workspace 90 | $tf/ 91 | 92 | # Guidance Automation Toolkit 93 | *.gpState 94 | 95 | # ReSharper is a .NET coding add-in 96 | _ReSharper*/ 97 | *.[Rr]e[Ss]harper 98 | *.DotSettings.user 99 | 100 | # JustCode is a .NET coding add-in 101 | .JustCode 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | _NCrunch_* 111 | .*crunch*.local.xml 112 | nCrunchTemp_* 113 | 114 | # MightyMoose 115 | *.mm.* 116 | AutoTest.Net/ 117 | 118 | # Web workbench (sass) 119 | .sass-cache/ 120 | 121 | # Installshield output folder 122 | [Ee]xpress/ 123 | 124 | # DocProject is a documentation generator add-in 125 | DocProject/buildhelp/ 126 | DocProject/Help/*.HxT 127 | DocProject/Help/*.HxC 128 | DocProject/Help/*.hhc 129 | DocProject/Help/*.hhk 130 | DocProject/Help/*.hhp 131 | DocProject/Help/Html2 132 | DocProject/Help/html 133 | 134 | # Click-Once directory 135 | publish/ 136 | 137 | # Publish Web Output 138 | *.[Pp]ublish.xml 139 | *.azurePubxml 140 | # TODO: Comment the next line if you want to checkin your web deploy settings 141 | # but database connection strings (with potential passwords) will be unencrypted 142 | *.pubxml 143 | *.publishproj 144 | 145 | # NuGet Packages 146 | *.nupkg 147 | # The packages folder can be ignored because of Package Restore 148 | **/packages/* 149 | # except build/, which is used as an MSBuild target. 150 | !**/packages/build/ 151 | # Uncomment if necessary however generally it will be regenerated when needed 152 | #!**/packages/repositories.config 153 | 154 | # Windows Azure Build Output 155 | csx/ 156 | *.build.csdef 157 | 158 | # Windows Azure Emulator 159 | efc/ 160 | rfc/ 161 | 162 | # Windows Store app package directory 163 | AppPackages/ 164 | 165 | # Visual Studio cache files 166 | # files ending in .cache can be ignored 167 | *.[Cc]ache 168 | # but keep track of directories ending in .cache 169 | !*.[Cc]ache/ 170 | 171 | # Others 172 | ClientBin/ 173 | [Ss]tyle[Cc]op.* 174 | ~$* 175 | *~ 176 | *.dbmdl 177 | *.dbproj.schemaview 178 | *.pfx 179 | *.publishsettings 180 | node_modules/ 181 | orleans.codegen.cs 182 | 183 | # RIA/Silverlight projects 184 | Generated_Code/ 185 | 186 | # Backup & report files from converting an old project file 187 | # to a newer Visual Studio version. Backup files are not needed, 188 | # because we have git ;-) 189 | _UpgradeReport_Files/ 190 | Backup*/ 191 | UpgradeLog*.XML 192 | UpgradeLog*.htm 193 | 194 | # SQL Server files 195 | *.mdf 196 | *.ldf 197 | 198 | # Business Intelligence projects 199 | *.rdl.data 200 | *.bim.layout 201 | *.bim_*.settings 202 | 203 | # Microsoft Fakes 204 | FakesAssemblies/ 205 | 206 | # GhostDoc plugin setting file 207 | *.GhostDoc.xml 208 | 209 | # Node.js Tools for Visual Studio 210 | .ntvs_analysis.dat 211 | 212 | # Visual Studio 6 build log 213 | *.plg 214 | 215 | # Visual Studio 6 workspace options file 216 | *.opt 217 | 218 | # Visual Studio LightSwitch build output 219 | **/*.HTMLClient/GeneratedArtifacts 220 | **/*.DesktopClient/GeneratedArtifacts 221 | **/*.DesktopClient/ModelManifest.xml 222 | **/*.Server/GeneratedArtifacts 223 | **/*.Server/ModelManifest.xml 224 | _Pvt_Extensions 225 | 226 | # Paket dependency manager 227 | .paket/paket.exe 228 | -------------------------------------------------------------------------------- /src/ControlPanel.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace EgmSmallTest 2 | { 3 | partial class ControlPanel 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.trackBarHeight = new System.Windows.Forms.TrackBar(); 32 | this.lblGlider = new System.Windows.Forms.Label(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.lblHeight = new System.Windows.Forms.Label(); 35 | ((System.ComponentModel.ISupportInitialize)(this.trackBarHeight)).BeginInit(); 36 | this.SuspendLayout(); 37 | // 38 | // trackBarHeight 39 | // 40 | this.trackBarHeight.Location = new System.Drawing.Point(51, 75); 41 | this.trackBarHeight.Maximum = 200; 42 | this.trackBarHeight.Minimum = 0; 43 | this.trackBarHeight.Name = "trackBarHeight"; 44 | this.trackBarHeight.Size = new System.Drawing.Size(202, 45); 45 | this.trackBarHeight.TabIndex = 0; 46 | this.trackBarHeight.TickFrequency = 50; 47 | this.trackBarHeight.Value = 0; 48 | this.trackBarHeight.ValueChanged += new System.EventHandler(this.trackBarHeight_ValueChanged); 49 | // 50 | // lblGlider 51 | // 52 | this.lblGlider.AutoSize = true; 53 | this.lblGlider.Location = new System.Drawing.Point(48, 46); 54 | this.lblGlider.Name = "lblGlider"; 55 | this.lblGlider.Size = new System.Drawing.Size(41, 13); 56 | this.lblGlider.TabIndex = 1; 57 | this.lblGlider.Text = "Height:"; 58 | // 59 | // label1 60 | // 61 | this.label1.Location = new System.Drawing.Point(0, 0); 62 | this.label1.Name = "label1"; 63 | this.label1.Size = new System.Drawing.Size(100, 23); 64 | this.label1.TabIndex = 0; 65 | // 66 | // lblHeight 67 | // 68 | this.lblHeight.AutoSize = true; 69 | this.lblHeight.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 70 | this.lblHeight.Location = new System.Drawing.Point(107, 135); 71 | this.lblHeight.Name = "lblHeight"; 72 | this.lblHeight.Size = new System.Drawing.Size(0, 25); 73 | this.lblHeight.TabIndex = 2; 74 | // 75 | // ControlPanel 76 | // 77 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 78 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 79 | this.ClientSize = new System.Drawing.Size(302, 207); 80 | this.Controls.Add(this.lblHeight); 81 | this.Controls.Add(this.label1); 82 | this.Controls.Add(this.lblGlider); 83 | this.Controls.Add(this.trackBarHeight); 84 | this.Name = "ControlPanel"; 85 | this.Text = "ControlPanel"; 86 | ((System.ComponentModel.ISupportInitialize)(this.trackBarHeight)).EndInit(); 87 | this.ResumeLayout(false); 88 | this.PerformLayout(); 89 | 90 | } 91 | 92 | #endregion 93 | 94 | private System.Windows.Forms.TrackBar trackBarHeight; 95 | private System.Windows.Forms.Label lblGlider; 96 | private System.Windows.Forms.Label label1; 97 | private System.Windows.Forms.Label lblHeight; 98 | } 99 | } -------------------------------------------------------------------------------- /src/ControlPanel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace EgmSmallTest 5 | { 6 | public partial class ControlPanel : Form 7 | { 8 | Sensor sensor; 9 | 10 | public ControlPanel(Sensor sensor) 11 | { 12 | this.sensor = sensor; 13 | sensor.Start(); 14 | InitializeComponent(); 15 | } 16 | 17 | private void trackBarHeight_ValueChanged(object sender, EventArgs e) 18 | { 19 | var trackBar = (sender as TrackBar); 20 | var value = trackBar.Value; 21 | sensor.Height = value; 22 | lblHeight.Text = value.ToString(); 23 | System.Diagnostics.Debug.WriteLine(value); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/ControlPanel.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /src/EgmSmallTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {CC039559-7A83-4EFB-9AD8-1059912A3EA4} 9 | Exe 10 | Properties 11 | EgmSmallTest 12 | EgmSmallTest 13 | v4.0 14 | 15 | 16 | 512 17 | 18 | 19 | x86 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | x86 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\..\..\..\Dropbox\ELE630 - EGM prosjekt\Program\C# Glider\bin\Debug\Google.ProtocolBuffers.dll 40 | 41 | 42 | ..\..\..\..\Dropbox\ELE630 - EGM prosjekt\Program\C# Glider\bin\Debug\Google.ProtocolBuffers.Serialization.dll 43 | 44 | 45 | 46 | 47 | 48 | ..\..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Windows\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Windows.dll 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Form 60 | 61 | 62 | ControlPanel.cs 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | ControlPanel.cs 74 | 75 | 76 | 77 | 84 | -------------------------------------------------------------------------------- /src/EgmSmallTest.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgmSmallTest", "EgmSmallTest.csproj", "{CC039559-7A83-4EFB-9AD8-1059912A3EA4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {CC039559-7A83-4EFB-9AD8-1059912A3EA4}.Debug|x86.ActiveCfg = Debug|x86 15 | {CC039559-7A83-4EFB-9AD8-1059912A3EA4}.Debug|x86.Build.0 = Debug|x86 16 | {CC039559-7A83-4EFB-9AD8-1059912A3EA4}.Release|x86.ActiveCfg = Release|x86 17 | {CC039559-7A83-4EFB-9AD8-1059912A3EA4}.Release|x86.Build.0 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /src/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Net; 4 | using System.Net.Sockets; 5 | using System.Threading; 6 | using System.Windows.Forms; 7 | using abb.egm; 8 | 9 | ////////////////////////////////////////////////////////////////////////// 10 | // Sample program using protobuf-csharp-port 11 | // (http://code.google.com/p/protobuf-csharp-port/wiki/GettingStarted) 12 | // 13 | // 1) Download protobuf-csharp binaries from https://code.google.com/p/protobuf-csharp-port/ 14 | // 2) Unpack the zip file 15 | // 3) Copy the egm.proto file to a sub catalogue where protobuf-csharp was un-zipped, e.g. ~\protobuf-csharp\tools\egm 16 | // 4) Generate an egm C# file from the egm.proto file by typing in a windows console: protogen .\egm\egm.proto --proto_path=.\egm 17 | // 5) Create a C# console application in Visual Studio 18 | // 6) Install Nuget, in Visual Studio, click Tools and then Extension Manager. Goto to Online, find the NuGet Package Manager extension and click Download. 19 | // 7) Install protobuf-csharp via NuGet, select in Visual Studio, Tools Nuget Package Manager and then Package Manager Console and type PM>Install-Package Google.ProtocolBuffers 20 | // 8) Add the generated file egm.cs to the Visual Studio project (add existing item) 21 | // 9) Copy the code below and then compile, link and run. 22 | ////////////////////////////////////////////////////////////////////////// 23 | 24 | namespace EgmSmallTest 25 | { 26 | class Program 27 | { 28 | // listen on this port for inbound messages 29 | public static int IpPortNumber = 6510; 30 | 31 | static void Main(string[] args) 32 | { 33 | Sensor s = new Sensor(); 34 | Application.Run(new ControlPanel(s)); 35 | 36 | Console.WriteLine("Press any key to Exit"); 37 | Console.ReadLine(); 38 | } 39 | } 40 | 41 | public class Sensor 42 | { 43 | private Thread _sensorThread = null; 44 | private UdpClient _udpServer = null; 45 | private bool _exitThread = false; 46 | private uint _seqNumber = 0; 47 | private int _distanceSquare; 48 | private int _xStartPoint; 49 | private int _yStartPoint; 50 | private float _x; 51 | private float _y; 52 | private int _robotX; 53 | private int _robotY; 54 | private int _robotZ; 55 | 56 | public double Height { get; set; } 57 | 58 | // Set the measurements for the square and initialize the start points 59 | public Sensor() 60 | { 61 | _distanceSquare = 200; 62 | _xStartPoint = 50; 63 | _yStartPoint = -400; 64 | _x = 50; 65 | _y = -400; 66 | _robotX = 0; 67 | _robotY = 0; 68 | _robotZ = 0; 69 | } 70 | 71 | 72 | public void SensorThread() 73 | { 74 | // create an udp client and listen on any address and the port _ipPortNumber 75 | _udpServer = new UdpClient(Program.IpPortNumber); 76 | var remoteEP = new IPEndPoint(IPAddress.Any, Program.IpPortNumber); 77 | 78 | while (_exitThread == false) 79 | { 80 | // get the message from robot 81 | var data = _udpServer.Receive(ref remoteEP); 82 | 83 | if (data != null) 84 | { 85 | // de-serialize inbound message from robot using Google Protocol Buffer 86 | EgmRobot robot = EgmRobot.CreateBuilder().MergeFrom(data).Build(); 87 | 88 | // display inbound message 89 | DisplayInboundMessage(robot); 90 | 91 | // Get the robots X-position 92 | _robotX = Convert.ToInt32((robot.FeedBack.Cartesian.Pos.X)); 93 | // Get the robots Y-position 94 | _robotY = Convert.ToInt32((robot.FeedBack.Cartesian.Pos.Y)); 95 | // Get the robots Z-position 96 | _robotZ = Convert.ToInt32((robot.FeedBack.Cartesian.Pos.Z)); 97 | 98 | 99 | 100 | // create a new outbound sensor message 101 | EgmSensor.Builder sensor = EgmSensor.CreateBuilder(); 102 | CreateSensorMessage(sensor); 103 | 104 | using (MemoryStream memoryStream = new MemoryStream()) 105 | { 106 | EgmSensor sensorMessage = sensor.Build(); 107 | sensorMessage.WriteTo(memoryStream); 108 | 109 | // send the UDP message to the robot 110 | int bytesSent = _udpServer.Send(memoryStream.ToArray(), 111 | (int)memoryStream.Length, remoteEP); 112 | if (bytesSent < 0) 113 | { 114 | Console.WriteLine("Error send to robot"); 115 | } 116 | } 117 | } 118 | } 119 | } 120 | 121 | // Display message from robot 122 | void DisplayInboundMessage(EgmRobot robot) 123 | { 124 | if (robot.HasHeader && robot.Header.HasSeqno && robot.Header.HasTm) 125 | { 126 | Console.WriteLine("Seq={0} tm={1}", 127 | robot.Header.Seqno.ToString(), robot.Header.Tm.ToString()); 128 | } 129 | else 130 | { 131 | Console.WriteLine("No header in robot message"); 132 | } 133 | } 134 | 135 | ////////////////////////////////////////////////////////////////////////// 136 | // Create a sensor message to send to the robot 137 | void CreateSensorMessage(EgmSensor.Builder sensor) 138 | { 139 | // create a header 140 | EgmHeader.Builder hdr = new EgmHeader.Builder(); 141 | hdr.SetSeqno(_seqNumber++) 142 | //Timestamp in milliseconds (can be used for monitoring delays) 143 | .SetTm((uint)DateTime.Now.Ticks) 144 | //Sent by sensor, MSGTYPE_DATA if sent from robot controller 145 | .SetMtype(EgmHeader.Types.MessageType.MSGTYPE_CORRECTION); 146 | 147 | sensor.SetHeader(hdr); 148 | 149 | // create some sensor data 150 | EgmPlanned.Builder planned = new EgmPlanned.Builder(); 151 | EgmPose.Builder pos = new EgmPose.Builder(); 152 | EgmQuaternion.Builder pq = new EgmQuaternion.Builder(); 153 | EgmCartesian.Builder pc = new EgmCartesian.Builder(); 154 | 155 | _x = X_Values_Square(); 156 | _y = Y_Values_Square(); 157 | 158 | pc.SetX(_x) 159 | .SetY(_y) 160 | .SetZ(Height); 161 | 162 | pq.SetU0(0.0) 163 | .SetU1(0.0) 164 | .SetU2(0.0) 165 | .SetU3(0.0); 166 | 167 | pos.SetPos(pc) 168 | .SetOrient(pq); 169 | 170 | // bind pos object to planned 171 | planned.SetCartesian(pos); 172 | // bind planned to sensor object 173 | sensor.SetPlanned(planned); 174 | 175 | return; 176 | } 177 | 178 | // Start a thread to listen on inbound messages 179 | public void Start() 180 | { 181 | _sensorThread = new Thread(new ThreadStart(SensorThread)); 182 | _sensorThread.Start(); 183 | } 184 | 185 | // Stop and exit thread 186 | public void Stop() 187 | { 188 | _exitThread = true; 189 | _sensorThread.Abort(); 190 | } 191 | 192 | 193 | //Set the Y-positions for the square 194 | public float Y_Values_Square() 195 | { 196 | if (_robotX == _xStartPoint + _distanceSquare && _robotY == _yStartPoint) 197 | { 198 | _y = _yStartPoint - _distanceSquare; 199 | 200 | } 201 | else if (_robotX == _xStartPoint && _robotY == _yStartPoint - _distanceSquare && _y == _yStartPoint - _distanceSquare) 202 | { 203 | _y = _y + _distanceSquare; 204 | 205 | } 206 | return _y; 207 | } 208 | 209 | 210 | // Set the X-positions for the square 211 | public float X_Values_Square() 212 | { 213 | if (_robotX == _xStartPoint && _robotY == _yStartPoint && _x == _xStartPoint) 214 | { 215 | _x = _x + _distanceSquare; 216 | } 217 | 218 | else if(_robotX == _xStartPoint + _distanceSquare && _robotY == _yStartPoint - _distanceSquare && _x == _xStartPoint + _distanceSquare) 219 | { 220 | _x = _x - _distanceSquare; 221 | } 222 | return _x; 223 | } 224 | } 225 | } 226 | 227 | 228 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | # How to Run 2 | _________________ 3 | 4 | 5 | ## Visual Studio 6 | **Add the missing refrences** Google.ProtocolBuffers.dll, Google.ProtocolBuffers.Serialization.dll, System.Windows.dll. 7 | 8 | ## RobotStudio 9 | 10 | EGMSensor needs to be defined under **Configuration Editor** - **Communication** - **Transmission Protocol.** The parameters are: 11 | 12 | | Name | Type | Serial Port | Remote Adress | Remote port number | 13 | | ----------- |:--------------:| ------------:| ---------------:| --------------------:| 14 | | EGMSensor | UDPUC | N/A | Computers IP | 6510 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Robotstudio/Glider program.rspag: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orjanmehre/EGM-Slider/2f739be1ce7496834ecb539514b6dd0a26486c12/src/Robotstudio/Glider program.rspag -------------------------------------------------------------------------------- /src/Robotstudio/Modfil glider.mod: -------------------------------------------------------------------------------- 1 | MODULE EGM_test_UDP 2 | 3 | VAR egmident egmID1; 4 | VAR egmstate egmSt1; 5 | 6 | CONST egm_minmax egm_minmax_lin1:=[-1,1]; !in mm 7 | CONST egm_minmax egm_minmax_rot1:=[-2,2];! in degees 8 | CONST robtarget p20:=[[34,-499,123],[0.000494947,0.662278052,-0.749217059,-0.007831731],[0,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]]; 9 | 10 | PERS tooldata UISpenholder:=[TRUE,[[0,0,114.25],[1,0,0,0]],[1,[-0.095984607,0.082520613,38.69176324],[1,0,0,0],0,0,0]]; 11 | TASK PERS wobjdata wobjBordN:=[FALSE,TRUE,"",[[0,0,0],[1,0,0,0]],[[150,-500,8],[0.707106781,0,0,-0.707106781]]]; 12 | 13 | VAR pose posecorTable:=[[150,-500,8],[1,0,0,0]]; 14 | VAR pose posesenTable:=[[150,-500,8],[1,0,0,0]]; 15 | 16 | 17 | PROC main() 18 | ! Move to start position. Fine point is demanded. 19 | MoveJ p20,v100,fine,UISpenholder; 20 | testuc_UDP; 21 | ENDPROC 22 | 23 | 24 | PROC testuc_UDP() 25 | EGMReset egmID1; 26 | EGMGetId egmID1; 27 | egmSt1 := EGMGetState(egmID1); 28 | TPWrite "EGM state: "\Num := egmSt1; 29 | 30 | IF egmSt1 <= EGM_STATE_CONNECTED THEN 31 | ! Set up the EGM data source: UdpUc server using device "EGMsensor:"and configuration "default" 32 | EGMSetupUC ROB_1, egmID1, "default", "EGMSensor:" \pose; 33 | ENDIF 34 | 35 | !Which program to run 36 | runEGM; 37 | 38 | IF egmSt1 = EGM_STATE_CONNECTED THEN 39 | TPWrite "Reset EGM instance egmID1"; 40 | EGMReset egmID1; 41 | ENDIF 42 | ENDPROC 43 | 44 | 45 | PROC runEGM() 46 | EGMActPose egmID1\Tool:=UISpenholder \WObj:=wobj0, posecorTable,EGM_FRAME_WOBJ, posesenTable, EGM_FRAME_WOBJ 47 | \x:=egm_minmax_lin1 \y:=egm_minmax_lin1 \z:=egm_minmax_lin1 48 | \rx:=egm_minmax_rot1 \ry:=egm_minmax_rot1 \rz:=egm_minmax_rot1\LpFilter:=2\Samplerate:=4\MaxSpeedDeviation:= 40; 49 | 50 | EGMRunPose egmID1, EGM_STOP_RAMP_DOWN\x \y \z\CondTime:=20 \RampInTime:=0.05\RampOutTime:=0.5; 51 | egmSt1:=EGMGetState(egmID1); 52 | ENDPROC 53 | 54 | ENDMODULE -------------------------------------------------------------------------------- /src/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | --------------------------------------------------------------------------------