Hello everyone!
you remeber my previous robot, right? on this link.... https://www.robotshop.com/letsmakerobots/node/23912
.
now i want to modify the user interface to make it more user friendly. As i told you before I'm using a MS Visual Studio, so my question is can i make a user interface using this software with minimum C or C++ code!
can you help?
this is one of the programs I made wich shows a DOS like interface >< .
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "dynamixel.h"
#include<time.h>
#pragma comment(lib, “dynamixel.lib”)
// Control table address
#define P_GOAL_POSITION_L 30
#define P_GOAL_POSITION_H 31
#define P_PRESENT_POSITION_L 36
#define P_PRESENT_POSITION_H 37
#define P_MOVING 46
// Defulat setting
#define DEFAULT_PORTNUM 25 // COM3
#define DEFAULT_BAUDNUM 1 // 1Mbps
int main()
{
int Moving, PresentPos;
int CommStatus, Hold;
int PORT_ID, GoalPos1, GoalPos2, GoalPos3, GoalPos4;
char Action;
<cite><em>// Open device</em></cite>
if( dxl_initialize(DEFAULT_PORTNUM, DEFAULT_BAUDNUM) == 0 )
{
printf( "Failed to open USB2Dynamixel!\n" );
printf( "Press any key to terminate...\n" );
getch();
return 0;
}
else
printf( "System Ready to Control ROBOT!\n" );
<cite><em>//initial position</em></cite>
dxl_write_word( 5, P_GOAL_POSITION_L, 512); getch();
dxl_write_word( 4, P_GOAL_POSITION_L, 512); getch();
dxl_write_word( 1, P_GOAL_POSITION_L, 512); getch();
dxl_write_word( 244, P_GOAL_POSITION_L, 512);
Hold = 0;
printf( "My MASTER, I am ready to obey your Commands \n" );
printf("A - Pick Object A \n");
printf("B - Pick Object B \n");
printf("R - Place at Right Side \n");
printf("L - Place at Leftide \n");
printf("ESC - Exit \n");
printf("\n\n Your Choice Please, MY Master : ");
do
{ Action = getch();
switch (Action)
{ case 0x1b : break;
case 97 : if (Hold == 0)
{ Hold = 1;
dxl_write_word( 4, P_GOAL_POSITION_L, 630);
getch();
dxl_write_word( 5, P_GOAL_POSITION_L, 176);
getch();
dxl_write_word( 1, P_GOAL_POSITION_L, 625);
getch();
dxl_write_word( 4, P_GOAL_POSITION_L, 512);
printf(“Yes, My Master, Where should I Place it?”); }
else
{ printf(“Sorry My Master! I Couldn’t - I am Holding an Object! \n\n”);
} break;
case 98 : if (Hold == 0)
{ Hold = 1;
dxl_write_word( 4, P_GOAL_POSITION_L, 630);
getch();
dxl_write_word( 5, P_GOAL_POSITION_L, 176);
getch();
dxl_write_word( 1, P_GOAL_POSITION_L, 625);
getch();
dxl_write_word( 4, P_GOAL_POSITION_L, 512);
printf("Yes, My Master, Where should I Place it?");}
else
{ printf("Sorry My Master! I Couldn't - I am Holding an Object! \n\n");
} break;
case 114 : if (Hold == 1)
{ Hold = 0;
dxl_write_word( 244, P_GOAL_POSITION_L, 218);
getch();
dxl_write_word( 4, P_GOAL_POSITION_L, 635);
getch();
dxl_write_word( 1, P_GOAL_POSITION_L, 436);
getch();
dxl_write_word( 4, P_GOAL_POSITION_L, 512);
getch();
dxl_write_word(244, P_GOAL_POSITION_L, 512);
printf(“I think that I have done the JOB correctly!”); }
else
{ printf(“Sorry My Master! I Couldn’t - I don’t have anything to place! \n\n”);
} break;
case 108 : if (Hold == 1)
{ Hold = 0;
dxl_write_word(244, P_GOAL_POSITION_L, 839);
getch();
dxl_write_word( 4, P_GOAL_POSITION_L, 635);
getch();
dxl_write_word( 1, P_GOAL_POSITION_L, 436);
getch();
dxl_write_word( 4, P_GOAL_POSITION_L, 512);
getch();
dxl_write_word( 244, P_GOAL_POSITION_L, 512);
printf(“I think that I have done the JOB correctly!”);}
else
{ printf(“Sorry My Master! I Couldn’t - I don’t have anything to place! \n\n”);
} break;
default: printf(" Sorry, I don't have this Knowledge! - Teach me My Master! \n\n"); break;
}
}while(Action != 0x1b);
<cite><em>// Close device</em></cite>
dxl_terminate();
printf( "Press any key to terminate...\n" );
getch();
return 0;
}