当前位置: 首页>>代码示例>>C++>>正文


C++ Trajectory::readTrajectory方法代码示例

本文整理汇总了C++中Trajectory::readTrajectory方法的典型用法代码示例。如果您正苦于以下问题:C++ Trajectory::readTrajectory方法的具体用法?C++ Trajectory::readTrajectory怎么用?C++ Trajectory::readTrajectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Trajectory的用法示例。


在下文中一共展示了Trajectory::readTrajectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readState

/**
	This method is used to read the state parameters from a file
*/
void SimBiConState::readState(FILE* f, int offset){
	if (f == NULL)
		throwError("File pointer is NULL - cannot read gain coefficients!!");

	//have a temporary buffer used to read the file line by line...
	char buffer[200];
	Trajectory* tempTraj;


	//this is where it happens.
	while (!feof(f)){
		//get a line from the file...
		fgets(buffer, 200, f);
		if (strlen(buffer)>195)
			throwError("The input file contains a line that is longer than ~200 characters - not allowed");
		char *line = lTrim(buffer);
		int lineType = getConLineType(line);
		switch (lineType) {
			case CON_STATE_END:
				//we're done...
				return;
				break;
			case CON_NEXT_STATE:
				if (sscanf(line, "%d", &this->nextStateIndex) != 1)
					throwError("An index must be specified when using the \'nextState\' keyword");
				this->nextStateIndex += offset;
				break;
			case CON_STATE_DESCRIPTION:
				strcpy(this->description, trim(line));
				break;
			case CON_STATE_TIME:
				if (sscanf(line, "%lf", &stateTime)!=1)
					throwError("The time that is expected to be spent in this state needs to be provided.");
				break;
			case CON_STATE_STANCE:
				reverseStance = false;
				keepStance = false;
				if (strncmp(trim(line), "left",4) == 0)
					stateStance = LEFT_STANCE;
				else
					if (strncmp(trim(line), "right", 5) == 0)
						stateStance = RIGHT_STANCE;
					else
						if (strncmp(trim(line), "reverse", 7) == 0)
							reverseStance = true;
						else if (strncmp(trim(line), "same", 4) == 0)
								keepStance = true;
							else
								throwError("When using the \'stateStance\' keyword, \'left\', \'right\' or \'reverse\' must be specified.");
				break;
			case CON_TRANSITION_ON:
				transitionOnFootContact = false;
				if (strncmp(trim(line), "footDown", 8) == 0)
					transitionOnFootContact = true;
				else
					if (strncmp(trim(line), "timeUp", 6) == 0)
						//nothn' to do, since this is the default
						;
					else
						throwError("When using the \'transitionOn\' keyword, \'footDown\' or \'timeUp\' must be specified.");
				break;
			case CON_TRAJECTORY_START:
				//create a new trajectory, and read its information from the file
				tempTraj = new Trajectory();
				strcpy(tempTraj->jName, trim(line));
				tempTraj->readTrajectory(f);
				this->sTraj.push_back(tempTraj);
				break;

			case CON_D_TRAJX_START:
				if( dTrajX != NULL )
					throwError( "Two dTrajX trajectory, this is illegal!" );
				dTrajX = new Trajectory1D();
				readTrajectory1D( f, *dTrajX, CON_D_TRAJX_END );
				break;

			case CON_D_TRAJZ_START:
				if( dTrajZ != NULL )
					throwError( "Two dTrajZ trajectory, this is illegal!" );
				dTrajZ = new Trajectory1D();
				readTrajectory1D( f, *dTrajZ, CON_D_TRAJZ_END );
				break;

			case CON_V_TRAJX_START:
				if( vTrajX != NULL )
					throwError( "Two vTrajX trajectory, this is illegal!" );
				vTrajX = new Trajectory1D();
				readTrajectory1D( f, *vTrajX, CON_V_TRAJX_END );
				break;

			case CON_V_TRAJZ_START:
				if( vTrajZ != NULL )
					throwError( "Two vTrajZ trajectory, this is illegal!" );
				vTrajZ = new Trajectory1D();
				readTrajectory1D( f, *vTrajZ, CON_V_TRAJZ_END );
				break;

//.........这里部分代码省略.........
开发者ID:jchen114,项目名称:CPSC540-Final-Project,代码行数:101,代码来源:SimBiConState.cpp

示例2: readState

/**
	This method is used to read the state parameters from a file
*/
void SimBiConState::readState(FILE* f, int offset){

    //have a temporary buffer used to read the file line by line...
    char buffer[200];
    Trajectory* tempTraj;


    //this is where it happens.
    while (!feof(f)){
        //get a line from the file...
        fgets(buffer, 200, f);

        char *line = lTrim(buffer);
        int lineType = getConLineType(line);
        switch (lineType) {
        case CON_STATE_END:
            //we're done...
            return;
            break;
        case CON_NEXT_STATE:
            if (sscanf(line, "%d", &this->nextStateIndex) != 1)
                return;
            this->nextStateIndex += offset;
            break;
        case CON_STATE_DESCRIPTION:
            strcpy(this->description, trim(line));
            break;
        case CON_STATE_TIME:
            if (sscanf(line, "%lf", &stateTime)!=1)
                return;
            break;
        case CON_STATE_STANCE:
            reverseStance = false;
            keepStance = false;
            if (strncmp(trim(line), "left",4) == 0)
                stateStance = LEFT_STANCE;
            else
                if (strncmp(trim(line), "right", 5) == 0)
                    stateStance = RIGHT_STANCE;
                else
                    if (strncmp(trim(line), "reverse", 7) == 0)
                        reverseStance = true;
                    else if (strncmp(trim(line), "same", 4) == 0)
                        keepStance = true;
                    else
                        return;
                    break;
        case CON_TRANSITION_ON:
            transitionOnFootContact = false;
            if (strncmp(trim(line), "footDown", 8) == 0)
                transitionOnFootContact = true;
            else
                if (strncmp(trim(line), "timeUp", 6) == 0)
                    //nothn' to do, since this is the default
                        ;
                else
                    return;
            break;
        case CON_TRAJECTORY_START:
            //create a new trajectory, and read its information from the file
            tempTraj = new Trajectory();
            strcpy(tempTraj->jName, trim(line));
            tempTraj->readTrajectory(f);
            this->sTraj.push_back(tempTraj);
            break;

        case CON_D_TRAJX_START:
            if( dTrajX != NULL )
                return;
            dTrajX = new Trajectory1D();
            readTrajectory1D( f, *dTrajX, CON_D_TRAJX_END );
            break;

        case CON_D_TRAJZ_START:
            if( dTrajZ != NULL )
                return;
            dTrajZ = new Trajectory1D();
            readTrajectory1D( f, *dTrajZ, CON_D_TRAJZ_END );
            break;

        case CON_V_TRAJX_START:
            if( vTrajX != NULL )
                return;
            vTrajX = new Trajectory1D();
            readTrajectory1D( f, *vTrajX, CON_V_TRAJX_END );
            break;

        case CON_V_TRAJZ_START:
            if( vTrajZ != NULL )
                return;
            vTrajZ = new Trajectory1D();
            readTrajectory1D( f, *vTrajZ, CON_V_TRAJZ_END );
            break;

        case CON_COMMENT:
            break;

//.........这里部分代码省略.........
开发者ID:rudysnow,项目名称:SimbiconPlatform,代码行数:101,代码来源:SimBiConState.cpp


注:本文中的Trajectory::readTrajectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。