Communication between Arduino and Raspberry pi

Hey !
So, we’re trying to run the thrusters using an Arduino Mega 2560.
We have connected a Joystick to the Laptop, and the Laptop is connected to a Raspberry pi using an ethernet cable, and the rapsberry pi and the Arduino are connected by the Arduino’s cable itself.
We are sending data through the ser.write(str().encode) command into the Arduino. We are have tried two approaches.

  1. Directly sending joystick commands into the Arduino
  2. Assigning an integer to a specific joystick value (i.e. if command is forward, number 2 will be sent to the Arduino which will turn on the thrusters which are related to Forward motion).

We are able to see the joystick commands in the Arduino, but we have a few problems

  1. We see a significant delay in the output of the Arduino
  2. If we are assigning integer values and then converting them into strings before sending them to the Arduino, we are noticing a huge delay and if we are assigning float values and then converting them into strings before sending them into the Arduino, we are noticing random values in the output of the Arduino.