Hi,
I have ESP32 programmed to talk to ROS. ROS subscribes to encoder data from Arduino. I am using the below integer type.
#include <std_msgs/Int32.h>
std_msgs::Int32 encoder_msg
On the Arduino side, I have an encoder count is an array or type 'long'. When I use the below statement on Arduino, it throws an error.
encoder_msg = (int32_t)pos[0];
no match for 'operator=' (operand types are 'std_msgs::Int32' and 'int32_t' {aka 'int'})
Can someone please help out in getting these messages out? I tried type casting to (std_msgs::Int32), but it does not seem to work.
gcjr
September 22, 2022, 12:41pm
2
praveen_khm:
encoder_msg_fl
where is encoder_msg_f1 defined (i.e. what is it)?
praveen_khm:
encoder_msg
Typo. Its
encoder_msg
I have corrected in the original post.
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
On the Arduino Uno (and other ATmega based boards) an int stores a 16-bit (2-byte) value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1).
I am not sure what you mean by accessing it. This is what the deceleration is. Isnt long same as Int32?
class Int32 : public ros::Msg
{
public:
typedef int32_t _data_type;
_data_type data;
Int32():
data(0)
{
}
@gcjr , its defined here:
std_msgs::Int32 encoder_msg
@Idahowalker , I am using Int32 which is as per my assumption long.
encoder_msg.data = (int32_t)pos[0];
Perfect. It worked. Thank you. It compiles well.
system
Closed
March 21, 2023, 3:20pm
10
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.