From: Mark M. <mar...@gm...> - 2013-07-12 19:52:12
|
You are missing a cast: base::CompoundStateSpace::StateType* cstate = state->as<base::CompoundStateSpace::StateType>(); // first subspace cstate->as<base::RealVectorStateSpace::StateType>(0)->values[0] = 0.1; // second subspace cstate->as<base::RealVectorStateSpace::StateType>(1)->values[0] = 0.1; Since all the state components are double values, you could also use the following approach to avoid the casts: base::ScopedState scopedState(space); // first component of first subspace scopedState[0] = .1; // first component of second subspace scopedState[2] = .1; See http://ompl.kavrakilab.org/classompl_1_1base_1_1ScopedState.html. On Jul 12, 2013, at 12:40 PM, Sören Jentzsch <jen...@in...> wrote: > Hello OMPL-Users, > > I need to define a CompoundStateSpace with several StateSpaces but can't > read/write certain subspaces appropriately. As an easy example take the > following code: > base::StateSpacePtr spaceRobot(new base::RealVectorStateSpace(2)); > base::StateSpacePtr spaceObject1(new base::RealVectorStateSpace(2)); > base::StateSpacePtr space = spaceRobot + spaceObject1; > base::State* state = space->allocState(); > For me the following questions came up: > > 1) How can I access both of the subspaces and define each values? > "state->as<base::RealVectorStateSpace::StateType>()->values[0] = 0.1"? > But how do I access the second subspace? The function "as" won't take > any arguments. > > 2) As soon as I write something like > "state->as<base::RealVectorStateSpace::StateType>()->values[0] = 0.1;" I > can't print the state anymore. How did I corrupt the CompoundState? How > can I then access the data or use the StateSpaces to print certain > subspaces? > > I spend some hours dealing with these issues, also I did not find any > helpful documentation online, so I consulted this mailing list. Thanks > in advance for your help and keep up this good work! > > Greetings from Munich > Sören Jentzsch > > ------------------------------------------------------------------------------ > See everything from the browser to the database with AppDynamics > Get end-to-end visibility with application monitoring from AppDynamics > Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > _______________________________________________ > ompl-users mailing list > omp...@li... > https://lists.sourceforge.net/lists/listinfo/ompl-users > -- Mark Moll |