Skip to content

Instantly share code, notes, and snippets.

@Daiver
Created January 31, 2013 20:30
Show Gist options
  • Save Daiver/4686170 to your computer and use it in GitHub Desktop.
Save Daiver/4686170 to your computer and use it in GitHub Desktop.
typedef boost::interprocess::allocator<float, boost::interprocess::managed_shared_memory::segment_manager> ShmemAllocator;
typedef boost::interprocess::vector<float, ShmemAllocator> DataVector;
DataVector *myvector;
void init_myvector()
{
struct shm_remove
{
shm_remove() { boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
~shm_remove(){ boost::interprocess::shared_memory_object::remove("MySharedMemory"); }
} remover;
boost::interprocess::managed_shared_memory segment(boost::interprocess::create_only, "MySharedMemory", 65536);
const ShmemAllocator alloc_inst (segment.get_segment_manager());
myvector = segment.construct<DataVector>("MyVector")(alloc_inst);
for(int i = 0; i < 6; ++i) { //Insert data in the vector
myvector->push_back(0);
}
}
void dump_points(vector<vector<GlPoint3f> > *glpoint_vec, Views *views, SE3 T_pos)
{
Vector3d pos = T_pos.translation();
for(int i = 0; i < 3; ++i) { //Insert data in the vector
myvector->at(i) = pos[i];
printf("%d %f ", i, myvector->at(i));
}
printf("\n");
pos = T_pos.so3().log();
for(int i = 0; i < 3; ++i) { //Insert data in the vector
myvector->at(i) = pos[i];
}
//sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment