Universal Robots+

Sample: URScript Communicator examples

URScript Communicator

Description of functionality:
Allows the developer to:

  • Send URScript to URControl, i.e. by user action (button)
  • Extract a value calculated in URScript into the URCap (or Java in general)

What topics are covered:
Secondary Client interface, extract data from URScript, secondary program

Find it on Github!

Requirements:
URCaps SDK v. 1.3 (due to Swing UI implementation)
But *.communicator classes can run with most version of PolyScope.

3 Likes

I can’t install this URCap directly into URSim. I edited the POM file by inserting:
<ursim.home>/home/ur/ursim/ursim-5.6.0.90886</ursim.home>
in place of:
<ursim.home>/home/jbm/ursim/ursim-3.7.0.40195/</ursim.home>
but when i write in terminal:
mvn install -P ursim
it gives me this error:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1:exec (ursim-install-urcap) on project scriptCommunicator: Result of /bin/sh -c cd /home/ur/workspace/com.jbm.urcap.sample.scriptCommunicator && cp target/scriptCommunicator-1.0-SNAPSHOT.jar /home/jbm/ursim/ursim-3.7.0.40195//.urcaps/com.jbm.urcap.sample.scriptCommunicator.jar execution is: '1'. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

To @a.mora

It was no problem to do “mvn install -P ursim” by myself.
Please try again.

The reason is maybe that pom.xml is not saved after replacing content of <ursim.home>
because your error content includes the following.

1 Like

The pom.xml file is saved.

I noticed that the project had a red X mark:
Screenshot from 2020-03-12 03-13-09

The “Problems” Eclipse tab suggested to do: Maven -> Update Project

I did that and the red X mark disappeared, but when trying to install the URCap I have the same error described before.

To @a.mora

Can you upload here “pom.xml” only?

<?xml version="1.0"?>
<project
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

	<modelVersion>4.0.0</modelVersion>

	<groupId>com.jbm.urcap.sample</groupId>
	<artifactId>scriptCommunicator</artifactId>
	<version>1.0-SNAPSHOT</version>
	<name>scriptCommunicator</name>
	<packaging>bundle</packaging>

	<properties>

		<!--********************************************************************-->
		<!--   Note: Update this section with relevant meta data                -->
		<!--         that comes along with your URCap                           -->
		<!--********************************************************************-->
		<!--******************* BEGINNING OF URCAP META DATA *******************-->
		<urcap.symbolicname>com.jbm.urcap.sample.scriptCommunicator</urcap.symbolicname>
		<urcap.vendor>URCaps R us Inc.</urcap.vendor>
		<urcap.contactAddress>123 URCap Street</urcap.contactAddress>
		<urcap.copyright>Copyright notice (C)</urcap.copyright>
		<urcap.description>This is a description of the URCap</urcap.description>
		<urcap.licenseType>License type</urcap.licenseType>
		<!--********************** END OF URCAP META DATA **********************-->
		<!--********************************************************************-->

		<!-- Host, username and password of the robot to be used when running "mvn install -Premote" -->
		<urcap.install.host>localhost</urcap.install.host>
		<urcap.install.username>root</urcap.install.username>
		<urcap.install.password>easybot</urcap.install.password>

		<!--Install path for the UR Sim-->
		<ursim.home>/home/ur/ursim/ursim-5.6.0.90886</ursim.home>

		<!--Host and standard user/password for UR Sim running in a VM-->
		<ursimvm.install.host></ursimvm.install.host>
		<ursimvm.install.username>ur</ursimvm.install.username>
		<ursimvm.install.password>easybot</ursimvm.install.password>
	</properties>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.6.0</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
			<plugin> 
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.0.2</version>
				<configuration>
					<archive>
						<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
					</archive>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<version>3.0.2</version>
			</plugin>
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>2.4.0</version>
				<extensions>true</extensions>
				<executions>
					<execution>
						<id>bundle-manifest</id>
						<phase>process-classes</phase>
							<goals>
								<goal>manifest</goal>
							</goals>
					</execution>
				</executions>
				<configuration>
					<instructions>
						<!--********** DO NOT MODIFY THE ENTRIES OF THIS SECTION **********-->
						<Bundle-Category>URCap</Bundle-Category>
						<Bundle-Activator>com.jbm.urcap.sample.scriptCommunicator.impl.Activator</Bundle-Activator>
						<Bundle-Vendor>${urcap.vendor}</Bundle-Vendor>
						<Bundle-ContactAddress>${urcap.contactAddress}</Bundle-ContactAddress>
						<Bundle-Copyright>${urcap.copyright}</Bundle-Copyright>
						<Bundle-LicenseType>${urcap.licenseType}</Bundle-LicenseType>
						<Bundle-Description>${urcap.description}</Bundle-Description>
						<!--***************************************************************-->
						<Import-Package>
							com.ur.urcap.api*;version="[1.3.0,2.0.0)",
							*
						</Import-Package>
					</instructions>
				</configuration>
			</plugin>
			<plugin>
	          <groupId>org.apache.maven.plugins</groupId>
	          <artifactId>maven-surefire-plugin</artifactId>
	          <version>2.22.1</version>
	          <configuration>
	              <useSystemClassLoader>false</useSystemClassLoader>
	          </configuration>
      		</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>exec-maven-plugin</artifactId>
				<version>1.1</version>
				<executions>
					<!-- generate URCap package after compiling -->
					<execution>
						<id>package-urcap</id>
						<phase>package</phase>
						<goals>
							<goal>exec</goal>
						</goals>
						<configuration>
							<executable>cp</executable>
								<commandlineArgs>target/${project.build.finalName}.jar target/${project.build.finalName}.urcap</commandlineArgs>
							<workingDirectory>.</workingDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

	<dependencies>
		<dependency>
			<groupId>org.osgi</groupId>
			<artifactId>org.osgi.core</artifactId>
			<version>4.3.0</version>
		</dependency>

		<dependency>
			<groupId>com.ur.urcap</groupId>
			<artifactId>api</artifactId>
			<version>1.3.0</version>
			<scope>provided</scope>
		</dependency>

		<!-- test dependencies -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>remote</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>1.1</version>
						<executions>
							<execution>
								<id>remote-install-urcap</id>
								<phase>install</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>sshpass</executable>
									<commandlineArgs>-p ${urcap.install.password} scp -o StrictHostKeyChecking=no target/${project.build.finalName}.jar ${urcap.install.username}@${urcap.install.host}:/root/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
									<workingDirectory>.</workingDirectory>
								</configuration>
							</execution>
							<execution>
								<id>remote-restart-ui</id>
								<phase>install</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>sshpass</executable>
									<commandlineArgs>-p ${urcap.install.password} ssh ${urcap.install.username}@${urcap.install.host} pkill java</commandlineArgs>
									<workingDirectory>.</workingDirectory>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>local</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>1.1</version>
						<executions>
							<execution>
								<id>local-install-urcap</id>
								<phase>install</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>cp</executable>
									<commandlineArgs>target/${project.build.finalName}.jar ${user.home}/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
									<workingDirectory>.</workingDirectory>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>ursim</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>1.1</version>
						<executions>
							<execution>
								<id>ursim-install-urcap</id>
								<phase>install</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>cp</executable>
									<commandlineArgs>target/${project.build.finalName}.jar ${ursim.home}/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
									<workingDirectory>.</workingDirectory>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>ursimvm</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>1.1</version>
						<executions>
							<execution>
								<id>ursimvm-install-urcap</id>
								<phase>install</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>sshpass</executable>
									<commandlineArgs>-p ${ursimvm.install.password} scp -o StrictHostKeyChecking=no target/${project.build.finalName}.jar ${ursimvm.install.username}@${ursimvm.install.host}:/home/ur/ursim-current/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
									<workingDirectory>.</workingDirectory>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>

Maybe it is no problem.
Did you compiled on Eclipse?
If you compile on vscode, does it cause same error?

I’m sorry but I’m not an expert on Java/Eclipse/VSCode. I tried in Eclipse to do Project - Clean and then to disable Build Automatically and perform Build All after selecting the scriptCommunicator project. The result of “mvn install -P ursim” is always the same in both cases. I will try with VSCode.

My result with VSCode is the following.
I upload pom.xml when I tried to do “mvn install -P ursim” for SW5.6

pom.zip (2.0 KB)

1 Like