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

Yarp RPC simulink block #163

Open
yeshasvitirupachuri opened this issue Oct 4, 2018 · 11 comments
Open

Yarp RPC simulink block #163

yeshasvitirupachuri opened this issue Oct 4, 2018 · 11 comments

Comments

@yeshasvitirupachuri
Copy link
Member

Summary

A simulink block that provided yarp rpc functionality.

Motivation

Currently, for the pHRI standup experiment in simulation I need to set the robot and the human models to be in an initial configuration and then connect their hands through linkattached plugin. It is currently done through rpc from terminal commands. It will be an asset to have this functionality done through simulink directly.

@traversaro
Copy link
Member

How do you imagine this block to work? RPC and dataflow blocks are fundamentally different paradigm, but indeed there are some convenient ways of combining the two.

@yeshasvitirupachuri
Copy link
Member Author

yeshasvitirupachuri commented Oct 4, 2018

@traversaro The block functionality should be such that at the start of the simulation it connects to rpc port of linkattacher plugin and sends commands to connect then hands of both the agents involved in physical interaction.

@traversaro
Copy link
Member

traversaro commented Oct 4, 2018

As the logic of this seems quite hardcoded, perhaps a good strategy is to write your own block in your project containing this logic following the example in https://robotology.github.io/wb-toolbox/mkdocs/create_new_library/ and https://github.com/robotology/wb-toolbox/tree/master/example .

@yeshasvitirupachuri
Copy link
Member Author

@traversaro thank you
Also discussed with @diegoferigo about this and decided to have a simple implementation first.

@diegoferigo
Copy link
Member

@Yeshasvitvs @traversaro Yes as discussed f2f before opening the issue, this RPC functionality can be developed in 2 steps:

  1. A block that does not take any inputs nor outputs. The RPC command will be sent the first loop of the simulation and then the block will become a no-op. From Simulink side, the block will take the following two mask parameters:
    1. The name of the rpc port
    2. The command to send
  2. As an improvement, I would add an input signal (double for simplicity but used as boolean) that contains a trigger. Every rising edge 0 ~> 1 the RPC command will be sent.

We should discuss how to implement a timeout in order to avoid that the simulation get stuck if the remote does not return (since RPC usually is a blocking call). A first idea would be spawning a thread for executing the call and wait that it joins or kill it after the timeout, but this would be the only case we use this approach in the entire toolbox. I'm not sure it is the only one. Any idea @traversaro?

@traversaro
Copy link
Member

Any idea @traversaro?

If we just need this at startup (option 1), for the time being I would play it safe and I would just not return from the first loop of simulation until the RPC has returned, or fail the simulation if the RPC did not returned after a timeout.

If option 2 is instead chosen, indeed blocking in the middle of the simulation may not be an option, especially when there is no explicit time synchronization. The idea of spawning a specific thread seems good.

@diegoferigo
Copy link
Member

cc @VenusPasandi

@traversaro
Copy link
Member

I think we could take inspiration from Simulink's ROS Call Service block https://www.mathworks.com/help/robotics/ref/callservice.html regarding the timing aspects.

@diegoferigo
Copy link
Member

In my opinion this is a simple task for someone that wants to learn how to add a new block (we also have a new tutorial which should cover the entire process). Since it has low priority, I would mark it also as good first issue.

@yeshasvitirupachuri
Copy link
Member Author

I will get to this task soon after HDEv2 and before starting the work with the controller

@diegoferigo
Copy link
Member

Great! You'll be the first tester of the new tutorial 😍

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

3 participants