6 typedef struct motion_speed_type motion_speed;
7 struct motion_speed_type {
12 struct robottype_orte_data {
13 ORTEDomain *orte_domain;
16 struct motion_speed_type motion_speed;
17 ORTEPublication *publication_motion_speed;
20 struct robottype_orte_data orte;
23 int robottype_roboorte_init(struct robottype_orte_data *data) {
28 if (data->strength < 0)
31 ORTEVerbositySetOptions("ALL.0");
32 ORTEDomainPropDefaultGet(&prop);
33 NTPTIME_BUILD(prop.baseProp.refreshPeriod, 3);
34 NTPTIME_BUILD(prop.baseProp.expirationTime, 10);
35 data->orte_domain = ORTEDomainAppCreate(ORTE_DEFAULT_DOMAIN, &prop, NULL, ORTE_FALSE);
36 if (!data->orte_domain) {
37 printf("ORTEDomainAppCreate failed!\n");
44 void motion_speed_serialize(CDR_Codec *cdrCodec, motion_speed *object) {
45 CORBA_short_serialize(cdrCodec,&(object->left));
47 CORBA_short_serialize(cdrCodec,&(object->right));
51 void motion_speed_deserialize(CDR_Codec *cdrCodec, motion_speed *object) {
52 CORBA_short_deserialize(cdrCodec,&(object->left));
54 CORBA_short_deserialize(cdrCodec,&(object->right));
58 int motion_speed_get_max_size(ORTEGetMaxSizeParam *gms, int num) {
63 gms->csize+=num*(gms->csize-csize_save);
67 csize_save=gms->csize;
68 CORBA_short_get_max_size(gms, 1);
69 CORBA_short_get_max_size(gms, 1);
75 motion_speed_type_register(ORTEDomain *d) {
78 ret=ORTETypeRegisterAdd(d,
80 (ORTETypeSerialize)motion_speed_serialize,
81 (ORTETypeDeserialize)motion_speed_deserialize,
82 motion_speed_get_max_size,
86 void robottype_subscriber_motion_speed_create(struct robottype_orte_data *data, ORTERecvCallBack callback, void *arg) {
87 NtpTime deadline, minimumSeparation;
89 motion_speed_type_register(data->orte_domain);
91 NtpTimeAssembFromMs(deadline, 0, 300);
92 NtpTimeAssembFromMs(minimumSeparation, 0, 0);
93 s = ORTESubscriptionCreate(
94 data->orte_domain, IMMEDIATE, BEST_EFFORTS,
95 "motion_speed", "motion_speed",
96 &data->motion_speed, &deadline, &minimumSeparation,
97 callback, arg, IPADDRESS_INVALID);
100 void rcv_motion_speed_cb(const ORTERecvInfo *info, void *vinstance,
101 void *recvCallBackParam)
103 struct motion_speed_type *m = (struct motion_speed_type *)vinstance;
105 switch (info->status) {
107 printf("Prijata data: left: %d, right: %d\n", m->left, m->right);
110 printf("ORTE deadline occurred - motion_speed receive\n");
115 void destroy(int sig) {
116 ORTESubscriptionDestroy(s);
117 ORTETypeRegisterDestroyAll(orte.orte_domain);
118 ORTEDomainAppDestroy(orte.orte_domain);
123 robottype_roboorte_init(&orte);
124 robottype_subscriber_motion_speed_create(&orte, rcv_motion_speed_cb, &orte);
126 signal(SIGINT, &destroy);
127 signal(SIGTERM, &destroy);