Go to the documentation of this file.00001 #include <ros/ros.h>
00002 #include "epos_hardware/utils.h"
00003 #include "epos_library/Definitions.h"
00004 #include <boost/foreach.hpp>
00005
00006 int main(int argc, char** argv){
00007 uint64_t serial_number;
00008 if(argc == 2){
00009 if(!SerialNumberFromHex(argv[1], &serial_number)) {
00010 std::cerr << "Expected a serial number" << std::endl;
00011 return 1;
00012 }
00013 }
00014 else {
00015 std::cerr << "Expected exactly one argument that is a serial number" << std::endl;
00016 return 1;
00017 }
00018
00019 std::string error_string;
00020 unsigned int error_code = 0;
00021
00022 std::cout << "Searching for USB EPOS2: 0x" << std::hex << serial_number << std::endl;
00023
00024 std::string port_name;
00025
00026 EposFactory epos_factory;
00027
00028 NodeHandlePtr handle;
00029 if(handle = epos_factory.CreateNodeHandle("EPOS2", "MAXON SERIAL V2", "USB", serial_number, &error_code)) {
00030 int position;
00031 if(VCS_GetPositionIs(handle->device_handle->ptr, handle->node_id, &position, &error_code)){
00032 std::cout << "Position: " << std::dec << position << std::endl;
00033 }
00034 else {
00035 if(GetErrorInfo(error_code, &error_string)){
00036 std::cerr << "Could not get position: " << error_string << std::endl;
00037 } else {
00038 std::cerr << "Could not get position" << std::endl;
00039 }
00040 }
00041
00042 int velocity;
00043 if(VCS_GetVelocityIs(handle->device_handle->ptr, handle->node_id, &velocity, &error_code)){
00044 std::cout << "Velocity: " << std::dec << velocity << std::endl;
00045 }
00046 else {
00047 if(GetErrorInfo(error_code, &error_string)){
00048 std::cerr << "Could not get velocity: " << error_string << std::endl;
00049 } else {
00050 std::cerr << "Could not get velocity" << std::endl;
00051 }
00052 }
00053
00054 short current;
00055 if(VCS_GetCurrentIs(handle->device_handle->ptr, handle->node_id, ¤t, &error_code)){
00056 std::cout << "Current: " << std::dec << current << std::endl;
00057 }
00058 else {
00059 if(GetErrorInfo(error_code, &error_string)){
00060 std::cerr << "Could not get current: " << error_string << std::endl;
00061 } else {
00062 std::cerr << "Could not get current" << std::endl;
00063 }
00064 }
00065
00066 }
00067 else {
00068 if(GetErrorInfo(error_code, &error_string)){
00069 std::cerr << "Could not open device: " << error_string << std::endl;
00070 } else {
00071 std::cerr << "Could not open device" << std::endl;
00072 }
00073 return 1;
00074 }
00075 }