-
Notifications
You must be signed in to change notification settings - Fork 3
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
This PR adds an example of geting the inertial parameters of a cuboid on CoppeliaSim #10
base: master
Are you sure you want to change the base?
Conversation
…verseController() to perform a pose control of a FrankaEmikaPandaRobot().
…CommandServer.lua' script and removed the CoppeliaSim scene that shouldn't be here.
…lva/matlab-examples into dq-get-inertial-parameters
Hi @juanjqo, I modified the Lua API to behave the same as the one you implemented for your C++ examples, while still allowing for arbitrary reference frames. Since the Lua script is somewhat of an add-on to the library, I believe having a slightly different version in some examples is not a problem. Kind regards, |
@ffasilva thank you for your example. I recommend using try-catch blocks to finish the connection automatically if an execution error happens, especially when using the legacy remote API. Otherwise, the connection port remains open, and the user must close it manually or restart Matlab. Layout example: clear all;
close all;
clc;
include_namespace_dq;
vi = DQ_VrepInterface();
try
vi.connect('127.0.0.1', 19997);
vi.start_simulation();
%-----------Your code here-------------------
%----------------------------------------------
vi.stop_simulation();
vi.disconnect();
catch ME
vi.stop_simulation();
vi.disconnect();
rethrow(ME)
end On the other hand, it looks like there is some bug when using BODY_FRAME arguments. Minimal example: clear all;
close all;
clc;
include_namespace_dq;
vi = DQ_VrepInterface();
try
vi.connect('127.0.0.1', 19997);
vi.start_simulation();
% Get the Cuboid's handle
handle = vi.get_handle('Cuboid');
% Get the Cuboid's inertia matrix
inertia_matrix_in_sf = vi.get_inertia_matrix(handle, vi.BODY_FRAME);
disp('inertia matrix =')
disp(inertia_matrix_in_sf)
vi.stop_simulation();
vi.disconnect();
catch ME
vi.stop_simulation();
vi.disconnect();
rethrow(ME)
end Output: Arrays have incompatible sizes for this operation.
Error in DQ_VrepInterface/get_inertia_matrix (line 903)
if(reference_frame == obj.ABSOLUTE_FRAME)
Error in untitled2 (line 18)
inertia_matrix_in_sf = vi.get_inertia_matrix(handle,
vi.BODY_FRAME);
Related documentation Please let me know if you can reproduce the issue. Best regards, Juancho |
Hi @juanjqo
I didn't add a try-catch block because I'm already checking for any previous connection that wasn't properly closed (e.g., due to an execution error). %% V-REP setup
% Create a DQ_VrepInterface object and start communication with V-REP
vi = DQ_VrepInterface();
% Finish any previous V-REP communication
vi.stop_simulation();
vi.disconnect_all();
% Start a new connection
vi.connect('127.0.0.1',19997);
disp('Communication established!')
Thanks for pointing that out. I fixed it in d29125d. Feel free to let me know if you have any more suggestions. Kind regards, |
Thank you @ffasilva It looks like everything is running well. My main concern is the duplication of the DQRoboticsApiCommandServer.lua, which is currently available in dqrobotics/cpp-examples. I think is impractical in terms of maintenance and support to have duplicate files. I recommend removing the one you are proposing here and using the one that is already in the DQ robotics. Best regards, Juancho |
Hi @juanjqo, If we're only going to keep one file, I would suggest doing it the other way around and keeping this version of Kind regards, |
Hi @ffasilva, I think the modifications you are proposing in Cheers, Juancho |
…ommandServer.lua'. It will be added in a different pull request to 'dqrobotics/cpp-examples'.
Hi @juanjqo, This makes sense. I've removed the Kind regards, |
Hi, @dqrobotics/developers,
This PR adds an example of geting the inertial parameters of a cuboid on CoppeliaSim. The motivation is to test the new methods added to
DQ_VrepInterface
in 109.The LUA child script on the scene
cuboid_inertial_parameters.ttt
diverges from the one used in the C++ examples. As they were, functionsget_center_of_mass()
andget_inertia()
only returned the parameters with respect to either the shape frame or the inertial reference frame through anif-else
check "is(reference frame == 'absolute_frame')
". To allow arbitrary reference frames, the LUA functionsim.getObjectMatrix
needs to receive a handle (i.e., anint
), which required the modifications. Namely, the reference frame is now passed as aninInts
rather than aninStrings
. I also removed unused arguments, renamed some variables, and added comments to make the functions clearer.Kind regards,
Frederico
P.S.: As described in the .m file, the necessary scene is available in OSF.