Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Communication between C++ and Java #51

Closed
8 tasks done
ahundt opened this issue Feb 20, 2015 · 4 comments
Closed
8 tasks done

Communication between C++ and Java #51

ahundt opened this issue Feb 20, 2015 · 4 comments
Assignees

Comments

@ahundt
Copy link
Owner

ahundt commented Feb 20, 2015

We will serialize one line of the path format, then send it from C++ to Java:
http://www.coppeliarobotics.com/helpFiles/en/pathImportExport.htm

Serialization will be done with a shared flatbuffer data type:
https://github.com/google/flatbuffers

A message passing system, Zeromq, will be used to pass the serialized message from C++ to Java:
http://zeromq.org/

Java will feed the point to the robot initially using smartservo.

FRI can potentially be used later to overlay and adjust the motion.

Question: where to handle transform from optical tracker to robot base frame?

C++

@athundt will take the lead on this

  • Install zeromq
  • Install google flatbuffers
  • Implement messaging functions for path step then full path

Java

@astrick3 can you take the lead on this part?

Testing

  • Communication with C++ plugin over zeromq+flatbuffers
@ahundt ahundt self-assigned this Feb 20, 2015
@ahundt ahundt added this to the Sprint 2 - Initial Arm Integration milestone Feb 20, 2015
@ahundt
Copy link
Owner Author

ahundt commented Feb 20, 2015

Commit df67234 creates the initial path flatbuffer file.

ahundt added a commit that referenced this issue Feb 24, 2015
ahundt added a commit that referenced this issue Feb 24, 2015
ahundt added a commit that referenced this issue Feb 24, 2015
ahundt added a commit that referenced this issue Feb 25, 2015
ahundt added a commit that referenced this issue Feb 26, 2015
ahundt added a commit that referenced this issue Feb 28, 2015
ahundt added a commit that referenced this issue Feb 28, 2015
…ho_server.cpp. Fixed RobonePlugin so it compiles.
@ahundt
Copy link
Owner Author

ahundt commented Feb 28, 2015

I created a few azmq issues during this process to help me learn and debug azmq:

@ahundt
Copy link
Owner Author

ahundt commented Mar 16, 2015

I ran a test using the instructions with Java in a VM and C++ running in OS X. There was no communication between the two. I took a look and the Java implementation appears to use a pub/sub system rather than a zeromq dealer system.

@ahundt ahundt assigned astrick3 and unassigned ahundt Mar 16, 2015
@ahundt
Copy link
Owner Author

ahundt commented Mar 16, 2015

It looks like we need to add a motion overlay for FRI command control to work. Here is the Java from Kuka's sample application.

package com.kuka.connectivity.fri.example;

import static com.kuka.roboticsAPI.motionModel.BasicMotions.ptp;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import com.kuka.connectivity.fri.FRIConfiguration;
import com.kuka.connectivity.fri.FRIJointOverlay;
import com.kuka.connectivity.fri.FRISession;
import com.kuka.roboticsAPI.applicationModel.RoboticsAPIApplication;
import com.kuka.roboticsAPI.controllerModel.Controller;
import com.kuka.roboticsAPI.deviceModel.LBR;

/**
 * Creates a FRI Session.
 */
public class LBRJointSineOverlay extends RoboticsAPIApplication
{
    private Controller _lbrController;
    private LBR _lbr;
    private String _hostName;

    @Override
    public void initialize()
    {
        _lbrController = (Controller) getContext().getControllers().toArray()[0];
        _lbr = (LBR) _lbrController.getDevices().toArray()[0];
        // **********************************************************************
        // *** change next line to the FRIClient's IP address                 ***
        // **********************************************************************
        _hostName = "127.0.0.1";
    }

    @Override
    public void run()
    {
        // configure and start FRI session
        FRIConfiguration friConfiguration = FRIConfiguration.createRemoteConfiguration(_lbr, _hostName);
        friConfiguration.setSendPeriodMilliSec(4);
        FRISession friSession = new FRISession(friConfiguration);
        FRIJointOverlay jointOverlay = new FRIJointOverlay(friSession);

        // wait until FRI session is ready to switch to command mode
        try
        {
            friSession.await(10, TimeUnit.SECONDS);
        }
        catch (final TimeoutException e)
        {

        }

        // move to start pose
        _lbr.move(ptp(Math.toRadians(90), .0, .0, Math.toRadians(90), .0, Math.toRadians(-90), .0));

        // async move with overlay ...
        _lbr.moveAsync(ptp(Math.toRadians(-90), .0, .0, Math.toRadians(90), .0, Math.toRadians(-90), .0)
                .setJointVelocityRel(0.2)
                .addMotionOverlay(jointOverlay)
                .setBlendingRel(0.1)
                );

        // ... blending into sync move with overlay
        _lbr.move(ptp(Math.toRadians(90), .0, .0, Math.toRadians(90), .0, Math.toRadians(-90), .0)
                .setJointVelocityRel(0.2)
                .addMotionOverlay(jointOverlay)
                );

        // done
        friSession.close();
    }

    /**
     * main.
     * 
     * @param args
     *            args
     */
    public static void main(final String[] args)
    {
        final LBRJointSineOverlay app = new LBRJointSineOverlay();
        app.runApplication();
    }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants