publishing int variable
Hello,
I want to publish a variable, called targetIdx (type int), but I always get an error message
That's an extract of my publisher:
std_msgs::Int32 targetIdx;
targetIdx.data = targetIdx;
Sensor_Target_Nr_pub.publish(targetIdx);
ROS_INFO("Sensor Target Nr: %d", targetIdx.data);
That's the error message:
cannot convert ‘std_msgs::Int32’ to ‘std_msgs::Int32_<std::allocator<void> >::_data_type {aka int}’ in assignment
targetIdx.data = targetIdx;
How can I solve the problem?
Thanks
I have declared the variable targetIdx as type int in the beginning of my program.