Accessing collided body information from lasers

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

Accessing collided body information from lasers

Raquel Phillips
Rosen-

In C++ plugin I'm working on I need to get access to the protected vector<int> _databodyids inside of BaseFlashLidar3DSensor. Earlier you had a worked out a way to get the information into Octave but now I need another means of accessing this information. As a quick fix I added the following as a public function in BaseFlashLidar3DSensor as defined in openrave/plugins/basesensors/baseflashlidar3d.h:

virtual vector<int> GetCollidingBodies() { return _databodyids; }

What's the best way to get support for this integrated permananty?

-Raquel
Reply | Threaded
Open this post in threaded view
|

Re: Accessing collided body information from lasers

Rosen Diankov-2
Hi Raquel,

Your fix means that your plugin has to include baseflashlidar3d.h in
order to get the colliding bodies. This will result in a couple of
complications because your plugin is now dependent on the compilation
of the basesensors plugin. Instead, I recommend using
SensorBase::SendCmd to actually transfer the data.

For example, imagine psensor is the sensor you want to get colliding
bodies from. To get information in a safe and interoperable way, a
function might look like:

bool GetCollidingBodies(SensorBase* psensor, vector<int>& collidingbodies)
{
if( !psensor->SupportsCmd("collidingbodies") )
    return false;

stringstream ssdata;
if( !psensor->SendCmd(stringstream("collidingbodies"), ssdata) )
    return false;

// now extract the data from ss
collidingbodies.resize(0);
while(1) {
    int bodyid; ssdata >> bodyid;
    if( !ssdata )
        break;
    collidingbodies.push_back(bodyid);
}
return true;
}


(this code might not compile, but should give you the right idea)

rosen,

2008/8/12 Raquel Phillips <[hidden email]>:

> Rosen-
>
> In C++ plugin I'm working on I need to get access to the protected
> vector<int> _databodyids inside of BaseFlashLidar3DSensor. Earlier you had a
> worked out a way to get the information into Octave but now I need another
> means of accessing this information. As a quick fix I added the following as
> a public function in BaseFlashLidar3DSensor as defined in
> openrave/plugins/basesensors/baseflashlidar3d.h:
>
> virtual vector<int> GetCollidingBodies() { return _databodyids; }
>
> What's the best way to get support for this integrated permananty?
>
> -Raquel
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Openrave-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openrave-users
>
>