go_openshowvar
is a Go library for interacting with Kuka robots over TCP/IP using the OpenShowVar protocol.
go-openshowvar
is a Go library that facilitates connecting to robot systems via TCP/IP to perform read and write operations. Targeting the KukaVarProxy server, it allows access to Kuka robots using the OpenShowVar protocol. This library is designed for use in robot control and monitoring applications, providing reliable communication over TCP/IP and extensive functionality for managing robot variables.
This project is inspired by the following repositories:
The communication with KukaVarProxy follows this message format:
- msg ID in HEX (2 bytes)
- msg length in HEX (2 bytes)
- read (0) or write (1) indicator (1 byte)
- variable name length in HEX (2 bytes)
- variable name in ASCII (# bytes)
- variable value length in HEX (2 bytes)
- variable value in ASCII (# bytes)
To install the go-openshowvar
library, use the following command:
- On Linux/macOS/Windows:
Open your terminal and execute:
go get github.com/selimserbes/go-openshowvar@latest
This library is designed to connect to Kuka robots via the KukaVarProxy server. KukaVarProxy is server software used to access Kuka robot system variables over TCP/IP.
-
To install and configure KukaVarProxy, please follow the instructions provided in the KukaVarProxy GitHub repository.
-
Ensure that
go_openshowvar
is configured to use port7000
to connect to the KukaVarProxy server. KukaVarProxy listens on this port to communicate with Kuka robots. -
Create your own program using the
go_openshowvar
library to connect to your robot. Below is an example:
package main
import (
"fmt"
"log"
"github.com/selimserbes/go-openshowvar/pkg/openshowvar"
)
func main() {
// Create a new OpenShowVar instance with the IP address and port of the TCP server.
osv := openshowvar.NewOpenShowVar("192.168.1.10", 7000)
// Connect to the TCP server.
err := osv.Connect()
if err != nil {
log.Fatalf("Failed to connect: %v", err)
}
defer osv.Disconnect()
// Check if there's a connection.
if osv.IsConnected() {
fmt.Println("Successfully connected!")
}
// Defining the value to be written and the variable name.
varName := "existing_var"
newValue := "new_value"
// Read a variable value.
initialValue, err := osv.Read(varName)
if err != nil {
log.Fatalf("Failed to read variable: %v", err)
}
fmt.Printf("Initial value of %s: %s\n", varName, initialValue)
// Write a new value to the variable.
_, err = osv.Write(varName, newValue)
if err != nil {
log.Fatalf("Failed to write variable: %v", err)
}
fmt.Printf("Written new value to %s: %s\n", varName, newValue)
// Read the variable value again to verify the change.
updatedValue, err := osv.Read(varName)
if err != nil {
log.Fatalf("Failed to read variable: %v", err)
}
fmt.Printf("Updated value of %s: %s\n", varName, updatedValue)
}
Contributions are welcome! If you'd like to contribute to go_openshowvar
, please fork the repository and submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.