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


C++ Dynamixel类代码示例

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


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

示例1: main

int main()
{
    Dynamixel test;
    double feed;
    if(!test.Initialize("/dev/ttyUSB0",false,10.0))
    {
        return -1;
    }
    
    
    //do a sine wave
    
    double t=0;
    double val;
    while(1)
    {
        double top=(564-512)/512.0*100.0;
        double bot=(440-512)/512.0*100.0;
        
        
        
        //val=(top-bot)/2.0*sin(t/(2*M_PI))+(top+bot)/2.0;
        //test.SetServo(1,val);
        //feed=test.GetServo(1);
        //printf("%lf %lf\n",val,feed);
        //t+=0.05;
        for(double val=bot;val<=top;val+=1.0)
        {
            printf("%lf\n",val);
            test.SetServo(1,val);
            CxUtils::SleepMs(50);
        }
        for(double val=top;val>=bot;val-=1.0)
        {
            printf("%lf\n",val);
            test.SetServo(1,val);
            CxUtils::SleepMs(50);
        }
        
    }
    
    return 0;
}
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:43,代码来源:example_dynamixel.cpp

示例2: main

int main(int argc,char** argv)
{
  ros::init(argc, argv, "c8_dynamixel");
  Dynamixel motors;

  float counter = -180;
  ros::Rate loop_rate(100);
  while(ros::ok())
  {
    if(counter < 180)
    {
      motors.moveMotor(counter*3.14/180);
      counter++;
    }else{
      counter = -180;
    }
    loop_rate.sleep();
  }
}
开发者ID:PETGreen,项目名称:effective_robotics_programming_with_ros,代码行数:19,代码来源:c8_dynamixel.cpp

示例3: printf

int Instruction::moveWithSpeed(std::vector<instruction_set> instruction_list){
	SerialPortF comPort;
	Dynamixel communication;
	hr = comPort.Open(L"COM1", baudRate);
	if(FAILED(hr))
	{
		printf("Cannot open COM1 port\n");
		return -1;
	}else{
		//printf("Starting communication\n");
	}

	communication.SendTossModeCommand(&comPort);
	for(int indx = 0;  indx < instruction_list.size(); indx++){
		communication.SetDynamixelMovingSpeed(&comPort, instruction_list[indx].id_motor, instruction_list[indx].value, instruction_list[indx].speed);	
	}

	comPort.Close();
	return 0;
}
开发者ID:rebot666,项目名称:morpholoid,代码行数:20,代码来源:Instruction.cpp

示例4: main

int main()
{
    
    int i;

    Dynamixel DXL("/dev/ttyUSB0");
    //BulkRead bulkread(&DXL);


    // Open device
    if( DXL.Connect() == 0 )
    {
        printf( "Failed to open USB2Dynamixel!\n" );
        return 0;
    }
    else
        printf( "Succeed to open USB2Dynamixel!\n" );

	//Close port of USB2DXL
    DXL.Disconnect();
   

    return 0;
}
开发者ID:thedancomplex,项目名称:XM-430-example,代码行数:24,代码来源:main.cpp

示例5: Read

void Read(int id, int addr, int len)
{
	int result = COMM_TXFAIL, error = 0;
	int ivalue = 0;
	long lvalue = 0;

	if(len == 1)
		result = DXL.ReadByte(id, addr, &ivalue, &error);
	else if(len == 2)
		result = DXL.ReadWord(id, addr, &ivalue, &error);
	else if(len == 4)
		result = DXL.ReadDWord(id, addr, &lvalue, &error);

	if(result != COMM_RXSUCCESS)
	{
		fprintf(stderr, "\n Fail to read! (result : %d) \n\n", result);
		return;
	}

	if(error != 0)
		PrintErrorCode(error);

	if(len == 1)
		fprintf(stderr, "\n READ VALUE : %d \n\n", ivalue);
	else if(len == 2)
		fprintf(stderr, "\n READ VALUE : (UNSIGNED) %u , (SIGNED) %d \n\n", ivalue, ivalue);
	else
		fprintf(stderr, "\n READ VALUE : (UNSIGNED) %lu , (SIGNED) %d \n\n", lvalue, lvalue);
}
开发者ID:Yunaik,项目名称:thu,代码行数:29,代码来源:monitor.cpp

示例6: jointMove

void xlMotor::jointMove(int position, int speed)
{
    Dxl.jointMode(myID);
    delayMicroseconds(100);
    Dxl.setPosition(myID,position,speed);
    delayMicroseconds(1);
}
开发者ID:KAsimov-,项目名称:DRIMLINER,代码行数:7,代码来源:DRIMLINER.cpp

示例7: wheelMove

void xlMotor::wheelMove(char direction,int speed)
{
    if (direction=='F') {
        Dxl.goalSpeed(myID, speed);
    }
    else if(direction=='R')
    {
        Dxl.goalSpeed(myID, speed| 0x400);
    }
   
    
}
开发者ID:KAsimov-,项目名称:DRIMLINER,代码行数:12,代码来源:DRIMLINER.cpp

示例8: resetSettings

void xlMotor::resetSettings(void){
	xlMotor::setBaud(3);
	xlMotor::setReturnDelay(250);
    Dxl.jointMode(myID);
	xlMotor::setTempLimit(70);
	xlMotor::setStatusReturn(2);
    
}
开发者ID:KAsimov-,项目名称:DRIMLINER,代码行数:8,代码来源:DRIMLINER.cpp

示例9: Refresh

void Refresh(int id, int addr, int len)
{
	int result = COMM_TXFAIL, error = 0;
	int ivalue = 0;
	long lvalue = 0;

	fprintf(stderr, "\n [ESC] : Quit monitoring \n\n");
	while(1)
	{
		if(len == 1)
			result = DXL.ReadByte(id, addr, &ivalue, &error);
		else if(len == 2)
			result = DXL.ReadWord(id, addr, &ivalue, &error);
		else if(len == 4)
			result = DXL.ReadDWord(id, addr, &lvalue, &error);

		if(result != COMM_RXSUCCESS)
		{
			//fprintf(stderr, "\n Fail to read! (result : %d) \n\n", result);
			continue;
		}

		if(error != 0)
			PrintErrorCode(error);

		if(len == 1)
			fprintf(stderr, " READ VALUE : %.3d [0x%.2X] \r", ivalue, ivalue);
		else if(len == 2)
			fprintf(stderr, " READ VALUE : %.5d [0x%.2X 0x%.2X] \r", ivalue, DXL_LOBYTE(ivalue), DXL_HIBYTE(ivalue));
		else
			fprintf(stderr, " READ VALUE : %.10ld [0x%.2X 0x%.2X 0x%.2X 0x%.2X] \r",
					lvalue, DXL_LOBYTE(DXL_LOWORD(lvalue)), DXL_HIBYTE(DXL_LOWORD(lvalue)), DXL_LOBYTE(DXL_HIWORD(lvalue)), DXL_HIBYTE(DXL_HIWORD(lvalue)));

		if(kbhit())
		{
			char c = _getch();
			if(c == 0x1b)
				break;
		}
	}
	fprintf(stderr, "\n\n");
}
开发者ID:Yunaik,项目名称:thu,代码行数:42,代码来源:monitor.cpp

示例10: Broadcast

void Broadcast()
{
	unsigned char param[Amount*(1+4)];
	for(int i = 0; i < Amount; i++)
	{
		DXL.WriteByte(Id[i], P_TORQUE_ENABLE, 1, 0);
	}
	int goal=0;
	int GoalPos;
	while(1)
    {
        printf( "Press any key to continue!(press ESC to quit)\n" );
        if(_getch() == 0x1b)
            break;
        do
        {
            // Make syncwrite packet
            for(int i = 0; i < Amount; i++)
            {
                printf("for id=%d,input goalpos\n",Id[i]);
		scanf("%d",&goal);
                GoalPos = (int)(goal);

                param[i*(1+4)+0] = (unsigned char)Id[i];
                param[i*(1+4)+1] = DXL_LOBYTE(DXL_LOWORD(GoalPos));
                param[i*(1+4)+2] = DXL_HIBYTE(DXL_LOWORD(GoalPos));
                param[i*(1+4)+3] = DXL_LOBYTE(DXL_HIWORD(GoalPos));
                param[i*(1+4)+4] = DXL_HIBYTE(DXL_HIWORD(GoalPos));
            }
            printf("%d\n", GoalPos);
            int result = DXL.SyncWrite(P_GOAL_POSITION_LL, 4, param, Amount*(1+4));
            if( result != COMM_RXSUCCESS )
            {
                printf("fail to open serial port!\n");//PrintCommStatus(result);
                break;
            }
            usleep(CONTROL_PERIOD*1000);

        }while(1);
    }
}
开发者ID:Yunaik,项目名称:thu,代码行数:41,代码来源:monitor.cpp

示例11: Write

void Write(int id, int addr, long value, int len)
{
	int result = COMM_TXFAIL, error = 0;

	if(len == 1)
		result = DXL.WriteByte(id, addr, (int)value, &error);
	else if(len == 2)
		result = DXL.WriteWord(id, addr, (int)value, &error);
	else if(len == 4)
		result = DXL.WriteDWord(id, addr, value, &error);

	if(result != COMM_RXSUCCESS)
	{
		fprintf(stderr, "\n Fail to write! \n\n");
		return;
	}

	if(error != 0)
		PrintErrorCode(error);

	fprintf(stderr, "\n Success to write! \n\n");
}
开发者ID:Yunaik,项目名称:thu,代码行数:22,代码来源:monitor.cpp

示例12: BeltTest

void BeltTest()
{
	int result;
	long lvalue1 , lvalue2;

	while(true)
	{
		if(kbhit())
			break;

		result = DXL.ReadDWord(17, 611, &lvalue1, 0);
		result = DXL.ReadDWord(18, 611, &lvalue2, 0);
		fprintf(stderr, "\n READ VALUE : %d , %d \n\n", lvalue1, lvalue2);
	}
}
开发者ID:Yunaik,项目名称:thu,代码行数:15,代码来源:monitor.cpp

示例13: BroadcastPing

void BroadcastPing()
{
	std::vector<PingInfo> vec_info = std::vector<PingInfo>();
	DXL.BroadcastPing(vec_info);

	if(vec_info.size() > 0)
	{
		Amount=vec_info.size();
		fprintf(stderr, "\n");
		for(int i = 0; i < (int)vec_info.size(); i++)
		{
			fprintf(stderr, "                                          ... SUCCESS \r");
			fprintf(stderr, " [ID:%.3d] Model No : %.5d (0x%.2X 0x%.2X) \n",
					vec_info.at(i).ID, vec_info.at(i).ModelNumber, DXL_LOBYTE(vec_info.at(i).ModelNumber), DXL_HIBYTE(vec_info.at(i).ModelNumber));
			Id[i]=vec_info.at(i).ID;
		}
		fprintf(stderr, "\n");
	}
}
开发者ID:Yunaik,项目名称:thu,代码行数:19,代码来源:monitor.cpp

示例14: Dump

void Dump(int id, int addr, int len)
{
	int result = COMM_TXFAIL, error = 0;
	unsigned char* data = (unsigned char*)calloc(len, sizeof(unsigned char));

	result = DXL.Read(id, addr, len, data, &error);
	if(result != COMM_RXSUCCESS)
	{
		fprintf(stderr, "\n Fail to read! (result : %d) \n\n", result);
		return;
	}

	if(error != 0)
		PrintErrorCode(error);

	if(id != BROADCAST_ID)
	{
		fprintf(stderr, "\n");
		for(int i = addr; i < addr+len; i++)
			fprintf(stderr, "ADDR %.3d [0x%.4X] :     %.3d [0x%.2X] \n", i, i, data[i-addr], data[i-addr]);
		fprintf(stderr, "\n");
	}
}
开发者ID:Yunaik,项目名称:thu,代码行数:23,代码来源:monitor.cpp

示例15: Scan

void Scan()
{
	fprintf(stderr, "\n");
	PingInfo *data = new PingInfo();
	for(int i = 1; i < 253; i++)
	{
		if(DXL.Ping(i, data, 0) == COMM_RXSUCCESS)
		{
			fprintf(stderr, "\n                                          ... SUCCESS \r");
			fprintf(stderr, " [ID:%.3d] Model No : %.5d (0x%.2X 0x%.2X) \n",
					data->ID, data->ModelNumber, DXL_LOBYTE(data->ModelNumber), DXL_HIBYTE(data->ModelNumber));
		}
		else
			fprintf(stderr, ".");

		if(kbhit())
		{
			char c = _getch();
			if(c == 0x1b)
				break;
		}
	}
	fprintf(stderr, "\n\n");
}
开发者ID:Yunaik,项目名称:thu,代码行数:24,代码来源:monitor.cpp


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