RobotecAI / ros2-for-unity

High-performance ROS2 solution for Unity3D
Apache License 2.0
446 stars 58 forks source link

Can't set variables of standard ROS2 messages in Ros2ForUnity 1.3.0 on Windows #98

Closed ashchennikov closed 6 months ago

ashchennikov commented 6 months ago

My issue is similar to the #39, however, I don't really understand how to apply the answer there. I use the prebuilt standalone release of Ros2ForUnity on Windows. When I try to do something like this (e.g. set the frame ID to the row number of a lidar scanner):

            for (int i = 0; i < numberRows; i++)
            {
                sensor_msgs.msg.LaserScan msg = new sensor_msgs.msg.LaserScan();
                msg.Header.frame_id = i;
                lidar_pub.Publish(msg);
            }

I get the following error:

'Header' does not contain a definition for 'frame_id' and no accessible extension method 'frame_id' accepting a first argument of type 'Header' could be found (are you missing a using directive or an assembly reference?)

I am pretty sure Header has the frame_id attribute, but I don't understand why it refuses to work. Do I overlook something?

ashchennikov commented 6 months ago

I was being stupid, I guess. msg.Header.Frame_id = i (with capital f) works fine.