Пример #1
0
JNIEXPORT jobject JNICALL Java_nl_ru_ai_projects_parrot_dronecontrol_groundstation_GroundStation_getFrontCameraImage0(JNIEnv* env, jobject obj) {
  lock_guard<recursive_mutex> dcoLock(droneControlObjectMutex);
  int imageSize = droneControlObject->getImageWidth() * droneControlObject->getImageHeight() * 3;

  if (imageSize == 0) {
    return NULL;
  }

  if (imageSize != allocatedFrontImageBufferData) {
    if (frontImageBufferData != NULL) {
      env->DeleteGlobalRef(frontImageBufferData);
      frontImageBufferData = NULL;
    }

    allocatedFrontImageBufferData = imageSize;
    if (imageSize > 0) {
      droneFrontImageData = shared_array<char>(new char[allocatedFrontImageBufferData]);
      frontImageBufferData = env->NewDirectByteBuffer(droneFrontImageData.get(), allocatedFrontImageBufferData);
      if (frontImageBufferData == NULL) {
        return NULL;
      }
    }
  }
  char* imageData = droneControlObject->getImageData();
  memcpy(droneFrontImageData.get(), imageData, imageSize);

  return frontImageBufferData;
}
Пример #2
0
    BlasiusFixture()
        : code_Ma(1.5)
        , blasius_u(suzerain_blasius_u(Re_x))
        , blasius_v(suzerain_blasius_v(Re_x))
        , accel(gsl_interp_accel_alloc())
        , b(k,
            bspline::from_breakpoints(),
            suzerain_blasius_extended_size,
            blasius_u->x + /*UGLY HACK uses Nnegative from blasius.c */10)
        , op(b, 0, SUZERAIN_BSPLINEOP_COLLOCATION_GREVILLE)
        , lu(op)
        , u (new double[b.n()])
        , v (new double[b.n()])
        , ke(new double[b.n()])
        , H0(new double[b.n()])
    {
        lu.factor_mass(op);

        // Prepare Blasius profile information as coefficients
        for (int i = 0; i < b.n(); ++i) {
            u[i]  = gsl_spline_eval(blasius_u, b.collocation_point(i), accel);
            v[i]  = gsl_spline_eval(blasius_v, b.collocation_point(i), accel);
            ke[i] = (u[i]*u[i] + v[i]*v[i]) / 2;
            H0[i] = u[i] + code_Ma*code_Ma*ke[i]; // h = u => delta2 = deltaH0
        }

        BOOST_REQUIRE_EQUAL(SUZERAIN_SUCCESS, lu.solve(1, u .get(), 1, b.n()));
        BOOST_REQUIRE_EQUAL(SUZERAIN_SUCCESS, lu.solve(1, v .get(), 1, b.n()));
        BOOST_REQUIRE_EQUAL(SUZERAIN_SUCCESS, lu.solve(1, ke.get(), 1, b.n()));
        BOOST_REQUIRE_EQUAL(SUZERAIN_SUCCESS, lu.solve(1, H0.get(), 1, b.n()));
    }
Пример #3
0
void NaoActionControl::GeneralActionCommand()
{
    stringstream ss;

    const shared_array<Robot::Link> link = NAO->GetLink();
    if (link.get() != 0)
    {
        for (int i = NAO->GetJointMin(); i <= NAO->GetJointMax(); ++i)
        {
            if (i == Robot::JID_ROOT) continue;
            /** NOTE if the link is the top one or not been set
             * up correctly, its joint velocity will not be sent */
            // if (link[i].mother == 0) continue;
            int twin = link[i].twin;
            if (twin == 0) // hinge joint effector
            {
                ss << "(" << link[i].eff_name;
                ss << " " << Precision(mJointVel[i]) << ")";
            }
            else // universal joint effector
            {
                int child = link[i].child;
                if (twin == child) // first twin
                {
                    ss << "(" << link[i].eff_name;
                    ss << " " << Precision(mJointVel[i]);
                    ss << " " << Precision(mJointVel[twin]) << ")";
                }
            }
        }
    }
    mActionCommand = ss.str();
    aLOG << mActionCommand << endl;
    aLOG << "****************************************the end of send message****************************************" << endl;
}
Пример #4
0
void QuickTimeSampleApp::loadMovieResource()
{
	try {
		loadResourceMemory( "Upgrade_U_small.mov", RES_UPGADE_U_MOV, "MOV", &data, &dataSize );
		
		mMovie = qtime::MovieGL( data.get(), dataSize, "Upgrade_U_small.mov", "video/quicktime" );
		std::cout << "Dimensions:" << mMovie.getWidth() << " x " << mMovie.getHeight() << std::endl;
		std::cout << "Duration:  " << mMovie.getDuration() << " seconds" << std::endl;
		std::cout << "Frames:    " << mMovie.getNumFrames() << std::endl;
		std::cout << "Framerate: " << mMovie.getFramerate() << std::endl;				
		mMovie.setLoop( true, true );
		
#ifdef USE_DISPLAY_LINK
		mMovie.enableDisplayLink( getDisplayLink() );
#endif
		mMovie.setNewFrameCallback( newFrameCallback, &mMovie );
		mMovie.play();
	}
	catch( ... ) {
		std::cout << "Unable to load the movie." << std::endl;
		mMovie.reset();
	}

	mTexture.reset();
}
/**
 * save tga images
 * @param name - file name to which data should be saved
 * @param data - smart array containing data to be stored (must be 32Bit per Pixel)
 * @param width,height - size of the image data
 * @return 0 if no error occurs
 */
int nrCTextureLoader::save_tga(const string& name,const shared_array<byte>& data,int width,int height) {
	
	char nname[1024];
	sprintf(nname, "%s%s", nrVFS.getPathToFileSystem(), name.c_str());
	FILE *file = fopen(nname,"wb");
	if(!file) {
		nrLog.Log(NR_LOG_ENGINE, "nrCTextureLoader::save_tga(): error create '%s' file",name.c_str());
		return 0;
	}
	shared_array<byte> buf(new byte[18 + width * height * 4]);
	memset(buf.get(),0,18);
	buf[2] = 2;
	buf[12] = width % 256;
	buf[13] = width / 256;
	buf[14] = height % 256;
	buf[15] = height / 256;
	buf[16] = 32;
	buf[17] = 0x28;
	memcpy(buf.get() + 18,data.get(),width * height * 4);

	// rgba->bgra
	for(int i = 18; i < 18 + width * height * 4; i += 4) {
		byte c = buf[i];
		buf[i] = buf[i + 2];
		buf[i + 2] = c;
	}
	fwrite(buf.get(),1,18 + width * height * 4,file);
	fclose(file);
	return 1;
}
Пример #6
0
void NaoActionControl::Update()
{
    const shared_array<Robot::Link> link = NAO->GetLink();
    if (link.get() != 0)
    {
        for (int i = NAO->GetJointMin(); i <= NAO->GetJointMax(); ++i)
        {
            //cerr << "ActionControl::Update----" << "i:" << i << endl;
            if (i == Robot::JID_ROOT) continue;
            /** NOTE if the link is the top one or not been
            * set up correctly, it will not be updated */
            // if (link[i].mother == 0) continue;
            mJointAngle[i] = link[i].q;
        }
    }

    for (int i = NAO->GetJointMin(); i <= NAO->GetJointMax(); ++i)
    {
        mJointVel[i] = 0.0f;
    }
}
 explicit two_bit_color_map(std::size_t n, const IndexMap& index = IndexMap())
   : n(n), index(index), data(new unsigned char[(n + 3) / 4])
 {
   // Fill to white
   std::fill(data.get(), data.get() + (n + 3) / 4, 0);
 }
Пример #8
0
void print(shared_array<char> text)
{
	std::cout << text.get() << std::endl;
}
Пример #9
0
template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) // never throws
{
    return std::less<T*>()(a.get(), b.get());
}
Пример #10
0
template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) // never throws
{
    return a.get() != b.get();
}
template<class T, class U> inline bool operator!=(shared_array<T> const & a, shared_array<U> const & b)
{
    return a.get() != b.get();
}