Giter VIP home page Giter VIP logo

xarm-grpc's Introduction

xarm-grpc

A gRPC service implemenation for controlling UFACTORY xArm series using the xArm-CPLUS-SDK.

The dependencies are added as subomodules, so when cloning this repository, do:

$ git clone [email protected]:Interactions-HSG/xarm-grpc.git --recursive

This project implements the following:

  • xarm-grpc-service: The gRPC service responsible for the Modbus/TCP connection management and packet generation (i.e., xArmAPI object) providing the xArmAPI as a service.
  • xarm-commander: A gRPC client implemented as a C++ CLI Tool to run commands on xArms. For further information about the xarm-commander go to section Tools.

The proto file is defined in proto/xapi.proto based on xarm_api.h.

The following services are specific to the connection management:

  • Initialize: instantiate a xArmAPI object and connect the server to a xArm specified by the -x option.
  • Disconnect: close the connection to the xArm.

Preparation

xArm-CPLUS-SDK

To use the xarm-grpc-service first install the xArm-PLUS-SDK library:

$ make -C libs/xArm-CPLUS-SDK xarm

cmake, gRPC and Protocol Buffers

Follow the gRPC's Quick start guide to install cmake, gRPC, and Protocol Buffers.

The rest of this document assumes you have installed gRPC and Protocol Buffers in ~/.local.

Build xarm-grpc-service and xarm-commander

$ mkdir -p cmake/build && cd cmake/build
$ cmake -DCMAKE_PREFIX_PATH=~/.local ../..
$ make -j

Synopsis

The gRPC service can be started using following command:

$ xarm-grpc-service start

Then use a gRPC client (e.g., xarm-commander) to send commands to the xArm.

To close the gRPC service run:

$ xarm-grpc-service stop

For further description about usage of the xarm-grpc-service, use -h or --help.

Tools

The Tools directory includes available clients for the xarm-grpc-service. Currently, the following clients are implemented:

  • xarm-commander: A gRPC client implemented as a C++ CLI Tool to run commands on xArms. For further instructions on how to use the xarm-commander see here.

Dependencies

How to contribute to this project?

See CONTRIBUTING.md.

Maintainers

Contributors

See here

License

See LICENSE.

xarm-grpc's People

Contributors

iomz avatar jo-bru avatar s-eibl avatar stefan7545 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

xarm-grpc's Issues

Refactor: exception escape

Resolve following problem:
an exception may be thrown in function 'main' which should not throw exceptionsclang-tidy(bugprone-exception-escape)

C++: Disable console output of xArm SDK

In order to use the CLI tool with other frameworks/languages (e.g. Nodejs) the output of the xArm SDK must be disabled/formatted. In the best case, this complies with the setting for multi-level logging, which is determined by the flags. (see issue #4)

Logging: CLI options for setting format and output

Add CLI options to be able to format and define output (e.g. Logfile) for logging information.

By setting a logging destination, the additional information (info, debug, eval) can be retrieved from an external file if the xarm-commander is used in an integrated way (e.g. called by Nodejs).

How to handle logging

Best way to return values, log information/debug messages.
Define syntax for return values, response code and logging messages. (maybe use json)

Consistency Problems for Properties: Service Properties vs. Controller Properties

Some properties (let's call them controller properties) such as angles are stored on the controller and therefore are fetched by sending a request to the controller.

Others (let's call them service properties), like last_used_angles are only stored as a property of the XArmAPI* api object (xARM-CPLUS-SDK) and are therefore not fetched from the controller.

Controller Properties are consistent over different sessions (session = initialization =>disconnect), on the other hand, Service Properties are reset every time a new session is started by calling initialize.
This is probably desired but still might create some problems (e.g. see Issue #44 ).

This might also be interesting for multi-user applications.

Needs to be further discussed and investigated..

Capability exposure through stdout in JSON-LD format

For wot-servients to interpret the capability of xArms (i.e., the C++ SDK/xarm-commander), it's a nice feature to have an option to print the capabilities for each command in a machine-readable format (e.g., JSON-LD).
Implement this by either a single global command or an option for each available command.

Serialization Error: Invalid UTF-8 Data in String Field

Sending multiple getVersion requests may result in breaking the gRPC connection, resulting in the following error message:

[XAPIDeamon] stderr: [libprotobuf ERROR /home/jo-bru/grpc/third_party/protobuf/src/google/protobuf/wire_format_lite.cc:577] String field 'xapi.Version.version' contains invalid UTF-8 data when serializing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes.

Strange behaviour with set_servo_angle(single servo) command

sending a set_servo_angle for a single angle right after initialization results in moving the robot with the given angle AND other all angles to the home position.
This can be recreated by doing the following:

xarm-commander initialize -x 130.82.171.9
xarm-commander set_position
xarm-commander disconnect
xarm-commander initialize -x 130.82.171.9
xarm-commander set_servo_angle -i 1 -a 20

`SetDefaultIsRadian` can be dangerous!

Changing the default_is_radian value can be dangerous, since some motion commands use last_used_x as default values.
As described in #45, last_used_x is a Service Property and will therefore not be adapted to the unit change (deg <=> rad).
This can lead to fast and unwanted movements (e.g., speed unit is deg/s <=> rad/s).

The SetDefaultRadian command will therefore be deactivated for now.

Proper external library handling

Include external libraries (e.g. CLI11, easylogging++) properly => sub-moduled or prepared by the users.
[optional] create CMake files.

Restructure the repo towards xarm-grpc-service

  • xarm-grpc-service: repo including xarm-deamon and .proto definitions
  • wot-fx/../nodewot-xarm: implements a gRPC client using the xarm-grpc-service as a submodule (to get the .proto definitions?)
  • xarm-commander: two options
    • seperate repo using the xarm-grpc-service as a submodule
    • or: included in xarm-grpc-service as tool or example

Originally posted by @jo-bru in #32 (review)

GetVersion response has trailing \00

The GetVersion request returns the version with trailing zeros.

"h2,v1.6.5\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"

Build test in the GitHub Action

Due to the complex dependency, we need to validate the build on the main branch always succeeds.
Add a workflow for build test including the generation of grpc sources from the proto file.

Clean up the build procedure

The dependencies are currently handled manually via the submodules. However, integrating them with cmake or bazel is preferable.

xARM-SDK Method `get_robot_sn()` doesn't work

Calling the get_robot_sn() using the following doesn't work (i.e., returns an empty value).

unsigned char robot_sn_char[40];
status_code = api->get_robot_sn(robot_sn_char);

The GetRobotSN was introduced in d73658f.

Error on multiple parallel requests

If more than four commands are sent in parallel, some commands will fail.

Example Error: Error: Command failed: xarm-commander -i 130.82.171.9 -v get_position

This error can be reproduced by calling more than four commands in parallel running for example the following:

Promise.all([
            sendCommand(['-i', IPaddress, '-v', 'get_version']),
            sendCommand(['-i', IPaddress, '-v', 'get_state']),
            sendCommand(['-i', IPaddress, '-v', 'get_state']),
            sendCommand(['-i', IPaddress, '-v', 'get_state']),
            sendCommand(['-i', IPaddress, '-v', 'get_position'])]);
    })

To understand this error, it should be investigated how many connections can be processed simultaneously by the CPLUS SDK.

Implement Proper Error Handling

Implement error handling to throw an error when the responseCode is not 0 (i.e., the command was not successful).
Return the responseCode without the responseValue by using stderr (?).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.