Using Arduino with ROS

Hi, seem to be getting an error message a with regards to storage when i compile my arduino, the error i get is ''Low memory available, stability problems may occur"

code:`#include "torquemeter.h"
#include "motor.h"
#include "brake.h"

#define roboclawRxPin1 9
#define roboclawTxPin1 8
#define roboclawRxPin2 11
#define roboclawTxPin2 10

ros::NodeHandle nh;

std_msgs::Float32 torque_msg1;
std_msgs::Float32 torque_msg2;
ros::Publisher pub_torque1("pub_torque1", &torque_msg1);
ros::Publisher pub_torque2("pub_torque2", &torque_msg2);

int sensorPin0 = A0;
int sensorPin1 = A1;
float torqueValueR1 = 0.0;
float torqueValueR2 = 0.0;

torqueread myTrqRead1(sensorPin0);
torqueread myTrqRead2(sensorPin1);

Motor *myMotor1;
Motor *myMotor2;
Brake *myBrake1;
Brake *myBrake2;

void torqueCallback1(const std_msgs::Float32& msg) {
torqueValueR1 = msg.data;
}

void torqueCallback2(const std_msgs::Float32& msg) {
torqueValueR2 = msg.data;
}

ros::Subscriber<std_msgs::Float32> sub_torque1("torque_values_1", &torqueCallback1);
ros::Subscriber<std_msgs::Float32> sub_torque2("torque_values_2", &torqueCallback2);

void setup() {
Serial.begin(115200);
nh.getHardware()->setBaud(9600);
nh.initNode();
nh.advertise(pub_torque1);
nh.advertise(pub_torque2);
nh.subscribe(sub_torque1);
nh.subscribe(sub_torque2);

myMotor1 = new Motor(roboclawRxPin1, roboclawTxPin1);
myMotor2 = new Motor(roboclawRxPin2, roboclawTxPin2);
myBrake1 = new Brake(roboclawRxPin1, roboclawTxPin1);
myBrake2 = new Brake(roboclawRxPin2, roboclawTxPin2);

// Initialize your hardware, motors, and brakes here

// Start motors at a specific speed (example: 50)
myMotor1->MotorSpeed(50);
myMotor2->MotorSpeed(50);

// Apply brakes if needed
myBrake1->applyBrake(0); // Example: 0 for no brake
myBrake2->applyBrake(0); // Example: 0 for no brake
}

void loop() {
torqueR1();
torque_msg1.data = torqueValueR1;
pub_torque1.publish(&torque_msg1);

delay(1000);

torqueR2();
torque_msg2.data = torqueValueR2;
pub_torque2.publish(&torque_msg2);

delay(1000);

// Your original loop code here

nh.spinOnce();
}

void torqueR1() {
torqueValueR1 = myTrqRead1.Read();
}

void torqueR2() {
torqueValueR2 = myTrqRead2.Read();
}

`

What you showed is a warning, not an error.
What happens when you run the code?

Please use code tags when posting code, and post the full message.

Which arduino?

the arduino is uno 3

Try arduino mega.

alright i would place a order for one. Also the arduino all of a sudden has stopped working and gives me the error below even when i try to upload a simple LED blinker code.

Arduino: 1.8.19 (Linux), Board: "Arduino Uno"

Sketch uses 9038 bytes (28%) of program storage space. Maximum is 32256 bytes.
Global variables use 1362 bytes (66%) of dynamic memory, leaving 686 bytes for local variables. Maximum is 2048 bytes.
avrdude: verification error, first mismatch at byte 0x0000
         0x62 != 0x0c
avrdude: verification error; content mismatch
avrdude: verification error; content mismatch



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.