ROBOTIS-GIT / DynamixelSDK

ROBOTIS Dynamixel SDK (Protocol1.0/2.0)
http://emanual.robotis.com/docs/en/software/dynamixel/dynamixel_sdk/overview/
Apache License 2.0
454 stars 405 forks source link

`[3.7.21][Python][USB2Dynamixel][XL430-W250-T] Issue: Motor Rotation and float bytearray allocation` #381

Open tahir1069 opened 4 years ago

tahir1069 commented 4 years ago

I have a differential drive robot with 4 active wheels (left_motors ->[1, 3], right_motors -> [2, 4]). I am programming in Python two control motors in velocity control mode. I have following questions:

  1. My motor # 4 rotate opposite to motor # 1. I don't know why as this is not the case with motor # 3 with respect to motor # 1. The motors are daisy chained and the motor # 4 is the last one in the chain (I have changed the motor but the issue is the same).

  2. For writing to Servos a byte array is used of the form [DXL_LOBYTE(DXL_LOWORD(dxl_goal_position)),DXL_HIBYTE(DXL_LOWORD(dxl_goal_position)),DXL_LOBYTE(DXL_HIWORD(dxl_goal_position)),DXL_HIBYTE(DXL_HIWORD(dxl_goal_position))]. This configuration works fine for integers but it is not possible to use this for float. Can you tell me any work around which can resolve this issuse. I have used Python bytearray method as here but this does not resolve the issue.

  3. I really can not understand the differnce between drive mode and operating mode. For me operating mode it is defining the control type of the motor which is obvious but what is drive mode and how it is related to operating mode and also to velocity control mode.

    3.1. If you can point to any example of drive mode, it will really be appreciated.

tahir1069 commented 4 years ago

@ROBOTIS-OFFICIAL can anyone please reply.

Also can you elaborate how to get encoder ticks, I think it can be read from present position. But how to decode this value is what am not able to understand and stuck. Any leads in this regard as well will highly be appreciated.

Thank you so much in advance.

Hello970 commented 3 years ago

Hello, brother, has the second problem been solved? I currently meet the same problem.

ROBOTIS-Will commented 3 years ago

@Hello970 You can only write integer to DYNAMIXEL since all data is integer. https://emanual.robotis.com/docs/en/dxl/x/xl430-w250/#control-table-of-eeprom-area Could you elaborate more about your issue?

ROBOTIS-Will commented 3 years ago

Hi @Hello970

Unfortunately, we do not review users' custom code. Have you tried running the default example included in DYNAMIXEL SDK? https://github.com/ROBOTIS-GIT/DynamixelSDK/blob/master/python/tests/protocol2_0/sync_read_write.py I think first try it and modify from the example might easier for you.

Also, when appending the parameter as below, you should use little endian.

dxl_addparam_result = groupSyncWrite1.addParam(DXL1_ID, str(int(dxl1_goal_position)))

In the above code, str(int(dxl1_goal_position)) is using an incorrect value and you should use something like below to make it little endian

param_goal_position = [DXL_LOBYTE(DXL_LOWORD(dxl1_goal_position)), DXL_HIBYTE(DXL_LOWORD(dxl1_goal_position)), DXL_LOBYTE(DXL_HIWORD(dxl1_goal_position)), DXL_HIBYTE(DXL_HIWORD(dxl1_goal_position))
dxl_addparam_result = groupSyncWrite1.addParam(DXL1_ID, param_goal_position)
Hello970 commented 3 years ago

Dear Sir,

Thanks for your prompt reply.

Yes, I ran the demo in DYNAMIXEL SDK at first. It was OK when I synchronically sent goal position to three motors just in the given position range (for example from 150 ~ 2000). Also, the little endian has been used since the demo gives the similar forms. However, it didn’t work when I modify the goal position according to the real requirement. I gave the error “the float has no len()”. Therefore, I change it into “str(int())”. Although it eliminated the errors about data type, it cased another problem. I will consider effective solutions to solve this problem.

Thank you all the same.

Best regards, Haonan Sun

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用

发件人: Will @.> 发送时间: 2021年5月31日 10:08 收件人: @.> 抄送: SUN @.>; @.> 主题: Re: [ROBOTIS-GIT/DynamixelSDK] [3.7.21][Python][USB2Dynamixel][XL430-W250-T] Issue: Motor Rotation and float bytearray allocation (#381)

Hi @Hello970https://github.com/Hello970

Unfortunately, we do not review users' custom code. Have you tried running the default example included in DYNAMIXEL SDK? https://github.com/ROBOTIS-GIT/DynamixelSDK/blob/master/python/tests/protocol2_0/sync_read_write.py I think first try it and modify from the example might easier for you.

Also, when appending the parameter as below, you should use little endian.

dxl_addparam_result = groupSyncWrite1.addParam(DXL1_ID, str(int(dxl1_goal_position)))

In the above code, str(int(dxl1_goal_position)) is using an incorrect value and you should use something like below to make it little endian

param_goal_position = [DXL_LOBYTE(DXL_LOWORD(dxl1_goal_position)), DXL_HIBYTE(DXL_LOWORD(dxl1_goal_position)), DXL_LOBYTE(DXL_HIWORD(dxl1_goal_position)), DXL_HIBYTE(DXL_HIWORD(dxl1_goal_position))

dxl_addparam_result = groupSyncWrite1.addParam(DXL1_ID, param_goal_position)

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ROBOTIS-GIT/DynamixelSDK/issues/381#issuecomment-851103373, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AN5A5BAXMAFH5ZQMDJ55B73TQLOSBANCNFSM4K3NHMCA.

ROBOTIS-Will commented 3 years ago

It is because you divided angle values with 360 as below.

ini_W_position = ini_W_angle / 360 * 4096 + offset_W # Wheel
ini_C_position = ini_C_angle / 360 * 4096 + offset_C # Carrier
ini_S_position = ini_S_angle / 360 * 4096 + offset_S # Sun gear

You need to convert the output into an integer then apply the little endian format to pass into the addparam() function.

Hello970 commented 3 years ago

Dear Sir,

Thanks for your patience.

According to your guidance, I have successfully solved this problem.

Thank you very much. I would be grateful for your help.

Best regards, Haonan Sun

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用

发件人: SUN @.> 发送时间: 2021年5月31日 10:27 收件人: @.> 主题: 回复: [ROBOTIS-GIT/DynamixelSDK] [3.7.21][Python][USB2Dynamixel][XL430-W250-T] Issue: Motor Rotation and float bytearray allocation (#381)

Dear Sir,

Thanks for your prompt reply.

Yes, I ran the demo in DYNAMIXEL SDK at first. It was OK when I synchronically sent goal position to three motors just in the given position range (for example from 150 ~ 2000). Also, the little endian has been used since the demo gives the similar forms. However, it didn’t work when I modify the goal position according to the real requirement. I gave the error “the float has no len()”. Therefore, I change it into “str(int())”. Although it eliminated the errors about data type, it cased another problem. I will consider effective solutions to solve this problem.

Thank you all the same.

Best regards, Haonan Sun

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用

发件人: Will @.> 发送时间: 2021年5月31日 10:08 收件人: @.> 抄送: SUN @.>; @.> 主题: Re: [ROBOTIS-GIT/DynamixelSDK] [3.7.21][Python][USB2Dynamixel][XL430-W250-T] Issue: Motor Rotation and float bytearray allocation (#381)

Hi @Hello970https://github.com/Hello970

Unfortunately, we do not review users' custom code. Have you tried running the default example included in DYNAMIXEL SDK? https://github.com/ROBOTIS-GIT/DynamixelSDK/blob/master/python/tests/protocol2_0/sync_read_write.py I think first try it and modify from the example might easier for you.

Also, when appending the parameter as below, you should use little endian.

dxl_addparam_result = groupSyncWrite1.addParam(DXL1_ID, str(int(dxl1_goal_position)))

In the above code, str(int(dxl1_goal_position)) is using an incorrect value and you should use something like below to make it little endian

param_goal_position = [DXL_LOBYTE(DXL_LOWORD(dxl1_goal_position)), DXL_HIBYTE(DXL_LOWORD(dxl1_goal_position)), DXL_LOBYTE(DXL_HIWORD(dxl1_goal_position)), DXL_HIBYTE(DXL_HIWORD(dxl1_goal_position))

dxl_addparam_result = groupSyncWrite1.addParam(DXL1_ID, param_goal_position)

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ROBOTIS-GIT/DynamixelSDK/issues/381#issuecomment-851103373, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AN5A5BAXMAFH5ZQMDJ55B73TQLOSBANCNFSM4K3NHMCA.