Quick Start for Dynamixel Pro v1.00b
xi. Checking the current position and current velocity of Dynamixel PRO
-
There are two methods to check the present position of Dynamixel PRO.
-
First, is to implement dxl_read_dword function twice to change the values.
Second, is to implement dxl_read function to simultaneously read the Present
Position and Present Velocity.
-
You
dxl_tead_dword, This time implement the second method to change the Goal
Position and Goal Velocity of Dynamixel PRO.
-
Both Goal Position and Goal Velocity require 4 bytes.
-
Thus, to simultaneously read the Present Position and Present Velocity you need
to modify the data length accordingly.
-
Data can be read by entering the data type as shown on the example below.
unsigned char
data[8];
dxl_read(Port, ID, P_PRESENT_POSITION, 8, data, &ErrorStatus);
int
present_position, present_velocity;
present_position=DXL_MAKEDWORD(DXL_MAKEWORD(data[0],data[1]),DXL_MAKEWORD(da
ta[2],data[3]));
present_velocity=DXL_MAKEDWORD(DXL_MAKEWORD(data[4],data[5]),DXL_MAKEWORD(da
ta[6],data[7]) );
-
The
position and velocity with DXL_MAKEWORD, DXL_MAKEDWORD (refer to the
source code above).
-
The program's entire source code is shown below.
main.cpp
#include
<stdio.h>
#include
<conio.h>
#include
"dynamixel.h"
#define
COM_PORT_NUM
#define
BAUD_RATE_NUM
#define
P_OPERATING_MODE
#define
P_TORQUE_ENABLE
#define
P_GOAL_POSITION
#define
P_GOAL_VELOCITY
#define
P_PRESENT_POSITION
#define
P_PRESENT_VELOCITY
#define
ID
// Print error bit of status packet
void PrintErrorCode(int
{
if(ErrorCode & ERRBIT_VOLTAGE)
printf("Input voltage
have
gone
over
type array data obtained is converted into the present
unsigned char
17
3
11
562
596
600
611
615
1
ErrorCode)
error!\n");
dxl_read_byte,
//Comport Number of USB2DXL
//Baudrate Number of Dynamixel PRO
//Address of Operation Mode in Control Table
//Address of Torque Enable in Control Table
//Address of Goal Position in Control Table
//Address of Goal Velocity in Control Table
//Address of Present Position in Control Table
//Address of Present Velocity in Control Table
//ID of Dynamixel PRO you use
dxl_read_word,
Page 72 / 139
and
Need help?
Do you have a question about the Dynamixel Pro and is the answer not in the manual?
Questions and answers