can't convert uint8 to uint8 to republish a field from a message.
This might sound like a really silly question but I've been trying to figure out the answer for the last two hours. :(
I have a Message that includes a uint8
field. In the callback that receives that message, I need to republish it after performing a calculation. I'm using a temporary variable, that is of the same class as the callback message type, and the republished message is a simple std_msgs::UInt8.
nxt::LegoNXTROS_Status currStatus;
void statusCallBack(const nxt::LegoNXTROS_Status::ConstPtr& msg) {
currStatus.leftMotorEncoder = msg->leftMotorEncoder;
currStatus.rightMotorEncoder = msg->rightMotorEncoder;
currStatus.sonarSensor = msg->sonarSensor;
currStatus.leftTouchSensor = msg->leftTouchSensor;
currStatus.rightTouchSensor = msg->rightTouchSensor;
std_msgs::UInt8 perturbedmsg = currStatus.sonarSensor; <<ERROR HERE
pWhiteNoiseAdder.publish(perturbedmsg);
}
sWhiteNoiseAdder = nWhiteNoiseAdder.subscribe("LegoNXTROS_Status", 1000, statusCallBack);
pWhiteNoiseAdder = nWhiteNoiseAdder.advertise<std_msgs::UInt8>("PerturbedSonar",10);
Message Definition below:
# LegoNXTROS_Status message
# Defines the protocol for publishing the NXT robot's status.
#
uint16 leftMotorEncoder
uint16 rightMotorEncoder
uint8 sonarSensor
bool leftTouchSensor
bool rightTouchSensor
Could someone please help me through this?
Cheers,
Nap