Example #1
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()));
    }
Example #2
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;
}
Example #3
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;
}
Example #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;
}
Example #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;
    }
}
Example #7
0
	void release()
	{
		// Note that if two OpenCLBuffers point to the same thing, then this
		// only disconnects one side - the other one should be fine as both
		// cl::Buffer and boost::shared_array are reference counted.
		m_buffer=cl::Buffer();
		m_pElts=NULL;
		if(m_pStg)
			m_pStg->Release();
		m_pStg=0;
		m_n=0;
		m_cb=0;
		m_name="<empty>";
	}
Example #8
0
void TSSLSocketFactory::cleanupOpenSSL() {
  if (!initialized) {
    return;
  }
  initialized = false;
#if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_NO_THREAD_ID)
  CRYPTO_set_id_callback(NULL);
#endif
  CRYPTO_set_locking_callback(NULL);
  CRYPTO_set_dynlock_create_callback(NULL);
  CRYPTO_set_dynlock_lock_callback(NULL);
  CRYPTO_set_dynlock_destroy_callback(NULL);
  CRYPTO_cleanup_all_ex_data();
  ERR_free_strings();
  EVP_cleanup();
  ERR_remove_state(0);
  mutexes.reset();
}
 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);
 }
Example #10
0
void print(shared_array<char> text)
{
	std::cout << text.get() << std::endl;
}
Example #11
0
template<class T> void swap(shared_array<T> & a, shared_array<T> & b) // never throws
{
    a.swap(b);
}
Example #12
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());
}
Example #13
0
template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) // never throws
{
    return a.get() != b.get();
}
#include "TestHeader.hpp"
#include <Core/SharedArray.hpp>


TEST_CASE("Shared Array Basics", "[shared_array]")
{
  test_allocator _Allocator;
  allocator_interface* Allocator = &_Allocator;

  shared_array<int> Arr{};
  Arr.Allocator = Allocator;

  REQUIRE( Arr.Num() == 0 );

  SECTION("Reserve")
  {
    Reserve(Arr, 10);
    REQUIRE( Arr.Num() == 0 );
    REQUIRE( Arr.Capacity() >= 10 );
    REQUIRE( Arr.Ptr() != nullptr );
  }

  SECTION("PushBack")
  {
    Expand(Arr) = 42;
    REQUIRE( Arr.Num() == 1 );
    REQUIRE( Arr[0] == 42 );
  }
}

TEST_CASE("Shared Array Reserve", "[shared_array]")
template<class T> void swap(shared_array<T> & a, shared_array<T> & b)
{
    a.swap(b);
}
template<class T, class U> inline bool operator!=(shared_array<T> const & a, shared_array<U> const & b)
{
    return a.get() != b.get();
}