[Rock-dev] Envire environment zum Versenden vereinfachen

Jakob Schwendner jakob.schwendner at dfki.de
Mon Dec 17 20:58:12 CET 2012



On December 17, 2012 at 8:25 PM Stefan Haase <stefan.haase at dfki.de> wrote:

>  Hi Jakob.
> 
>  I did like you told or at least as I think you told (see below) and it seems
> to work (no Pointcloud in my visualization-module anymore), but on the second
> look I realize that it didn't do anything (see a little bit more below).
>  Btw.: event.a.get() is an EnvironmentItem and Pointcloud is an
> EnvironmentItem.. so dont we actually perform an downcast here?
> 

Yes... did I say upcast? my bad.

> 
>  The filter:
>      /**
>       * Event filter to exclude the pointcloud from serialization.
>       */
>      class EventFilterExcludePointcloud : public envire::EventFilter {
>       public:
>          bool filter(envire::Event const& event) {
>              try {
>                  envire::Pointcloud* pointcloud =
> dynamic_cast<envire::Pointcloud*>(event.a.get());
>                  if(pointcloud != NULL) {
>                      LOG_INFO("Removes event %s", event.id_a.c_str());
>                      return false;
>                  }
>              } catch (std::exception& e) {
>                  LOG_ERROR("Exception using EventFilterExcludePointcloud: %s",
> e.what());
>                  return false;
>              }
>              return true;
>          }
>      };
> 

Don't think you need to catch here. dynamic_cast of pointers doesn't throw afak.
Looks good otherwise.

> 
>  Add it to the emitter:
>      mEmitter = new envire::OrocosEmitter(_envire_environment_out);
>      mEmitter->setFilter(&mFilterPointcloud);
>      mEmitter->useContextUpdates(&mEnv);
>      mEmitter->useEventQueue( true );
>      mEmitter->attach(&mEnv);
> 
> 

seems reasonable.

> 
>  Actually this removes the pointcloud (or at least I do not see it anymore):
> 
>  With pointcloud:
> 
>  update hook:
>          envire::OrocosEmitter emitter(&mEnv, _envire_environment_out);
>          emitter.setTime(base::Time::now());
>          emitter.flush();
> 
> 

This will flush the entire environment everytime the update hook is called. Not
likely what you want.

> 
>  Without pointcloud:
> 
>  configureHook:
>      mEmitter = new envire::OrocosEmitter(_envire_environment_out);
>      mEmitter->useContextUpdates(&mEnv);
>      mEmitter->attach(&mEnv);
> 
>  updateHook:
>      mEmitter->setTime(base::Time::now());
>      mEmitter->flush();
> 
>  Irritated greetings,
> 

Irritation received... Is there a question here? If you leave out whatever you
have in the "with pointcloud" paragraph, all seems to be good :)

Jakob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.dfki.de/pipermail/rock-dev/attachments/20121217/2029c997/attachment-0001.htm 


More information about the Rock-dev mailing list