Go to the documentation of this file.00001
00002
00003
00004 #include <stdint.h>
00005
00006 #include <sstream>
00007 #include <string>
00008 #include <vector>
00009
00010 #include <dynamixel_hardware_interface/dynamixel_io.h>
00011 #include <dynamixel_hardware_interface/serial_proxy.h>
00012
00013 #include <ros/ros.h>
00014
00015 int main (int argc, char **argv)
00016 {
00017 ros::init(argc, argv, "dynamixel_hardware_interface");
00018
00019
00020
00021
00022
00023
00024 dynamixel_hardware_interface::DynamixelIO dxl_io("/dev/ttyUSB0", "1000000");
00025
00026 int num_motors = 6;
00027 int motors[] = { 4, 5, 6, 13, 15, 16 };
00028
00029 for (int i = 0; i < num_motors; ++i)
00030 {
00031 int id = motors[i];
00032
00033 if (dxl_io.ping(id))
00034 {
00035 ROS_INFO("Pinging motor %d", id);
00036
00037 uint16_t model_number, cw_angle, ccw_angle, position;
00038 uint8_t firmware_version, return_delay_time;
00039 int16_t velocity;
00040
00041 dxl_io.getModelNumber(id, model_number);
00042 dxl_io.getFirmwareVersion(id, firmware_version);
00043 dxl_io.getReturnDelayTime(id, return_delay_time);
00044 dxl_io.getCWAngleLimit(id, cw_angle);
00045 dxl_io.getCCWAngleLimit(id, ccw_angle);
00046 dxl_io.getPosition(id, position);
00047 dxl_io.getVelocity(id, velocity);
00048
00049 ROS_INFO("Pinging motor ID %d successfull, model is %d", id, model_number);
00050 ROS_INFO("ID %d: fw %d, delay %d, cw %d, ccw %d, pos %d, vel %d", id, firmware_version, return_delay_time, cw_angle, ccw_angle, position, velocity);
00051
00052
00053
00054 }
00055 }
00056
00057 int position = 512;
00058 int velocity = 32;
00059 int cw_compliance_margin = 1;
00060 int ccw_compliance_margin = cw_compliance_margin;
00061 int cw_compliance_slope = 32;
00062 int ccw_compliance_slope = cw_compliance_slope;
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 std::vector<std::map<std::string, int> > vm;
00094
00095 std::map<std::string, int> m;
00096 m["id"] = 15;
00097 m["target_position"] = position;
00098 m["target_velocity"] = velocity;
00099 m["cw_compliance_margin"] = cw_compliance_margin;
00100 m["ccw_compliance_margin"] = ccw_compliance_margin;
00101 m["cw_compliance_slope"] = cw_compliance_slope;
00102 m["ccw_compliance_slope"] = ccw_compliance_slope;
00103 vm.push_back(m);
00104
00105 m.clear();
00106 m["id"] = 16;
00107 m["target_position"] = position;
00108 m["target_velocity"] = velocity;
00109 m["cw_compliance_margin"] = cw_compliance_margin;
00110 m["ccw_compliance_margin"] = ccw_compliance_margin;
00111 m["cw_compliance_slope"] = cw_compliance_slope;
00112 m["ccw_compliance_slope"] = ccw_compliance_slope;
00113 vm.push_back(m);
00114
00115 dxl_io.setMultiValues(vm);
00116
00117 return 0;
00118 }