[Dynamixel] CONTROLLING Dynamixel MX106R Servo with Dynamixel shield

Im struggling to get the Dynamixel servos to respond to the data sent via serial port, but when I manually generate random angles inside the loop the motor responds:

#include <DynamixelShield.h>

#if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_MEGA2560)
#include <SoftwareSerial.h>
SoftwareSerial soft_serial(7, 8); // DYNAMIXELShield UART RX/TX
#define DEBUG_SERIAL soft_serial
#elif defined(ARDUINO_SAM_DUE) || defined(ARDUINO_SAM_ZERO)
#define DEBUG_SERIAL SerialUSB
#else
#define DEBUG_SERIAL Serial
#endif

//Please see eManual Control Table section of your DYNAMIXEL.
//This example is written for DYNAMIXEL AX & MX series with Protocol 1.0.
//For MX 2.0 with Protocol 2.0, refer to write_x.ino example.
#define CW_ANGLE_LIMIT_ADDR 6
#define CCW_ANGLE_LIMIT_ADDR 8
#define ANGLE_LIMIT_ADDR_LEN 2
#define OPERATING_MODE_ADDR_LEN 2
#define TORQUE_ENABLE_ADDR 24
#define TORQUE_ENABLE_ADDR_LEN 1
#define LED_ADDR 25
#define LED_ADDR_LEN 1
#define GOAL_POSITION_ADDR 30
#define GOAL_POSITION_ADDR_LEN 2
#define PRESENT_POSITION_ADDR 36
#define PRESENT_POSITION_ADDR_LEN 2
#define TIMEOUT 10 //default communication timeout 10ms

uint8_t turn_on = 1;
uint8_t turn_off = 0;

const uint8_t DXL_ID = 3;
const float DXL_PROTOCOL_VERSION = 1.0;

uint16_t goalPosition1 = 512;
uint16_t goalPosition2 = 1023;

DynamixelShield dxl;

void setup() {
// put your setup code here, to run once:

// For Uno, Nano, Mini, and Mega, use UART port of DYNAMIXEL Shield to debug.
DEBUG_SERIAL.begin(115200); //Set debugging port baudrate to 115200bps
while(!DEBUG_SERIAL); //Wait until the serial port for terminal is opened

// Set Port baudrate to 57600bps. This has to match with DYNAMIXEL baudrate.
dxl.begin(57600);
// Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);

// Turn off torque when configuring items in EEPROM area
if(dxl.write(DXL_ID, TORQUE_ENABLE_ADDR, (uint8_t*)&turn_off , TORQUE_ENABLE_ADDR_LEN, TIMEOUT))
DEBUG_SERIAL.println("DYNAMIXEL Torque off");
else
DEBUG_SERIAL.println("Error: Torque off failed");

// Set to Joint Mode
if(dxl.write(DXL_ID, CW_ANGLE_LIMIT_ADDR, (uint8_t*)&goalPosition1, ANGLE_LIMIT_ADDR_LEN, TIMEOUT)
&& dxl.write(DXL_ID, CCW_ANGLE_LIMIT_ADDR, (uint8_t*)&goalPosition2, ANGLE_LIMIT_ADDR_LEN, TIMEOUT))
DEBUG_SERIAL.println("Set operating mode");
else
DEBUG_SERIAL.println("Error: Set operating mode failed");

// Turn on torque
if(dxl.write(DXL_ID, TORQUE_ENABLE_ADDR, (uint8_t*)&turn_on, TORQUE_ENABLE_ADDR_LEN, TIMEOUT))
DEBUG_SERIAL.println("Torque on");
else
DEBUG_SERIAL.println("Error: Torque on failed");


dxl.write(DXL_ID, GOAL_POSITION_ADDR, (uint8_t*)&goalPosition1, GOAL_POSITION_ADDR_LEN, TIMEOUT);

}



void loop() {
// put your main code here, to run repeatedly:


int goalPosition1 = random(0, 181);

dxl.write(DXL_ID, GOAL_POSITION_ADDR, (uint8_t*)&goalPosition1, GOAL_POSITION_ADDR_LEN, TIMEOUT);
delay(500);


}

but when I try to get those numbers or continuously changing angles from my python code via serial port the motors dont respond even though Arduino shows that data is being received, the motors are connected to Dynamixel shield ,using 4pin RS485 cables ,which is stacked onto on an Arduino board:

/*******************************************************************************
* Copyright 2016 ROBOTIS CO., LTD.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#include <DynamixelShield.h>
#include <Dynamixel2Arduino.h>

#if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_MEGA2560)
  #include <SoftwareSerial.h>
  SoftwareSerial soft_serial(7, 8); // DYNAMIXELShield UART RX/TX
  #define DEBUG_SERIAL soft_serial
#elif defined(ARDUINO_SAM_DUE) || defined(ARDUINO_SAM_ZERO)
  #define DEBUG_SERIAL SerialUSB    
#else
  #define DEBUG_SERIAL Serial
#endif

DynamixelShield dxl;

const uint8_t DXL_ID = 3;
const float DXL_PROTOCOL_VERSION = 1.0;


//This namespace is required to use Control table item names
using namespace ControlTableItem;

void setup() {
  // put your setup code here, to run once:
  
  // For Uno, Nano, Mini, and Mega, use UART port of DYNAMIXEL Shield to debug.
  DEBUG_SERIAL.begin(115200);

  Serial.begin(57600);
  // Set Port baudrate to 57600bps. This has to match with DYNAMIXEL baudrate.
  dxl.begin(57600);
  // Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
  dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);
  // Get DYNAMIXEL information
  dxl.ping(DXL_ID);

  // Turn off torque when configuring items in EEPROM area
  dxl.torqueOff(DXL_ID);
  dxl.setOperatingMode(DXL_ID, OP_POSITION);
  dxl.torqueOn(DXL_ID);
}

void loop() {
  // put your main code here, to run repeatedly:
   if (Serial.available()> 0) {
     
      int goalPosition1 = Serial.parseFloat();
  // Please refer to e-Manual(http://emanual.robotis.com/docs/en/parts/interface/dynamixel_shield/) for available range of value. 
  // Set Goal Position in RAW value
//  dxl.setGoalPosition(DXL_ID, 512);
  //delay(1000);
  // Print present position in raw value
  //DEBUG_SERIAL.print("Present Position(raw) : ");
  //DEBUG_SERIAL.println(dxl.getPresentPosition(DXL_ID));
  //delay(1000);

  // Set Goal Position in DEGREE value
  dxl.setGoalPosition(DXL_ID,goalPosition1, UNIT_DEGREE);
   }
  // Print present position in degree value
  //DEBUG_SERIAL.print("Present Position(degree) : ");
  //DEBUG_SERIAL.println(dxl.getPresentPosition(DXL_ID, UNIT_DEGREE));
  //delay(1000);
}

Please help, what may be the problem for regarding the serial communication?

Dera @Bakanium

In regards to the issue you’re experiencing, please note that we are not experts in Dynamixel servo and have not worked with it before. Therefore, we are unable to provide guidance on this matter.
Apologies for any inconvenience caused.