qtcoin viewer with LoadIKFastSolver in C++

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

qtcoin viewer with LoadIKFastSolver in C++

mattis
Hi all,

I'm having a hard time using ikfast problem together with a viewer, i.e.
qtcoin. I'd like to do something similar as the hanoitowers example, but
in c++. First, I open a GUI as in orloadviewer.cpp and then I'm trying
to load ikfastproblem for my robot. However, I'm obviously doing
something wrong here - since the GUI blocks the ik from loading. If I do
things in reverse order, the GUI doesn't show up at all.

Am I missing something small here, I'd suppose that this has something
to do with threads? Or am I using completely wrong method? Could I
somehow get completely rid of the call to python script? I'm attaching a
snippet describing my problem.

I have to say that this userlist has been an excellent source of
information. However, I wasn't able to find any problem similar to mine.

Best regards,
Mathias von Essen
---------------------------
#include <openrave-core.h>
#include <vector>
#include <cstring>
#include <sstream>
#include <stdio.h>

#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/format.hpp>

using namespace OpenRAVE;
using namespace std;

void SetViewer(EnvironmentBasePtr penv, const string& viewername)
{
    ViewerBasePtr viewer = penv->CreateViewer(viewername);
    penv->AttachViewer(viewer);
    viewer->main(true);
}

int main()
{
    string scenefilename = "smaract.env.xml";
    string viewername = "qtcoin";
   
    EnvironmentBasePtr penv = CreateEnvironment(true);
    penv->SetDebugLevel(Level_Debug);
    boost::thread thviewer(boost::bind(SetViewer,penv,viewername)); //
create the viewer
    usleep(300000); // wait for the viewer to init
   
    if( !penv->Load(scenefilename) ) {
        penv->Destroy();
        return 2;
    }
   
    vector<RobotBasePtr> vrobots;
    penv->GetRobots(vrobots);
    RobotBasePtr probot = vrobots.at(0);
   
    EnvironmentMutex::scoped_lock lock(penv->GetMutex()); // lock
environment
       
    stringstream ssin,ssout;
    ssin << "LoadIKFastSolver " << probot->GetName() << " " <<
(int)IkParameterization::Type_Translation3D;

probot->SetActiveManipulator(probot->GetManipulators().at(0)->GetName());
   
    ProblemInstancePtr pikfast = penv->CreateProblem("ikfast");
    penv->LoadProblem(pikfast,"SmarActMockup");
   
   
    if( !pikfast->SendCommand(ssout,ssin) ) {
      RAVELOG_ERROR("failed to load iksolver\n");
      penv->Destroy();
      return 1;
    }
   
    thviewer.join(); // wait for the viewer thread to exit
    penv->Destroy(); // destroy
    return 0;
}



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: qtcoin viewer with LoadIKFastSolver in C++

Rosen Diankov
Administrator
hi matthias,

Your code is just fine. Just wait 4-8 minutes, the ik solver is
generating the solution. You should have get a message like:

[ikfastproblem.h:363] Generating inverse kinematics for manip ...

This is a one time process that only occurs when you start using a new
robot in openrave.

rosen,

2010/9/17 Mathias von Essen <[hidden email]>:

> Hi all,
>
> I'm having a hard time using ikfast problem together with a viewer, i.e.
> qtcoin. I'd like to do something similar as the hanoitowers example, but
> in c++. First, I open a GUI as in orloadviewer.cpp and then I'm trying
> to load ikfastproblem for my robot. However, I'm obviously doing
> something wrong here - since the GUI blocks the ik from loading. If I do
> things in reverse order, the GUI doesn't show up at all.
>
> Am I missing something small here, I'd suppose that this has something
> to do with threads? Or am I using completely wrong method? Could I
> somehow get completely rid of the call to python script? I'm attaching a
> snippet describing my problem.
>
> I have to say that this userlist has been an excellent source of
> information. However, I wasn't able to find any problem similar to mine.
>
> Best regards,
> Mathias von Essen
> ---------------------------
> #include <openrave-core.h>
> #include <vector>
> #include <cstring>
> #include <sstream>
> #include <stdio.h>
>
> #include <boost/iostreams/device/file_descriptor.hpp>
> #include <boost/iostreams/stream.hpp>
> #include <boost/format.hpp>
>
> using namespace OpenRAVE;
> using namespace std;
>
> void SetViewer(EnvironmentBasePtr penv, const string& viewername)
> {
>    ViewerBasePtr viewer = penv->CreateViewer(viewername);
>    penv->AttachViewer(viewer);
>    viewer->main(true);
> }
>
> int main()
> {
>    string scenefilename = "smaract.env.xml";
>    string viewername = "qtcoin";
>
>    EnvironmentBasePtr penv = CreateEnvironment(true);
>    penv->SetDebugLevel(Level_Debug);
>    boost::thread thviewer(boost::bind(SetViewer,penv,viewername)); //
> create the viewer
>    usleep(300000); // wait for the viewer to init
>
>    if( !penv->Load(scenefilename) ) {
>        penv->Destroy();
>        return 2;
>    }
>
>    vector<RobotBasePtr> vrobots;
>    penv->GetRobots(vrobots);
>    RobotBasePtr probot = vrobots.at(0);
>
>    EnvironmentMutex::scoped_lock lock(penv->GetMutex()); // lock
> environment
>
>    stringstream ssin,ssout;
>    ssin << "LoadIKFastSolver " << probot->GetName() << " " <<
> (int)IkParameterization::Type_Translation3D;
>
> probot->SetActiveManipulator(probot->GetManipulators().at(0)->GetName());
>
>    ProblemInstancePtr pikfast = penv->CreateProblem("ikfast");
>    penv->LoadProblem(pikfast,"SmarActMockup");
>
>
>    if( !pikfast->SendCommand(ssout,ssin) ) {
>      RAVELOG_ERROR("failed to load iksolver\n");
>      penv->Destroy();
>      return 1;
>    }
>
>    thviewer.join(); // wait for the viewer thread to exit
>    penv->Destroy(); // destroy
>    return 0;
> }
>
>
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Openrave-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openrave-users
>

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: Another OpenRAVE question on robot workspace

Rosen Diankov
Administrator
In reply to this post by mattis
hi ken,

The simplest way is to sample the entire workspace, and check if the
robot has a collision-free configuration to get it there.
Unfortunately, depending on your discretizations, this is very
computationally heavy.

Once you have all the valid points, you can use the plot/drawtrimesh
functions of Environment to render the freespace inside the openrave
environment

rosen,

2010/9/18 Yue Peng Toh <[hidden email]>:

> Hi Rosen,
>
> Given a robot, what would be the best way to compute and visualize the
> workspace of the robot (in free space, let's say)? I know this should be
> rather straightforward, but do you propose a recommended way? Which
> Knowledge-based generators should I use (kinematic reachability?) or/and
> is there a way to see the workspace visualization in MATLAB or something?
> Pardon me if the question sounds silly!
>
> Thanks,
> Ken
>
>

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users