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

Add Zenoh Pico Examples #107

Open
wants to merge 1 commit into
base: examples
Choose a base branch
from
Open

Conversation

uupks
Copy link

@uupks uupks commented Apr 7, 2024

This add Zenoh Pico examples for:

  • Topics listener
  • Topics talker
  • Services client
  • Services server
  • Actions client
  • Actions server

Resolves #70
Main PR: #80

There are two fields named with sequence in Fibonacci.idl file, which causes idlc compile failed, so it can't support
Actions client demo for now.

module example_interfaces {
  module action {
    @verbatim (language="comment", text=
      "Goal")
    struct Fibonacci_Goal {
      int32 order;
    };
    @verbatim (language="comment", text=
      "Result")
    struct Fibonacci_Result {
      sequence<int32> sequence;
    };
    @verbatim (language="comment", text=
      "Feedback")
    struct Fibonacci_Feedback {
      sequence<int32> sequence;
    };
  };
};

@JEnoch
Copy link
Member

JEnoch commented Apr 8, 2024

sequence is a reserved keyword in IDL. Thus it cannot be used as an identifier.
Replacing it with another name such as just seq will work, since the struct members identifiers are not serialized in CDR (i.e. the identifiers are strictly local).

@uupks
Copy link
Author

uupks commented Apr 8, 2024

Replacing sequence with seq does work, but it's still can't generate source code for SendGoal_Request SendGoal_Response GetResult_Request GetResult_Response... 😟

/****************************************************************

  Generated by Eclipse Cyclone DDS IDL to C Translator
  File name: src/example_interfaces/action/Fibonacci.h
  Source: zenoh-plugin-ros2dds/examples/zenoh-pico/build/example_interfaces/action/Fibonacci.idl
  Cyclone DDS: V0.10.4

*****************************************************************/
#ifndef DDSC_SRC_EXAMPLE_INTERFACES_ACTION_FIBONACCI_H
#define DDSC_SRC_EXAMPLE_INTERFACES_ACTION_FIBONACCI_H

#include "dds/ddsc/dds_public_impl.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct example_interfaces_action_Fibonacci_Goal
{
  int32_t order;
} example_interfaces_action_Fibonacci_Goal;

extern const dds_topic_descriptor_t example_interfaces_action_Fibonacci_Goal_desc;

#define example_interfaces_action_Fibonacci_Goal__alloc() \
((example_interfaces_action_Fibonacci_Goal*) dds_alloc (sizeof (example_interfaces_action_Fibonacci_Goal)));

#define example_interfaces_action_Fibonacci_Goal_free(d,o) \
dds_sample_free ((d), &example_interfaces_action_Fibonacci_Goal_desc, (o))

#ifndef DDS_SEQUENCE_INT32_DEFINED
#define DDS_SEQUENCE_INT32_DEFINED
typedef struct dds_sequence_int32
{
  uint32_t _maximum;
  uint32_t _length;
  int32_t *_buffer;
  bool _release;
} dds_sequence_int32;

#define dds_sequence_int32__alloc() \
((dds_sequence_int32*) dds_alloc (sizeof (dds_sequence_int32)));

#define dds_sequence_int32_allocbuf(l) \
((int32_t *) dds_alloc ((l) * sizeof (int32_t)))
#endif /* DDS_SEQUENCE_INT32_DEFINED */

typedef struct example_interfaces_action_Fibonacci_Result
{
  dds_sequence_int32 seq;
} example_interfaces_action_Fibonacci_Result;

extern const dds_topic_descriptor_t example_interfaces_action_Fibonacci_Result_desc;

#define example_interfaces_action_Fibonacci_Result__alloc() \
((example_interfaces_action_Fibonacci_Result*) dds_alloc (sizeof (example_interfaces_action_Fibonacci_Result)));

#define example_interfaces_action_Fibonacci_Result_free(d,o) \
dds_sample_free ((d), &example_interfaces_action_Fibonacci_Result_desc, (o))

#ifndef DDS_SEQUENCE_INT32_DEFINED
#define DDS_SEQUENCE_INT32_DEFINED
typedef struct dds_sequence_int32
{
  uint32_t _maximum;
  uint32_t _length;
  int32_t *_buffer;
  bool _release;
} dds_sequence_int32;

#define dds_sequence_int32__alloc() \
((dds_sequence_int32*) dds_alloc (sizeof (dds_sequence_int32)));

#define dds_sequence_int32_allocbuf(l) \
((int32_t *) dds_alloc ((l) * sizeof (int32_t)))
#endif /* DDS_SEQUENCE_INT32_DEFINED */

typedef struct example_interfaces_action_Fibonacci_Feedback
{
  dds_sequence_int32 seq;
} example_interfaces_action_Fibonacci_Feedback;

extern const dds_topic_descriptor_t example_interfaces_action_Fibonacci_Feedback_desc;

#define example_interfaces_action_Fibonacci_Feedback__alloc() \
((example_interfaces_action_Fibonacci_Feedback*) dds_alloc (sizeof (example_interfaces_action_Fibonacci_Feedback)));

#define example_interfaces_action_Fibonacci_Feedback_free(d,o) \
dds_sample_free ((d), &example_interfaces_action_Fibonacci_Feedback_desc, (o))

#ifdef __cplusplus
}
#endif

#endif /* DDSC_SRC_EXAMPLE_INTERFACES_ACTION_FIBONACCI_H */

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

2 participants