Looking for a way to set 2 modes of operation in a single non threaded script

Typically: "How do I... ", "How can I... " questions
Post Reply
Quartz
Posts: 7
Joined: 08 Jan 2018, 19:31

Looking for a way to set 2 modes of operation in a single non threaded script

Post by Quartz » 11 Jun 2018, 19:51

Hello Everyone.

What I'm trying to do is a way to have 2 modes of kinematics (forward and inverse kinematics) in a single non-threaded script. So when the user starts the simulation, he has to choose between forward or inverse, maybe creating a UI , or being more simplistic, something like cin/scanf to receive a variable, after that I could use an If situation, for example if x=1 go forward, if x=0, go inverse. then the script can run normally, without any interruption, unless the user stops the simulation. So I think it has to be done on initialization part of the script

Is that possible?

PS: I'm using v-rep 3.3.2

Thanks in advance

Luiz Arthur (Quartz)
Last edited by Quartz on 12 Jun 2018, 21:03, edited 1 time in total.

coppelia
Site Admin
Posts: 6625
Joined: 14 Dec 2012, 00:25

Re: Looking for a way to set 2 modes of operation in a single non threaded script

Post by coppelia » 12 Jun 2018, 11:55

Hello,

not sure what the question relates exactly to... is it about how to have IK and FK set-up at the same time and switching from one to another, and/or is it about a way to interact with the user? I will assume the latter one.

For interaction with the user, use custom UIs. You can also use custom UIs in modal mode when running from a non-threaded child script. Simulation will however start to run already. If you want to wait until the user has made a decision in order to make the simulation advance, then you should use V-REP 3.5.0, revision 4 (or later): there, you can use a customization script that will open a modal dialog in callback function sysCall_beforeSimulation. Then, as long as the user has not made a decision (i.e. the modal custom UI is still open), hinder the main script from running by using following callback function:

Code: Select all

function sysCall_beforeMainScript()
    -- Can be used to step a simulation in a custom manner.
    local outData={doNotRunMainScript=false} -- when true, then the main script won't be executed
    return outData
end
You can run all the code you used to have in your non-threaded child script also inside of your customization script. Or you can have the customization script just in charge for the custom UI, and transmit the user input to the non-threaded child script via sim.setScriptVariable for instance.

Cheers

Quartz
Posts: 7
Joined: 08 Jan 2018, 19:31

Re: Looking for a way to set 2 modes of operation in a single non threaded script

Post by Quartz » 12 Jun 2018, 21:02

Thanks for fast reply.

You have assumed right. I'm looking a way to interact with the user which kinematics he wants to run his simulation (FK or IK).

I Tried to use Vrep 3.4 version rev 17 on my ros indigo version. But it didn't work. Because of that I'm currently using 3.3.2 version with vrep_ros_interface. So I think changing version could be problematic at this rate.

I'm trying to use the OpenGL based UI, since it's deprecated I can't get much information about types of button. Although I used a Checkable button (when it's on up state, runs forward kinematics, after I click on it, it become on down state, and it's suppose to run Inverse kinematics). I imagine it's a 0 or 1 scenario. So I created these lines of code on Initialization part of the script

Code: Select all

    ui=simGetUIHandle('UI')
    ik=simGetIkGroupHandle('ik')    
    a=simGetUIEventButton(ui)
    if(a==1) then
    inverse=true
    else
    inverse=false
    end
But even doing this I didn't get what I expected. Maybe because it turns 0 to 1 only after the simulation starts. Or because I'm doing something wrong.

PS: I decided for OpenGL based UI because I'm only using a single checkable button. And it's implemented already on Vrep, I don't need to download anything else to run it

PS2: Maybe I should try simGetUIButtonLabel instead of UIEventButton, but i don't know how it works

coppelia
Site Admin
Posts: 6625
Joined: 14 Dec 2012, 00:25

Re: Looking for a way to set 2 modes of operation in a single non threaded script

Post by coppelia » 13 Jun 2018, 14:26

I highly recommend to switch now to the latest V-REP version, otherwise you will run into more trouble later on.

Cheers

Quartz
Posts: 7
Joined: 08 Jan 2018, 19:31

Re: Looking for a way to set 2 modes of operation in a single non threaded script

Post by Quartz » 13 Jun 2018, 18:11

Hello again.

I tried to use the new version of vrep. But I'm getting a problem when I try to open it.

" relocation error: /home/lro/V-REP_PRO_EDU_V3_5_0_Linux/vrep: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference"

Is that happened because I'm using ubuntu 14.04? Or can it be fixed? Because I tried to update my libs on apt-get update, it did change something, but the error persists. If the first case is the answer I really have a problem, since i can't change de version of linux because other lab colleagues needs to use Ros Indigo version for their works.

coppelia
Site Admin
Posts: 6625
Joined: 14 Dec 2012, 00:25

Re: Looking for a way to set 2 modes of operation in a single non threaded script

Post by coppelia » 15 Jun 2018, 15:20

Yes, that is the problem. Can't you use ROS indigo on Ubuntu 16.04?

Cheers

Post Reply