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;
22 void send_dummy_cb(const ORTESendInfo *info, void *vinstance, void *sendCallBackParam)
24 struct motion_speed_type *m = (struct motion_speed_type *)vinstance;
26 switch(info->status) {
28 printf("Odeslana data: left: %d, right: %d\n", m->left, m->right);
31 printf("Kriticka uroven fronty zprav na odeslani.\n");
36 int robottype_roboorte_init(struct robottype_orte_data *data) {
41 if (data->strength < 0)
44 ORTEVerbositySetOptions("ALL.0");
45 ORTEDomainPropDefaultGet(&prop);
46 NTPTIME_BUILD(prop.baseProp.refreshPeriod, 3);
47 NTPTIME_BUILD(prop.baseProp.expirationTime, 10);
48 data->orte_domain = ORTEDomainAppCreate(ORTE_DEFAULT_DOMAIN, &prop, NULL, ORTE_FALSE);
49 if (!data->orte_domain) {
50 printf("ORTEDomainAppCreate failed!\n");
57 void motion_speed_serialize(CDR_Codec *cdrCodec, motion_speed *object) {
58 CORBA_short_serialize(cdrCodec,&(object->left));
60 CORBA_short_serialize(cdrCodec,&(object->right));
64 void motion_speed_deserialize(CDR_Codec *cdrCodec, motion_speed *object) {
65 CORBA_short_deserialize(cdrCodec,&(object->left));
67 CORBA_short_deserialize(cdrCodec,&(object->right));
71 int motion_speed_get_max_size(ORTEGetMaxSizeParam *gms, int num) {
76 gms->csize+=num*(gms->csize-csize_save);
80 csize_save=gms->csize;
81 CORBA_short_get_max_size(gms, 1);
82 CORBA_short_get_max_size(gms, 1);
88 motion_speed_type_register(ORTEDomain *d) {
91 ret=ORTETypeRegisterAdd(d,
93 (ORTETypeSerialize)motion_speed_serialize,
94 (ORTETypeDeserialize)motion_speed_deserialize,
95 motion_speed_get_max_size,
99 void robottype_publisher_motion_speed_create(struct robottype_orte_data *data, ORTESendCallBack callback, void *arg) {
100 NtpTime persistance, delay;
102 motion_speed_type_register(data->orte_domain);
103 NtpTimeAssembFromMs(persistance, 3, 0);
104 NtpTimeAssembFromMs(delay, 0, 100);
105 printf("delay: s = %d, f = %d\n", delay.seconds, delay.fraction);
106 data->publication_motion_speed = ORTEPublicationCreate(data->orte_domain, "motion_speed", "motion_speed", &data->motion_speed, &persistance, data->strength, callback, arg, &delay);
109 void destroy(int sig) {
110 ORTEPublicationDestroy(orte.publication_motion_speed);
111 ORTETypeRegisterDestroyAll(orte.orte_domain);
112 ORTEDomainAppDestroy(orte.orte_domain);
117 robottype_roboorte_init(&orte);
118 robottype_publisher_motion_speed_create(&orte, send_dummy_cb, &orte);
120 orte.motion_speed.right = -19000;
121 orte.motion_speed.left = 20000;
122 ORTEPublicationSend(orte.publication_motion_speed);
124 signal(SIGINT, &destroy);
125 signal(SIGTERM, &destroy);