MCPcopy Create free account
hub / github.com/ROBOTIS-GIT/DynamixelSDK / BulkReadWrite

Class BulkReadWrite

java/protocol2.0/bulk_read_write/BulkReadWrite.java:31–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29import java.util.Scanner;
30
31public class BulkReadWrite
32{
33 public static void main(String[] args)
34 {
35 // Control table address
36 short ADDR_PRO_TORQUE_ENABLE = 562; // Control table address is different in Dynamixel model
37 short ADDR_PRO_LED_RED = 563;
38 short ADDR_PRO_GOAL_POSITION = 596;
39 short ADDR_PRO_PRESENT_POSITION = 611;
40
41 // Data Byte Length
42 short LEN_PRO_LED_RED = 1;
43 short LEN_PRO_GOAL_POSITION = 4;
44 short LEN_PRO_PRESENT_POSITION = 4;
45
46 // Protocol version
47 int PROTOCOL_VERSION = 2; // See which protocol version is used in the Dynamixel
48
49 // Default setting
50 byte DXL1_ID = 1; // Dynamixel ID: 1
51 byte DXL2_ID = 2; // Dynamixel ID: 2
52 int BAUDRATE = 57600;
53 String DEVICENAME = "/dev/ttyUSB0"; // Check which port is being used on your controller
54 // ex) Windows: "COM1" Linux: "/dev/ttyUSB0" Mac: "/dev/tty.usbserial-*"
55
56 byte TORQUE_ENABLE = 1; // Value for enabling the torque
57 byte TORQUE_DISABLE = 0; // Value for disabling the torque
58 int DXL_MINIMUM_POSITION_VALUE = -150000; // Dynamixel will rotate between this value
59 int DXL_MAXIMUM_POSITION_VALUE = 150000; // and this value (note that the Dynamixel would not move when the position value is out of movable range. Check e-manual about the range of the Dynamixel you use.)
60 int DXL_MOVING_STATUS_THRESHOLD = 20; // Dynamixel moving status threshold
61
62 String KEY_FOR_ESCAPE = "e"; // Key for escape
63
64 int COMM_SUCCESS = 0; // Communication Success result value
65 int COMM_TX_FAIL = -1001; // Communication Tx Failed
66
67 // Instead of getch
68 Scanner scanner = new Scanner(System.in);
69
70 // Initialize Dynamixel class for java
71 Dynamixel dynamixel = new Dynamixel();
72
73 // Initialize PortHandler Structs
74 // Set the port path
75 // Get methods and members of PortHandlerLinux or PortHandlerWindows
76 int port_num = dynamixel.portHandler(DEVICENAME);
77
78 // Initialize PacketHandler Structs
79 dynamixel.packetHandler();
80
81 // Initialize GroupBulkWrite Struct
82 int groupwrite_num = dynamixel.groupBulkWrite(port_num, PROTOCOL_VERSION);
83
84 // Initialize Groupsyncwrite instance
85 int group_num = dynamixel.groupBulkRead(port_num, PROTOCOL_VERSION);
86
87 int index = 0;
88 int dxl_comm_result = COMM_TX_FAIL; // Communication result

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected