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


C++ Matrix::ColNo方法代码示例

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


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

示例1: Print

//Prints the elements of a matrix
void Print(Matrix M)
{
	for (int i=0; i < M.RowNo(); i++)
	{
      for (int j=0; j < M.ColNo(); j++)
      {
         printf("%.6f ", M(i,j));

      }
      printf("\n");
	}
}
开发者ID:jys168723,项目名称:MIMO-Simulation,代码行数:13,代码来源:utilities.cpp

示例2: WMRA_park2ready

void WMRA_park2ready(int ini, int vr, int ml, int arm, Matrix Tiwc, Matrix qiwc, Galil &g){
Matrix zero(1,1);
zero.Null(1,1);
	if (ini==3){
		if (arm==1){
			try {
            WMRA_ARM_Motion(ini, 0, zero, 0, g);
			}
			catch (...) {
				cout << "Exception 1 occurred";
			}
		}
		if (vr==1){
			/*try {
				WMRA_VR_Animation(ini, 0, 0);
			}
			catch (...) {
				cout << "Exception 2 occurred";
			}*/
		}
		if (ml==1){
			/*try {
				WMRA_ML_Animation(ini, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
			}
			catch (...) {
				cout << "Exception 3 occurred";
			}*/
		}
		return;
	}

	// Defining the used conditions:
	float qi2 [7]= {0, PI/2, 0, PI, 0, 0, 0}; // Initial joint angles (Parking Position).
	float qd2 [7]= {PI/2, PI/2, 0, PI/2, PI/2, PI/2, 0}; // Final joint angles (Ready Position).
	Matrix qd(7,1), qi(7,1);
	float ts, dt, ddt;
	int n, j;
	for ( j = 0 ; j < 7 ; j++ ) {
		qi(j,0)=qi2[j];
		qd(j,0)=qd2[j];
	}
	ts=10;  // (5 or 10 or 20) Simulation time to move the arm from any position to the ready position.
	n=100;  // Number of time steps.
	dt=ts/n;  // The time step to move the arm from any position to the ready position.
	Matrix dq(1,1);
	dq=qd-qi;
	dq/=(0.5*n+5);  // Joint angle change at every time step.

	FILE * fil;
	fil = fopen("Park2ready.txt","w");
	fprintf(fil," qi is: \n\n");
	int k;
	for (j=0;j<qi.RowNo();j++){
		for (k=0;k<qi.ColNo();k++){
			fprintf(fil," %4.2f ",  qi(j,k));
		}
		fprintf(fil," \n");
	}
	fprintf(fil," \n\n\n");
	fprintf(fil," qd is: \n\n");
	for (j=0;j<qd.RowNo();j++){
		for (k=0;k<qd.ColNo();k++){
			fprintf(fil," %4.2f ",  qd(j,k));
		}
		fprintf(fil," \n");
	}
	fprintf(fil," \n\n\n");
	fprintf(fil," ts is %4.2f ",  ts);
	fprintf(fil," \n\n\n");
	fprintf(fil," n is %d ",  n);
	fprintf(fil," \n\n\n");
	fprintf(fil," dt is %4.2f ",  dt);
	fprintf(fil," \n\n\n");
	fprintf(fil," dq is: \n\n");
	for (j=0;j<dq.RowNo();j++){
		for (k=0;k<dq.ColNo();k++){
			fprintf(fil," %4.2f ",  dq(j,k));
		}
		fprintf(fil," \n");
	}
	fprintf(fil," \n\n\n");

	// Initializing the physical Arm:
	if (arm==1){
		zero.Null(10,1);
		for ( j = 0 ; j < 7 ; j++ ) {
			zero(j,0)=qi(j,0);
		}
		zero(7,0)=qiwc(0,0);
		zero(8,0)=qiwc(1,0);
		WMRA_ARM_Motion(ini, 2, zero, dt, g);
		ddt=0;
	}

	fprintf(fil," qi is: \n\n");
	for (j=0;j<qi.RowNo();j++){
		for (k=0;k<qi.ColNo();k++){
			fprintf(fil," %4.2f ",  qi(j,k));
		}
		fprintf(fil," \n");
//.........这里部分代码省略.........
开发者ID:CARRTUSF,项目名称:Master_Program,代码行数:101,代码来源:park2ready.cpp

示例3: WMRA_any2ready

void WMRA_any2ready(int ini, int vr, int ml, int arm, Matrix Tiwc, Matrix qi, Galil &g){
Matrix zero(1,1);
zero.Null(1,1);
	if (ini==3){
		if (arm==1){
			try {
            WMRA_ARM_Motion(ini, 0, zero, 0, g);
			cout<< "any ini "<<endl;
			}
			catch (...) {
				cout << "Exception 1 occurred";
			}
		}
		if (vr==1){
			/*try {
				WMRA_VR_Animation(ini, 0, 0);
			}
			catch (...) {
				cout << "Exception 2 occurred";
			}*/
		}
		if (ml==1){
			/*try {
				WMRA_ML_Animation(ini, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
			}
			catch (...) {
				cout << "Exception 3 occurred";
			}*/
		}
		return;
	}

	// Defining the used conditions:
	Matrix qd(7,1);
	float ts, dt, ddt;
	int n, j;
	//float qd2 [7]= {90, 90, 0, 90, 90, 90, 0}; // Final joint angles (Ready Position) //#1
	//float qd2 [7]= {90, 90, -90, 180, 0, 60, 0}; // Final joint angles (Ready Position) #3
	//float qd2 [7]= {90, 90, -90, 180, 0, 60, 0}; //#4
	float qd2 [7]= {90, 90, 0, 90, 90, 60, 0}; // (Ready Position) //#2
	//float qd2 [7]= {90, 90, 0, 90, 120, 60, 0}; // (Ready Position) //#5
	//float qd2 [7]= {90, 90, 0, 90, 60, 60, 0}; // (Ready Position) //#6
	//float qd2 [7]= {90, 60, 0, 90, 60, 60, 0};// ready position joint angles #7
	//float qd2 [7]= {90, 90, 30, 90, 90, 60, 0};// ready position joint angles #8

	for ( j = 0 ; j < 7 ; j++ ) {
		qd(j,0)=qd2[j]*d2r;
	}
	ts=10;  // (5 or 10 or 20) Simulation time to move the arm from any position to the ready position.
	n=100;  // Number of time steps.
	dt=ts/n;  // The time step to move the arm from any position to the ready position.

	FILE * fel;
	fel = fopen("Any2ready.txt","w");
	fprintf(fel," qd is: \n\n");
	int k;
	for (j=0;j<qd.RowNo();j++){
		for (k=0;k<qd.ColNo();k++){
			fprintf(fel," %4.2f ",  qd(j,k));
		}
		fprintf(fel," \n");
	}
	fprintf(fel," \n\n\n");
	fprintf(fel," ts is %4.2f ",  ts);
	fprintf(fel," \n\n\n");
	fprintf(fel," n is %d ",  n);
	fprintf(fel," \n\n\n");
	fprintf(fel," dt is %4.2f ",  dt);
	fprintf(fel," \n\n\n");
	
	// Initializing the physical Arm:
	if (arm==1){
		zero.Null(10,1);
		for ( j = 0 ; j < 9 ; j++ ) {
			zero(j,0)=qi(j,0);
		}
		cout<<"0";
		WMRA_ARM_Motion(ini, 2, zero, dt, g);
		ddt=0;
		cout<<"1"<<endl;		
	}
	fprintf(fel," qi is: \n\n");
	for (j=0;j<qi.RowNo();j++){
		for (k=0;k<qi.ColNo();k++){
			fprintf(fel," %4.2f ",  qi(j,k));
		}
		fprintf(fel," \n");
	}	
	fprintf(fel," \n\n\n");

	// Initializing Virtual Reality Animation:
	if (vr==1){
	//	WMRA_VR_Animation(ini, Tiwc, qi);
	}

	// Initializing Robot Animation in Matlab Graphics:
	Matrix DH(1,1);
	Matrix T01(4,4), T12(4,4), T23(4,4), T34(4,4), T45(4,4), T56(4,4), T67(4,4);
	Matrix Ti(4,4), Td(4,4);
		
//.........这里部分代码省略.........
开发者ID:CARRTUSF,项目名称:Master_Program,代码行数:101,代码来源:any2ready.cpp


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