Brushless rc car getting mixed, ESC and motor, values from nRF24L01

Hi, can you please help me set up my arduino project.
I'm trying to control a brushless motor rc car, with processing, trough two arduino unos and two nRF24L01 modules.

The processing part works, it sends slider values to a serial port.
Processing code:

import controlP5.*;
import processing.serial.*;

ControlP5 cp5;
Serial myPort;

int x=0, y=0;

void setup()
{
  size(600, 275);
  cp5 = new ControlP5(this);
  myPort = new Serial(this, Serial.list()[0], 9600);
  rectMode(CENTER);
  noFill();
  stroke(255);

  addSliders();
}

void draw() {
  background(200);
  
  myPort.write(x + ";" + y + ";");
  circle(width/2+x*2.195-198, 65, 20);
  rect(100+y*1.1, 145, y*2.2, 20);
}

void addSliders(){
 cp5.addSlider("x")
     .setBroadcast(false)
     .setPosition(100, 80)
     .setSize(400, 15)
     .setRange(0, 180)
     .setValue(90)
     .setLabel("servo")
     .setSliderMode(Slider.FLEXIBLE)
     .setBroadcast(true)
     .getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0).setFont(createFont("Arial", 12)).toUpperCase(false).setColor(0)
     ;

cp5.addSlider("y")
     .setBroadcast(false)
     .setPosition(100, 160)
     .setSize(400, 15)
     .setRange(0, 180)
     .setValue(90)
     .setLabel("motor")
     .setSliderMode(Slider.FLEXIBLE)
     .setBroadcast(true)
     .getCaptionLabel().align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0).setFont(createFont("Arial", 12)).toUpperCase(false).setColor(0)
     ;
}

And when I connect an arduino directly (without an nRF24L01 module, but with a usb) to a computer, it also works

Servo and Motor control, trough a serial port (with data sent from processing):

#include <Servo.h>
#include "ESC.h"

#define SPEED_MIN (1000)                             
#define SPEED_MAX (2000)                                 
int arming=1500;
ESC myESC (5, SPEED_MIN, SPEED_MAX, arming);             
int oESC; 
Servo cmar;
int x, y;

void setup() {
  Serial.begin(9600);
  pinMode(3, OUTPUT);
  pinMode(10, OUTPUT);
  int newData = false;
  
  cmar.attach(9);

  myESC.arm();                                           
  delay(100);
  myESC.speed(arming);
}

void loop() {
  receiveData();
  
  int x1=map(x,0,180,0,255);
    analogWrite(10, x1);
  int x2=map(y,0,180,1000,2000);
 
  myESC.speed(x2);

  int y1=map(y,0,180,0,255);
    analogWrite(3, y1);
  
  cmar.write(map(x,0,180,50,130));
}

void receiveData() {
  if (Serial.available() > 0) {
    x = Serial.parseInt();
    y = Serial.parseInt();
    Serial.read();
  }
}

And now for the nRF24L01 part, it's okay if I send either the servo value or the motor value, but if I send both at the same time I get mixed signals.

Transmitter:

#include <SPI.h>  
#include "RF24.h"

RF24 myRadio (7, 8);

int x, y;

struct package
{
  int msg = 0;
  int motor = 0;
};

byte addresses[][6] = {"0"};

typedef struct package Package;
Package data;

void setup()
{
  Serial.begin(9600);
  myRadio.begin();  
  myRadio.setChannel(115); 
  myRadio.setPALevel(RF24_PA_MAX);
  myRadio.setDataRate( RF24_250KBPS ) ;  
  delay(10);
  Serial.print("Setup Initialized");
}

void loop()
{
  receiveData();
  
  char servo_value =  x  ;    
  char motor_value =  y  ;
    if (servo_value>1)
    data.msg = servo_value;
    data.motor = motor_value;
    WriteData();
    delay(10);
}

void WriteData()
{
  myRadio.stopListening();   
  myRadio.openWritingPipe( 0xF0F0F0F0AA); 
  myRadio.write(&data, sizeof(data)); 
Serial.print("\nSent:");
  Serial.println(data.msg);
  delay(10);
}

void ReadData()
{ 
myRadio.openReadingPipe(1, 0xF0F0F0F066); 
  myRadio.startListening();
  if ( myRadio.available()) 
  {
    while (myRadio.available())
    {
      myRadio.read( &data, sizeof(data) );
    }
    Serial.print("\nReceived:");
    Serial.println(data.msg);
  }
}


void receiveData() {
  if (Serial.available() > 0) {
    x = Serial.parseInt();
    y = Serial.parseInt();
    Serial.read();
  }
}

Receiver:

#include <SPI.h>  
#include "RF24.h" 
#include <Servo.h>
#include "ESC.h"

#define SPEED_MIN (1000)                                  
#define SPEED_MAX (2000)                                 
int arming=1500;
ESC myESC (5, SPEED_MIN, SPEED_MAX, arming);               
int oESC;
Servo myservo;


RF24 myRadio (7, 8); 

struct package
{
  int msg;
  int motor;
};
typedef struct package Package;
Package data;

byte addresses[][6] = {"0"}; 

void setup() 
{
  Serial.begin(9600);
  myRadio.begin(); 
  myRadio.setChannel(115); 
  myRadio.setPALevel(RF24_PA_MAX);  
  myRadio.setDataRate( RF24_250KBPS ) ;  

  pinMode(10, OUTPUT);
  
  myservo.attach(9);
  
  myESC.arm();                                           
  delay(10);
  myESC.speed(arming);
  
  Serial.print("Setup Initialized");
  delay(10);
}

int Servo_value;
int Pev_servo_value;
int Pev_motor_value;
int motor_value;

void loop()  
{
  ReadData();
  delay(50);
  
  Pev_servo_value = Servo_value;
  Servo_value = data.msg; 
  int x2=map(data.msg,0,180,1000,2000);
 
  myESC.speed(x2);
  myservo.write(Servo_value);
}

void ReadData()
{
  myRadio.openReadingPipe(1, 0xF0F0F0F0AA); 
  myRadio.startListening();  

  if ( myRadio.available()) 
  {
    while (myRadio.available())
    {
      myRadio.read( &data, sizeof(data) );
    }
    Serial.print("\nReceived:");
    Serial.println(data.msg);
  }
}

void WriteData()
{
  myRadio.stopListening(); 
  myRadio.openWritingPipe(0xF0F0F0F066);
  myRadio.write(&data, sizeof(data)); 
  Serial.print("\nSent:");
  Serial.println(data.msg);
  delay(10);
}

The code is a mix of multiple codes so there might be some redundant code and I'm sorry if I missed some valuable information, here is a video of the car when I try to send both the servo and the motor value:

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

...R

struct package
{
  int msg = 0;
  int motor = 0;
};

byte addresses[][6] = {"0"};

typedef struct package Package;
Package data;

This looks very odd. You define a struct named package then use it to define a struct of type package named Package which is in turn used to define a struct named data

When I used a struct to send data using RF24 this is the struct definition that I used

struct data
{
  byte pinState;
  byte temperature;
} dataToSend;

After populating the struct with data it was sent like this

  txResult = radio.write( &dataToSend, sizeof(dataToSend) );

The struct was defined in a similar way on the Rx side and received like this

    radio.read( &dataReceived, sizeof(dataReceived) );

I can't remember now but the code I used was almost certainly based on Robin's examples that he linked to. Have a look at them

UKHeliBob:
When I used a struct to send data using RF24 this is the struct definition that I used

struct data

{
  byte pinState;
  byte temperature;
} dataToSend;

I like to create a struct in two stages like this

struct DataStruct
{
  byte pinState;
  byte temperature;
};

DataStruct dataToSend;

because I find it reduces confusion between the name of the struct definition and the name of the instance of the struct. And the line DataStruct dataToSend; is syntactically similar to the familiar int myInt;

I agree with the rest of your Reply #2

...R

I like to create a struct in two stages like this

I know what you mean. I suspect that I was experimenting with structs as well as RF24 at the same time (Don't try this at home children)

Actually, although the typedef keyword is not needed in C++ it makes what you are doing even clearer. Something like

typedef struct theData
{
  char theText[10] = "some text";
  int theInt = 1234;
  byte theByte = 123;
};

theData outData;