Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

the Problem is the oder of the instrucktions.

if you change your loop to `void loop() {

if (sensor.changed() || force_sensors) {
    bool_msg.data = sensor.get();
    sensor_publisher.publish(&bool_msg);
    force_sensors = false;
}

nh.spinOnce();
delay(1);

}`

or

`void loop() {

if (sensor.changed() || force_sensors) {
    bool_msg.data = sensor.get();
    sensor_publisher.publish(&bool_msg);

}
force_sensors = false;
nh.spinOnce();
delay(1);

}`

the Reson is that the var force_sensors is updatet in nh.spinOnce() and just after that you resett it

the Problem is the oder of the instrucktions.

if you change your loop to `void loop() {

if (sensor.changed() || force_sensors) {
    bool_msg.data = sensor.get();
    sensor_publisher.publish(&bool_msg);
    force_sensors = false;
}

nh.spinOnce();
delay(1);
}

}`

or

`void loop() {

if (sensor.changed() || force_sensors) {
    bool_msg.data = sensor.get();
    sensor_publisher.publish(&bool_msg);

}
force_sensors = false;
nh.spinOnce();
delay(1);
}

}`

the Reson is that the var force_sensors is updatet in nh.spinOnce() and just after that you resett it