virtual void SetUp()
    {
        const size_t usableBlocksPerPage = (pageSize / blockSize) - 1;
        const size_t availablePages = maxSize / pageSize;
        allocations = availablePages * usableBlocksPerPage;

        allocator.reset(new SmallObjectAllocator(PageManager::create(maxSize, pageSize), blockSize));
    }
Example #2
0
	static
	Recorder* GetInstance() 
	{
		if (!instance) 
		{
			instance.reset(new RASP24Recorder);
    	}
		return instance.get();
	}
	void objectAdded(Object* object)
	{
		if (currentStepObject) {
			return;
		}

		currentStepObject.reset(object->clone());
		currentStepRecorded = false;
	}
Example #4
0
 void load(
     Archive & ar, 
     boost::scoped_ptr< T > & t, 
     const unsigned int /* version */
 ){
     T* r;
     ar >> boost::serialization::make_nvp("scoped_ptr", r);
     t.reset(r); 
 }
Example #5
0
 bool set_disabled(SetDisabledRequest &request, SetDisabledResponse &response)
 {
   disabled = request.disabled;
   if (disabled)
   {
     c3trajectory.reset();
   }
   return true;
 }
	/** component start method, starts thread */
	virtual void start()
	{
		if ( !m_running )
		{
			m_bStop = false;
			m_running = true;
			m_pThread.reset( new boost::thread( boost::bind( &KeyboardEvent::mainLoop, this ) ) );
		}
	}
Example #7
0
TranslatorRoster*
TranslatorRoster::default_roster()
{
	static boost::scoped_ptr<TranslatorRoster> roster;
	if(! roster)
		roster.reset(new TranslatorRoster);

	return roster.get();
}
Example #8
0
static void cleanup(void)
{
    mgr   = NULL;
    staticScene = NULL;
    dynamicScene = NULL;
    win   = NULL;
    dynamicVp = NULL;
    spSimpleFBO.reset();
}
Example #9
0
 virtual void handle_stop()
 {
     if (acceptor_ && acceptor_->is_open())
     {
         acceptor_->close();
         std::cout << "Server stopped" << std::endl;
     }
     acceptor_.reset();
 }
Example #10
0
static void cleanup(void)
{
    mgr   = nullptr;
    staticScene = nullptr;
    dynamicScene = nullptr;
    win   = nullptr;
    dynamicVp = nullptr;
    spSimpleFBO.reset();
}
Example #11
0
	CTextInputWindow()
		: FK2DEngine::CFKWindow( 300, 200, false )
	{
		SetCaption( L"自由骑士笃志引擎:字符输入测试" );
		SetBackgroudColor( FK2DEngine::CColor::YELLOW );
		// 设置字体
		m_pFont.reset( new FK2DEngine::CFont( Graphics(), L"Sans MT 936_S60", 20 ) );

		for( unsigned int nIndex = 0; nIndex < LengthOf( m_pTextFields ); ++nIndex )
		{
			m_pTextFields[nIndex].reset( new CTextField( *this, *m_pFont, 50, 30 + nIndex * 50 ) );
		}
		// 开动计时器
		m_Timer.Play();
		// 隐藏真实鼠标,自定虚拟鼠标
		::ShowCursor( FALSE );
		// 设置自己鼠标图片
		m_pCursor.reset( new FK2DEngine::CImage( Graphics(), FK2DEngine::ShareResourcePrefix() + L"rc/media/Cursor.png", false ) );
	}
Example #12
0
	/*! @brief configure the detector state
	 *
	 * The configure method is called once when the ECTO cell is launched,
	 * and is designed to initialise the detector state and load models,
	 * parameters, etc.
	 *
	 * @param params the parameters made available through the config file and
	 * python bindings
	 * @param inputs for initializing inputs, if necessary
	 * @param outputs for initializing outputs, if necessary
	 */
	void configure(const tendrils& params, const tendrils& inputs,
			const tendrils& outputs)
	{

		std::cout << "MODEL: " << *model_file_ << std::endl;
		// create the model object and deserialize it
		FileStorageModel model;
		model.deserialize(*model_file_);

		// create the visualizer
		visualizer_.reset(new Visualize(model.name()));

		// create the PartsBasedDetector and distribute the model parameters
		detector_.reset(new PartsBasedDetector<double>);
		detector_->distributeModel(model);

		// set the model_name
		model_name_ = model.name();
	}
Example #13
0
  MainClass(int argc, const char *argv[])
      :argv_(argv)
  {
    rg_.reset(new RegistryPO(argc,argv));
    util::initLogger ( argc, argv );
    FORCELINFO ( argv[0] << " starts!" );
    FORCELINFO ( rg_->dump ( "CONFIG parameters:\n====================="
                             , "=====================" ) );

  }
void InputEventsWestonTest::SetUp()
{
  WestonTest::SetUp();
  
  clientLibrary.Load();
  eglLibrary.Load();
  xkbCommonLibrary.Load();
  
  xkbContext.reset(CXKBKeymap::CreateXKBContext(xkbCommonLibrary),
                   boost::bind(&IDllXKBCommon::xkb_context_unref,
                               &xkbCommonLibrary, _1));
  keymap.reset(new CXKBKeymap(
                 xkbCommonLibrary, 
                 CXKBKeymap::CreateXKBKeymapFromNames(xkbCommonLibrary,
                                                      xkbContext.get(),
                                                      "evdev",
                                                      "pc105",
                                                      "us",
                                                      "",
                                                      "")));
  
  display.reset(new xw::Display(clientLibrary));
  queue.reset(CreateEventQueue());
  registry.reset(new xw::Registry(clientLibrary,
                                  display->GetWlDisplay(),
                                  *this));
  loop.reset(new xwe::Loop(listener, *queue));

  /* Wait for the seat, shell, compositor to appear */
  WaitForSynchronize();
  
  ASSERT_TRUE(input.get() != NULL);
  ASSERT_TRUE(compositor.get() != NULL);
  ASSERT_TRUE(shell.get() != NULL);
  ASSERT_TRUE(xbmcWayland.get() != NULL);
  
  /* Wait for input devices to appear etc */
  WaitForSynchronize();
  
  surface.reset(new xw::Surface(clientLibrary,
                                compositor->CreateSurface()));
  shellSurface.reset(new xw::ShellSurface(clientLibrary,
                                          shell->CreateShellSurface(
                                            surface->GetWlSurface())));
  openGLSurface.reset(new xw::OpenGLSurface(eglLibrary,
                                            surface->GetWlSurface(),
                                            SurfaceWidth,
                                            SurfaceHeight));

  wl_shell_surface_set_toplevel(shellSurface->GetWlShellSurface());
  surface->Commit();
}
void InputEventsWestonTest::WaitForSynchronize()
{
  synchronized = false;
  syncCallback.reset(new xw::Callback(clientLibrary,
                                      display->Sync(),
                                      boost::bind(&InputEventsWestonTest::Synchronize,
                                                  this)));
  
  while (!synchronized)
    loop->Dispatch();
}
Example #16
0
void CameraV4LPublisher::open()
{
  locateCameraNode();

  if ( _node == -1 )
    throw std::runtime_error("Error in CameraV4LPublisher::open(): device not found");

  ROS_INFO_STREAM("Creating cv::VideoCapture in node " << _node);
  _capture.reset( new cv::VideoCapture(_node) );

  ROS_INFO_STREAM("Setting image width to " << _imageSize.width << " pixels");
  _capture->set(CV_CAP_PROP_FRAME_WIDTH,  _imageSize.width);
  ROS_INFO_STREAM("Setting image height to " << _imageSize.height << " pixels");
  _capture->set(CV_CAP_PROP_FRAME_HEIGHT, _imageSize.height);

  //set up ROS publisher
  _imageTransport.reset( new image_transport::ImageTransport(_nh) );
  _cameraPublisher.reset( new image_transport::CameraPublisher(
                            _imageTransport->advertiseCamera(_nh.getNamespace()+"/image", 1)) );
}
 Connection(const std::string &connection_str, const std::string ns)
     : ns_(ns), closed_(false) {
     try {
         conn_.reset(mongo::ScopedDbConnection::getScopedDbConnection(connection_str));
     } catch (mongo::DBException &de) {
         std::string err_msg = "Mongodb Plugin: ";
         err_msg += de.toString();
         err_msg += "\n";
         throw mapnik::datasource_exception(err_msg);
     }
 }
Example #18
0
    /** gets a scoped_block given a key, or leaves empty
     ** if the key is not found */
    void get(boost::scoped_ptr< variable_store::scoped_block > & p,
             const Key & key)
    {
        boost::mutex::scoped_lock lock(m_mutex);
        // if key is found, loads index into the scoped block
        typename hm_key_location::const_iterator it = m_key_location.find(key);

        if (it == m_key_location.end())
            return;

        p.reset( new variable_store::scoped_block(m_variable_store, it->second.block_size, it->second.index) );
    }
Example #19
0
File: node.cpp Project: ErolB/Sub8
  void timer_callback(const ros::TimerEvent &) {
    if (!c3trajectory) return;

    ros::Time now = ros::Time::now();

    if (actionserver.isPreemptRequested()) {
      current_waypoint = c3trajectory->getCurrentPoint();
      current_waypoint.r.qdot = subjugator::Vector6d::Zero();  // zero velocities
      current_waypoint_t = now;

      // don't try to make output c3 continuous when cancelled - instead stop as quickly as possible
      c3trajectory.reset(new subjugator::C3Trajectory(current_waypoint.r, limits));
      c3trajectory_t = now;
    }

    if (actionserver.isNewGoalAvailable()) {
      boost::shared_ptr<const uf_common::MoveToGoal> goal = actionserver.acceptNewGoal();
      current_waypoint = subjugator::C3Trajectory::Waypoint(
          Point_from_PoseTwist(goal->posetwist.pose, goal->posetwist.twist), goal->speed,
          !goal->uncoordinated);
      current_waypoint_t = now;  // goal->header.stamp;
      this->linear_tolerance = goal->linear_tolerance;
      this->angular_tolerance = goal->angular_tolerance;
      c3trajectory_t = now;
    }

    while ((c3trajectory_t + traj_dt < now) and ros::ok()) {
      // ROS_INFO("Acting");

      c3trajectory->update(traj_dt.toSec(), current_waypoint,
                           (c3trajectory_t - current_waypoint_t).toSec());
      c3trajectory_t += traj_dt;
    }

    PoseTwistStamped msg;
    msg.header.stamp = c3trajectory_t;
    msg.header.frame_id = fixed_frame;
    msg.posetwist = PoseTwist_from_PointWithAcceleration(c3trajectory->getCurrentPoint());
    trajectory_pub.publish(msg);

    PoseStamped posemsg;
    posemsg.header.stamp = c3trajectory_t;
    posemsg.header.frame_id = fixed_frame;
    posemsg.pose = Pose_from_Waypoint(current_waypoint);
    waypoint_pose_pub.publish(posemsg);

    if (actionserver.isActive() &&
        c3trajectory->getCurrentPoint().is_approximately(
            current_waypoint.r, max(1e-3, linear_tolerance), max(1e-3, angular_tolerance)) &&
        current_waypoint.r.qdot == subjugator::Vector6d::Zero()) {
      actionserver.setSucceeded();
    }
  }
Example #20
0
	virtual bool next() {
		if (!nested_current)
			return false;

		while (!nested_current->next()) {
			nested_current.reset();

			++current;
			if (current == end) {
				// no more items
				nested_current.reset();
				valid = false;
				return false;
			}

			nested_current.reset((*current)->lines());
		}

		valid = true;
		return true;
	}
Example #21
0
		void complete (const value_type& value)
		{
			boost::lock_guard<boost::mutex> lock(mutex);
			if (finished)
				return;
			finished = true;
			if (!started) {
				value_ptr.reset(new value_type(value));
			} else if (completed_handler) {
				completed_handler(value);
			}
		}
Example #22
0
bool Model::initString(const std::string& xml_string)
{
  boost::shared_ptr<ModelInterface> model;

  // necessary for COLLADA compatibility
  if( IsColladaData(xml_string) ) {
    ROS_DEBUG("Parsing robot collada xml string");

    static boost::mutex PARSER_PLUGIN_LOCK;
    static boost::scoped_ptr<pluginlib::ClassLoader<urdf::URDFParser> > PARSER_PLUGIN_LOADER;
    boost::mutex::scoped_lock _(PARSER_PLUGIN_LOCK);

    try
    {
      if (!PARSER_PLUGIN_LOADER)
	PARSER_PLUGIN_LOADER.reset(new pluginlib::ClassLoader<urdf::URDFParser>("urdf_parser_plugin", "urdf::URDFParser"));
      const std::vector<std::string> &classes = PARSER_PLUGIN_LOADER->getDeclaredClasses();
      bool found = false;
      for (std::size_t i = 0 ; i < classes.size() ; ++i)
	if (classes[i].find("urdf/ColladaURDFParser") != std::string::npos)
	{
	  boost::shared_ptr<urdf::URDFParser> instance = PARSER_PLUGIN_LOADER->createInstance(classes[i]);
	  if (instance)
	    model = instance->parse(xml_string);
	  found = true;
	  break;
	}
      if (!found)
	ROS_ERROR_STREAM("No URDF parser plugin found for Collada files. Did you install the corresponding package?");
    }
    catch(pluginlib::PluginlibException& ex)
    {
      ROS_ERROR_STREAM("Exception while creating planning plugin loader " << ex.what() << ". Will not parse Collada file.");
    }
  }
  else {
    ROS_DEBUG("Parsing robot urdf xml string");
    model = parseURDF(xml_string);
  }

  // copy data from model into this object
  if (model){
    this->links_ = model->links_;
    this->joints_ = model->joints_;
    this->materials_ = model->materials_;
    this->name_ = model->name_;
    this->root_link_ = model->root_link_;
    return true;
  }
  else
    return false;
}
Example #23
0
void testCaseSetup_1() {
  ooe.reset(new OneOfEach);
  ooe->im_true = true;
  ooe->im_false = false;
  ooe->a_bite = 0x7f;
  ooe->integer16 = 27000;
  ooe->integer32 = 1 << 24;
  ooe->integer64 = (uint64_t)6000 * 1000 * 1000;
  ooe->double_precision = M_PI;
  ooe->some_characters = "JSON THIS! \"\1";
  ooe->zomg_unicode = "\xd7\n\a\t";
  ooe->base64 = "\1\2\3\255";
}
Example #24
0
    /** allocs a scoped_block for a new key
     ** doesn't support reallocing on an existing key, maybe in the future */
    void alloc(boost::scoped_ptr< variable_store::scoped_block > & p,
               const Key & key,
               size_t block_size)
    {
        boost::mutex::scoped_lock lock(m_mutex);
        // don't support reallocing for now
        typename hm_key_location::const_iterator it = m_key_location.find(key);

        if (it != m_key_location.end())
            throw std::invalid_argument("realloc not supported");

        p.reset( new variable_store::scoped_block(m_variable_store, block_size) );
        m_key_location[key] = location(p->block_size(), p->index());
    }
Example #25
0
    virtual void handle_start()
    {
        tcp::resolver resolver(main_pool().io_service());
        tcp::endpoint endpoint = *resolver.resolve(addr_query_);

        acceptor_.reset(new tcp::acceptor(main_pool().io_service()));
        acceptor_->open(endpoint.protocol());
        acceptor_->set_option(tcp::acceptor::reuse_address(true));
        acceptor_->bind(endpoint);
        acceptor_->listen();
        start_accept();

        std::cout << "Server started" << std::endl;
    }
Example #26
0
		~FiberControl(){
			AUTO(it, g_stack_pool.begin());
			for(;;){
				if(it == g_stack_pool.end()){
					stack.reset();
					break;
				}
				if(!*it){
					stack.swap(*it);
					break;
				}
				++it;
			}
		}
  VisualServo() : arm_("left"),
		planning_group_name_(arm_+"_arm"),
		camera_frame_(arm_+"_hand_camera")
  {
    move_group_.reset(new move_group_interface::MoveGroup(planning_group_name_));
    move_group_->setPlanningTime(30.0);
    move_group_->setPlannerId("RRTstark");
    while(ros::ok())
      {
	// marker_pose_subscriber_ = node_.subscribe("ar_pose_marker",50, &VisualServo::marker_pose_callback, this);
	// target_publisher_ = node_.advertise<geometry_msgs::Pose>("/visual_servo_target", 10);
	servo_to_tag();
      }
  }
Example #28
0
File: node.cpp Project: ErolB/Sub8
  void odom_callback(const OdometryConstPtr &odom) {
    if (c3trajectory) return;                            // already initialized
    if (kill_listener.get_killed() || disabled) return;  // only initialize when unkilled

    subjugator::C3Trajectory::Point current =
        Point_from_PoseTwist(odom->pose.pose, odom->twist.twist);
    current.q[3] = current.q[4] = 0;              // zero roll and pitch
    current.qdot = subjugator::Vector6d::Zero();  // zero velocities

    c3trajectory.reset(new subjugator::C3Trajectory(current, limits));
    c3trajectory_t = odom->header.stamp;

    current_waypoint = current;
    current_waypoint_t = odom->header.stamp;
  }
Example #29
0
   sub_match(const sub_match& that, bool 
#ifdef BOOST_REGEX_MATCH_EXTRA
      deep_copy
#endif
      = true
      ) 
      : std::pair<BidiIterator, BidiIterator>(that), 
        matched(that.matched) 
   {
#ifdef BOOST_REGEX_MATCH_EXTRA
      if(that.m_captures)
         if(deep_copy)
            m_captures.reset(new capture_sequence_type(*(that.m_captures)));
#endif
   }
Example #30
0
File: tree.hpp Project: qnzhou/cgal
 void train(DataView2D<FeatureType> samples, 
            DataView2D<int> labels, 
            int* sample_idxes, 
            size_t n_samples, 
            SplitGenerator split_generator,
            RandomGen const& gen
            ) 
 {
     // copy generator
     RandomGen my_gen = gen;
     // initialize root node
     root_node.reset(new NodeT(0, params));
     // train root node (other notes get trained recursively)
     root_node->train(samples, labels, sample_idxes, n_samples, split_generator, my_gen);
 }