Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid typedefs from idl #58

Merged
merged 2 commits into from Mar 21, 2023
Merged

Avoid typedefs from idl #58

merged 2 commits into from Mar 21, 2023

Conversation

Acuadros95
Copy link
Contributor

Related to #57

@Ryanf55
Copy link
Contributor

Ryanf55 commented Mar 13, 2023

This still isn't passing the generator.

ryan@ryan-B650:~/Development/ardu_ws/src/Micro-XRCE-DDS-Gen$ microxrceddsgen NavSatFix.idl 
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)
Loading templates...
Processing the file NavSatFix.idl...
WARNING (File NavSatFix, Line 41): Annotation unit not supported. Ignoring...
WARNING (File NavSatFix, Line 46): Annotation unit not supported. Ignoring...
WARNING (File NavSatFix, Line 52): Annotation unit not supported. Ignoring...
WARNING (File NavSatFix, Line 61): Annotation unit not supported. Ignoring...
ERROR: Can't get property cTypename using method get/isCTypename from com.eprosima.idl.parser.typecode.PrimitiveTypeCode instance
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.antlr.stringtemplate.language.ASTExpr.invokeMethod(ASTExpr.java:563)
        at org.antlr.stringtemplate.language.ASTExpr.rawGetObjectProperty(ASTExpr.java:514)
        at org.antlr.stringtemplate.language.ASTExpr.getObjectProperty(ASTExpr.java:416)
        at org.antlr.stringtemplate.language.ActionEvaluator.attribute(ActionEvaluator.java:351)
        at org.antlr.stringtemplate.language.ActionEvaluator.expr(ActionEvaluator.java:136)
        at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:84)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.language.ConditionalExpr.write(ConditionalExpr.java:126)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:722)
        at org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:659)
        at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:722)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:742)
        at org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:659)
        at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1635)
        at org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1626)
        at com.eprosima.idl.generator.manager.TemplateGroup.setAttribute(TemplateGroup.java:90)
        at com.eprosima.idl.parser.grammar.IDLParser.definition_list(IDLParser.java:833)
        at com.eprosima.idl.parser.grammar.IDLParser.module(IDLParser.java:748)
        at com.eprosima.idl.parser.grammar.IDLParser.definition(IDLParser.java:517)
        at com.eprosima.idl.parser.grammar.IDLParser.definition_list(IDLParser.java:817)
        at com.eprosima.idl.parser.grammar.IDLParser.module(IDLParser.java:748)
        at com.eprosima.idl.parser.grammar.IDLParser.definition(IDLParser.java:517)
        at com.eprosima.idl.parser.grammar.IDLParser.specification(IDLParser.java:334)
        at com.eprosima.uxr.microxrceddsgen.parseIDL(microxrceddsgen.java:327)
        at com.eprosima.uxr.microxrceddsgen.process(microxrceddsgen.java:264)
        at com.eprosima.uxr.microxrceddsgen.execute(microxrceddsgen.java:179)
        at com.eprosima.uxr.microxrceddsgen.main(microxrceddsgen.java:518)
Caused by: java.lang.IllegalArgumentException: Can't find template type_1e.st; group hierarchy is [Types]
        at org.antlr.stringtemplate.StringTemplateGroup.lookupTemplate(StringTemplateGroup.java:507)
        at org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:392)
        at org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:404)
        at com.eprosima.idl.parser.typecode.TypeCode.getCTypenameFromStringTemplate(TypeCode.java:71)
        at com.eprosima.idl.parser.typecode.PrimitiveTypeCode.getCTypename(PrimitiveTypeCode.java:36)
        ... 39 more
ERROR: Can't get property cTypename using method get/isCTypename from com.eprosima.idl.parser.typecode.PrimitiveTypeCode instance
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.antlr.stringtemplate.language.ASTExpr.invokeMethod(ASTExpr.java:563)
        at org.antlr.stringtemplate.language.ASTExpr.rawGetObjectProperty(ASTExpr.java:514)
        at org.antlr.stringtemplate.language.ASTExpr.getObjectProperty(ASTExpr.java:416)
        at org.antlr.stringtemplate.language.ActionEvaluator.attribute(ActionEvaluator.java:351)
        at org.antlr.stringtemplate.language.ActionEvaluator.expr(ActionEvaluator.java:136)
        at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:84)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.language.ConditionalExpr.writeSubTemplate(ConditionalExpr.java:152)
        at org.antlr.stringtemplate.language.ConditionalExpr.write(ConditionalExpr.java:113)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:722)
        at org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:659)
        at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:722)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:742)
        at org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:659)
        at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1635)
        at org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1626)
        at com.eprosima.idl.generator.manager.TemplateGroup.setAttribute(TemplateGroup.java:90)
        at com.eprosima.idl.parser.grammar.IDLParser.definition_list(IDLParser.java:833)
        at com.eprosima.idl.parser.grammar.IDLParser.module(IDLParser.java:748)
        at com.eprosima.idl.parser.grammar.IDLParser.definition(IDLParser.java:517)
        at com.eprosima.idl.parser.grammar.IDLParser.definition_list(IDLParser.java:817)
        at com.eprosima.idl.parser.grammar.IDLParser.module(IDLParser.java:748)
        at com.eprosima.idl.parser.grammar.IDLParser.definition(IDLParser.java:517)
        at com.eprosima.idl.parser.grammar.IDLParser.specification(IDLParser.java:334)
        at com.eprosima.uxr.microxrceddsgen.parseIDL(microxrceddsgen.java:327)
        at com.eprosima.uxr.microxrceddsgen.process(microxrceddsgen.java:264)
        at com.eprosima.uxr.microxrceddsgen.execute(microxrceddsgen.java:179)
        at com.eprosima.uxr.microxrceddsgen.main(microxrceddsgen.java:518)
Caused by: java.lang.NullPointerException
        at com.eprosima.idl.parser.typecode.PrimitiveTypeCode.getCTypename(PrimitiveTypeCode.java:36)
        ... 40 more
ERROR: Can't get property cTypename using method get/isCTypename from com.eprosima.idl.parser.typecode.PrimitiveTypeCode instance
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.antlr.stringtemplate.language.ASTExpr.invokeMethod(ASTExpr.java:563)
        at org.antlr.stringtemplate.language.ASTExpr.rawGetObjectProperty(ASTExpr.java:514)
        at org.antlr.stringtemplate.language.ASTExpr.getObjectProperty(ASTExpr.java:416)
        at org.antlr.stringtemplate.language.ActionEvaluator.attribute(ActionEvaluator.java:351)
        at org.antlr.stringtemplate.language.ActionEvaluator.expr(ActionEvaluator.java:136)
        at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:84)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.language.ConditionalExpr.writeSubTemplate(ConditionalExpr.java:152)
        at org.antlr.stringtemplate.language.ConditionalExpr.write(ConditionalExpr.java:113)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:722)
        at org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:659)
        at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:722)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:742)
        at org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:659)
        at org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
        at org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
        at org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
        at org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1635)
        at org.antlr.stringtemplate.StringTemplate.toString(StringTemplate.java:1626)
        at com.eprosima.idl.generator.manager.TemplateGroup.setAttribute(TemplateGroup.java:90)
        at com.eprosima.idl.parser.grammar.IDLParser.definition_list(IDLParser.java:833)
        at com.eprosima.idl.parser.grammar.IDLParser.module(IDLParser.java:748)
        at com.eprosima.idl.parser.grammar.IDLParser.definition(IDLParser.java:517)
        at com.eprosima.idl.parser.grammar.IDLParser.definition_list(IDLParser.java:817)
        at com.eprosima.idl.parser.grammar.IDLParser.module(IDLParser.java:748)
        at com.eprosima.idl.parser.grammar.IDLParser.definition(IDLParser.java:517)
        at com.eprosima.idl.parser.grammar.IDLParser.specification(IDLParser.java:334)
        at com.eprosima.uxr.microxrceddsgen.parseIDL(microxrceddsgen.java:327)
        at com.eprosima.uxr.microxrceddsgen.process(microxrceddsgen.java:264)
        at com.eprosima.uxr.microxrceddsgen.execute(microxrceddsgen.java:179)
        at com.eprosima.uxr.microxrceddsgen.main(microxrceddsgen.java:518)
Caused by: java.lang.NullPointerException
        at com.eprosima.idl.parser.typecode.PrimitiveTypeCode.getCTypename(PrimitiveTypeCode.java:36)
        ... 40 more
Generating Type definition files...
ryan@ryan-B650:~/Development/ardu_ws/src/Micro-XRCE-DDS-Gen$ git log -n 1
commit e0b8bdcff3cdf153e3f2e2984064fce9df1c0e19 (HEAD -> fix/typedefs, origin/fix/typedefs)
Author: acuadros95 <acuadros1995@gmail.com>
Date:   Mon Mar 13 12:23:27 2023 +0100

    Avoid typedef definitions
    
    Signed-off-by: acuadros95 <acuadros1995@gmail.com>

NavSatFix.idl (only change is the include directive)

// generated from rosidl_adapter/resource/msg.idl.em
// with input from sensor_msgs/msg/NavSatFix.msg
// generated code does not contain a copyright notice

#include "NavSatStatus.idl"
#include "Header.idl"

module sensor_msgs {
  module msg {
    typedef double double__9[9];
    module NavSatFix_Constants {
      @verbatim (language="comment", text=
        "If the covariance of the fix is known, fill it in completely. If the" "\n"        "GPS receiver provides the variance of each measurement, put them" "\n"        "along the diagonal. If only Dilution of Precision is available," "\n"        "estimate an approximate covariance from that.")
      const uint8 COVARIANCE_TYPE_UNKNOWN = 0;
      const uint8 COVARIANCE_TYPE_APPROXIMATED = 1;
      const uint8 COVARIANCE_TYPE_DIAGONAL_KNOWN = 2;
      const uint8 COVARIANCE_TYPE_KNOWN = 3;
    };
    @verbatim (language="comment", text=
      "Navigation Satellite fix for any Global Navigation Satellite System" "\n"
      "" "\n"
      "Specified using the WGS 84 reference ellipsoid")
    struct NavSatFix {
      @verbatim (language="comment", text=
        "header.stamp specifies the ROS time for this measurement (the" "\n"
        "       corresponding satellite time may be reported using the" "\n"
        "       sensor_msgs/TimeReference message)." "\n"
        "" "\n"
        "header.frame_id is the frame of reference reported by the satellite" "\n"
        "       receiver, usually the location of the antenna.  This is a" "\n"
        "       Euclidean frame relative to the vehicle, not a reference" "\n"
        "       ellipsoid.")
      std_msgs::msg::Header header;

      @verbatim (language="comment", text=
        "Satellite fix status information.")
      sensor_msgs::msg::NavSatStatus status;

      @verbatim (language="comment", text=
        "Latitude. Positive is north of equator; negative is south.")
      @unit (value="degrees")
      double latitude;

      @verbatim (language="comment", text=
        "Longitude. Positive is east of prime meridian; negative is west.")
      @unit (value="degrees")
      double longitude;

      @verbatim (language="comment", text=
        "Altitude. Positive is above the WGS 84 ellipsoid" "\n"
        "(quiet NaN if no altitude is available).")
      @unit (value="m")
      double altitude;

      @verbatim (language="comment", text=
        "Position covariance defined relative to a tangential plane" "\n"
        "through the reported position. The components are East, North, and" "\n"
        "Up (ENU), in row-major order." "\n"
        "" "\n"
        "Beware: this coordinate system exhibits singularities at the poles.")
      @unit (value="m^2")
      double__9 position_covariance;

      uint8 position_covariance_type;
    };
  };
};

Should I modify the IDL to remove the usage of the typedef?

@Acuadros95
Copy link
Contributor Author

Could you share the used idls for NavSatStatus.idl and Header.idl?

Should I modify the IDL to remove the usage of the typedef?

Not really, this PR should fix that part.

@Ryanf55
Copy link
Contributor

Ryanf55 commented Mar 15, 2023

Could you share the used idls for NavSatStatus.idl and Header.idl?

Should I modify the IDL to remove the usage of the typedef?

Not really, this PR should fix that part.

Here you are, sorry for delay. Only change from upstream ROS2 is the include path.

Header

// generated from rosidl_adapter/resource/msg.idl.em
// with input from std_msgs/msg/Header.msg
// generated code does not contain a copyright notice

#include "Time.idl"

module std_msgs {
  module msg {
    @verbatim (language="comment", text=
      "Standard metadata for higher-level stamped data types." "\n"
      "This is generally used to communicate timestamped data" "\n"
      "in a particular coordinate frame.")
    struct Header {
      @verbatim (language="comment", text=
        "Two-integer timestamp that is expressed as seconds and nanoseconds.")
      builtin_interfaces::msg::Time stamp;

      @verbatim (language="comment", text=
        "Transform frame with which this data is associated.")
      string frame_id;
    };
  };
};

Time.idl

// generated from rosidl_adapter/resource/msg.idl.em
// with input from builtin_interfaces/msg/Time.msg
// generated code does not contain a copyright notice


module builtin_interfaces {
  module msg {
    @verbatim (language="comment", text=
      "This message communicates ROS Time defined here:" "\n"
      "https://design.ros2.org/articles/clock_and_time.html")
    struct Time {
      @verbatim (language="comment", text=
        "The seconds component, valid over all int32 values.")
      int32 sec;

      @verbatim (language="comment", text=
        "The nanoseconds component, valid in the range [0, 10e9).")
      uint32 nanosec;
    };
  };
};

NavSatStatus

// generated from rosidl_adapter/resource/msg.idl.em
// with input from sensor_msgs/msg/NavSatStatus.msg
// generated code does not contain a copyright notice


module sensor_msgs {
  module msg {
    module NavSatStatus_Constants {
      @verbatim (language="comment", text=
        "unable to fix position")
      const int8 STATUS_NO_FIX = -1;
      @verbatim (language="comment", text=
        "unaugmented fix")
      const int8 STATUS_FIX = 0;
      @verbatim (language="comment", text=
        "with satellite-based augmentation")
      const int8 STATUS_SBAS_FIX = 1;
      @verbatim (language="comment", text=
        "with ground-based augmentation")
      const int8 STATUS_GBAS_FIX = 2;
      @verbatim (language="comment", text=
        "Bits defining which Global Navigation Satellite System signals were" "\n"        "used by the receiver.")
      const uint16 SERVICE_GPS = 1;
      const uint16 SERVICE_GLONASS = 2;
      @verbatim (language="comment", text=
        "includes BeiDou.")
      const uint16 SERVICE_COMPASS = 4;
      const uint16 SERVICE_GALILEO = 8;
    };
    @verbatim (language="comment", text=
      "Navigation Satellite fix status for any Global Navigation Satellite System." "\n"
      "" "\n"
      "Whether to output an augmented fix is determined by both the fix" "\n"
      "type and the last time differential corrections were received.  A" "\n"
      "fix is valid when status >= STATUS_FIX.")
    struct NavSatStatus {
      int8 status;

      uint16 service;
    };
  };
};

Signed-off-by: acuadros95 <acuadros1995@gmail.com>
Signed-off-by: acuadros95 <acuadros1995@gmail.com>
@Acuadros95
Copy link
Contributor Author

@Ryanf55 give it another go, and check that the IDL-Parser is updated with our latest fix: IDL-Parser @ ac27ead

@Ryanf55
Copy link
Contributor

Ryanf55 commented Mar 16, 2023

@Ryanf55 give it another go, and check that the IDL-Parser is updated with our latest fix: IDL-Parser @ ac27ead

Thanks. Can you rebase on develop to just include the PR that does that? It merged recently, but it's not in your branch yet.

#59

@Acuadros95
Copy link
Contributor Author

@Ryanf55 Already rebased

@Ryanf55
Copy link
Contributor

Ryanf55 commented Mar 17, 2023

@Ryanf55 Already rebased

My bad, just re-tested. LGTM.

Results:

// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
 * @file NavSatFix.h
 * This header file contains the declaration of the described types in the IDL file.
 *
 * This file was generated by the tool gen.
 */

#ifndef _NavSatFix_H_
#define _NavSatFix_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdint.h>
#include <stdbool.h>
#include "Header.h"
#include "NavSatStatus.h"






typedef struct sensor_msgs_msg_NavSatFix
{
    std_msgs_msg_Header header;
    sensor_msgs_msg_NavSatStatus status;
    double latitude;
    double longitude;
    double altitude;
    double position_covariance[9];
    uint8_t position_covariance_type;
} sensor_msgs_msg_NavSatFix;

struct ucdrBuffer;

bool sensor_msgs_msg_NavSatFix_serialize_topic(struct ucdrBuffer* writer, const sensor_msgs_msg_NavSatFix* topic);
bool sensor_msgs_msg_NavSatFix_deserialize_topic(struct ucdrBuffer* reader, sensor_msgs_msg_NavSatFix* topic);
uint32_t sensor_msgs_msg_NavSatFix_size_of_topic(const sensor_msgs_msg_NavSatFix* topic, uint32_t size);


#ifdef __cplusplus
}
#endif

#endif // _NavSatFix_H_

@Acuadros95 Acuadros95 merged commit b7eb112 into develop Mar 21, 2023
3 checks passed
@Acuadros95 Acuadros95 deleted the fix/typedefs branch March 21, 2023 07:02
@Acuadros95 Acuadros95 mentioned this pull request Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants