]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
motory pripojene pres USB misto pres CAN eb2010/motor-usb
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 1 May 2010 14:40:12 +0000 (16:40 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 1 May 2010 14:40:12 +0000 (16:40 +0200)
src/robofsm/Makefile.omk
src/robofsm/movehelper.cc
src/robofsm/robot.c
src/robofsm/robot.h
src/robofsm/test/Makefile.omk
src/sercom/sercom.h

index 07ccd538c4fb0c896d4c53ecd185db20417a29bd..0eab34e5abf78f765708ccd39c186012e22b9b50 100644 (file)
@@ -30,7 +30,7 @@ lib_LIBRARIES += cornslib
 cornslib_SOURCES = corns_configs.c
 
 # Libraries linked to all programs in this Makefile
-lib_LOADLIBES = robot mcl robomath roboorte robottype          \
+lib_LOADLIBES = robot sercom mcl robomath roboorte robottype           \
                pthread rt m orte pathplan sharp map fsm        \
                rbtree motion robodim actlib cornslib
 
index 4116adad827bf950b4e8d7bcea8da53936a1d8f8..5353d1c87185cd65f1b07875a00aaafa73365688 100644 (file)
@@ -21,6 +21,7 @@
 #include <robomath.h>
 #include <mcl_robot.h>
 #include <string.h>
+#include <unistd.h>
 
 #if 0
 struct TrajectoryConstraints trajectoryConstraintsDefault = {
@@ -208,6 +209,10 @@ void robot_send_speed(double left, double right) {
 //         right, r //robot.orte.motion_speed.right
 //         );
        ORTEPublicationSend(robot.orte.publication_motion_speed);
+       char s[50];
+       sprintf(s, "SPDA:%d\nSPDB:%d\n", r, -l);
+       printf(s);
+       write(robot.motory.fd, s, strlen(s));
 }
 
 /** 
index 8ae7b0bbd14d8e9915d51989ef47c7b4085f8f8a..a2aa5d2be4a8b11800e81b0dc0815626fb446751 100644 (file)
@@ -196,6 +196,17 @@ int robot_init()
        rv = robot_init_orte();
        act_init(&robot.orte);
 
+       strcpy((char *)&robot.motory.devname, "/dev/ttyUSB0");
+       robot.motory.baudrate = 19200;
+       robot.motory.parity = SERCOM_PARNONE;
+       robot.motory.databits = 8;
+       robot.motory.stopbits = 1;
+       robot.motory.mode = 0;
+       robot.motory.sighandler = NULL;
+       rv = sercom_open(&robot.motory);
+       printf("RRRRRRRRRRRRRRRRRRRR %d\n", rv);
+       perror("sercom_open");
+
        return rv;
 }
 
index 60b2b8ba3f5708a23c3d9da17ee8eba7ed1c11d1..57282f9c823a06d155ab4dbfdf4bcc1c12dd6765 100644 (file)
@@ -21,6 +21,7 @@
 #include <roboevent.h>
 #include <fsm.h>
 #include <robot_config.h>
+#include <sercom.h>
 
 /**
  * Competition parameters
@@ -217,6 +218,7 @@ struct robot {
        /** is set to true in separate thread when there is short time left */
        bool short_time_to_end;
        bool check_turn_safety;
+       struct sercom_data motory;
 }; /* robot */
 
 extern struct robot robot;
index 22d81703349552d0982bec91753ee6411f34e597..2f88e596527b6971353f0f62bb61445a35bf33b9 100644 (file)
@@ -38,5 +38,5 @@ mcl-laser_SOURCES = mcl-laser.cc
 # Libraries linked to all programs in this Makefile
 lib_LOADLIBES = robot mcl robodim laser-nav robomath   \
                roboorte robottype pthread rt m orte pathplan   \
-               sharp map fsm rbtree motion actlib cornslib
+               sharp map fsm rbtree motion actlib cornslib sercom 
 
index 8a515363c4e31cda57cd61c2a0bdd2cdc140abe3..4d5ba2012c0fa4510c2dcbbfa038419fb8e8a625 100644 (file)
 #include <termios.h>
 #include <sys/types.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+
+
 #define _POSIX_SOURCE          1       /* POSIX compliant source */
 #define SERCOM_DEFAULT_DEV     "/dev/ttyS0"
 #define SERCOM_DEVNAME_LEN     80
@@ -49,4 +54,9 @@ int sercom_open(struct sercom_data *sercom);
 ssize_t sercom_read(struct sercom_data *sercom, char *buf, ssize_t buflen);
 void sercom_close(struct sercom_data *sercom);
 
+#ifdef __cplusplus
+}
+#endif 
+
+
 #endif