Commit c7e7044c767446146d50dfa739e6cb453f9d0c25

Authored by elopes
1 parent 05f40afd

put all files

RIOT/drivers/include/robotcar.h
... ... @@ -10,7 +10,7 @@ extern "C" {
10 10 #endif
11 11  
12 12 #define WHEEL_DIAM 65 //mm
13   -#define STEP_COUNT 20
  13 +#define STEP_COUNT 19
14 14  
15 15 typedef struct {
16 16 pwm_t device; /**< the PWM device driving the robot */
... ...
RIOT/drivers/robotcar/robotcar.c
... ... @@ -74,7 +74,7 @@ void robot_rev( robot_t *dev, uint16_t speed){
74 74  
75 75 void robot_drive( robot_t *dev, uint16_t speed, int direction){
76 76 gpio_set(dev->stby);
77   - if(direction > 0) robot_fw(dev,speed);
  77 + if(direction < 0) robot_fw(dev,speed);
78 78 else robot_rev(dev,speed);
79 79 }
80 80  
... ... @@ -84,12 +84,13 @@ void robot_stop(robot_t *dev1, robot_t *dev2){
84 84 gpio_clear(dev1->in2);
85 85 gpio_clear(dev2->in1);
86 86 gpio_clear(dev2->in2);
  87 + dev1->counter = 0;
  88 + dev2->counter = 0;
87 89 }
88 90  
89 91 void robot_move_forward( robot_t *dev1, robot_t *dev2, uint16_t speed,int steps){
90 92  
91   - dev1->counter = 0;
92   - dev2->counter = 0;
  93 +
93 94 while((steps > dev1->counter)&&(steps > dev2->counter))
94 95 {
95 96  
... ... @@ -98,15 +99,13 @@ void robot_move_forward( robot_t *dev1, robot_t *dev2, uint16_t speed,int steps
98 99  
99 100 }
100 101 robot_stop(dev1,dev2);
101   - dev1->counter = 0;
102   - dev2->counter = 0;
  102 +
103 103 }
104 104  
105 105  
106 106 void robot_move_reverse( robot_t *dev1, robot_t *dev2, uint16_t speed,int steps){
107 107  
108   - dev1->counter = 0;
109   - dev2->counter = 0;
  108 +
110 109 while((steps > dev1->counter)&&(steps > dev2->counter))
111 110 {
112 111  
... ... @@ -116,14 +115,12 @@ void robot_move_reverse( robot_t *dev1, robot_t *dev2, uint16_t speed,int steps
116 115  
117 116 }
118 117 robot_stop(dev2,dev1);
119   - dev1->counter = 0;
120   - dev2->counter = 0;
  118 +
121 119 }
122 120  
123 121 void robot_spin_right( robot_t *dev1, robot_t *dev2, uint16_t speed,int steps){
124 122  
125   - dev1->counter = 0;
126   - dev2->counter = 0;
  123 +
127 124 while((steps > dev1->counter)&&(steps > dev2->counter))
128 125 {
129 126  
... ... @@ -133,14 +130,12 @@ void robot_spin_right( robot_t *dev1, robot_t *dev2, uint16_t speed,int steps){
133 130  
134 131 }
135 132 robot_stop(dev1,dev2);
136   - dev1->counter = 0;
137   - dev2->counter = 0;
  133 +
138 134 }
139 135  
140 136 void robot_spin_left( robot_t *dev1, robot_t *dev2, uint16_t speed,int steps){
141 137  
142   - dev1->counter = 0;
143   - dev2->counter = 0;
  138 +
144 139 while((steps > dev1->counter)&&(steps > dev2->counter))
145 140 {
146 141  
... ... @@ -150,6 +145,5 @@ void robot_spin_left( robot_t *dev1, robot_t *dev2, uint16_t speed,int steps){
150 145  
151 146 }
152 147 robot_stop(dev1,dev2);
153   - dev1->counter = 0;
154   - dev2->counter = 0;
  148 +
155 149 }
... ...
RIOT/examples/network_app_rtt_1/Makefile renamed to RIOT/examples/network_app_sntp/Makefile
RIOT/examples/network_app_rtt_1/main.c renamed to RIOT/examples/network_app_sntp/main.c
... ... @@ -168,7 +168,7 @@ void *sock_server_thread(void *arg)
168 168 local.port = 1234;
169 169 Data buf;
170 170 int64_t offset = 0;
171   - int deadline;
  171 + int latency;
172 172  
173 173 sock_udp_ep_t server = { .port = NTP_PORT, .family = AF_INET6 };
174 174 ipv6_addr_from_str((ipv6_addr_t *)&server.addr, "baad:a555::1702");
... ... @@ -195,8 +195,8 @@ void *sock_server_thread(void *arg)
195 195 {
196 196 puts("Can't receive datagram\n");
197 197 }
198   - deadline = xtimer_now_usec() + offset - buf.send_time;
199   - printf("tps de transmission : %i\n",deadline);
  198 + latency = xtimer_now_usec() + offset - buf.send_time;
  199 + printf("latency : %i\n",latency);
200 200  
201 201 //puts("Got a UDP datagram\n");
202 202 //send ack
... ... @@ -228,11 +228,11 @@ void *sock_client_thread(void *arg)
228 228 remote.addr.ipv6[14] = 0x17;
229 229 remote.addr.ipv6[15] = 0x36;
230 230  
231   - /* fill up the echo message
  231 + /* fill up the echo message */
232 232 for (i = 0; i < ECHOLEN; i++) {
233 233  
234 234 data.donnees[i] = 'e';
235   - }*/
  235 + }
236 236  
237 237 for (;;)
238 238 {
... ...
RIOT/examples/network_app_rtt_1/udp.c renamed to RIOT/examples/network_app_sntp/udp.c
RIOT/examples/robot_app_dynamic/main.c
... ... @@ -112,8 +112,15 @@ void *robot_thread(void *arg)
112 112 {
113 113 msg_receive(&msg);
114 114 cmd[0] = msg.content.value;
115   - if((cmd[0]&0xff) == 4) {send_to_robot_auto();xtimer_sleep(3);} //mode auto
116   - else {send_to_robot_manu(cmd[0]);xtimer_sleep(1);} //mode manu
  115 + if((cmd[0]&0xff) == 4)
  116 + {
  117 + send_to_robot_auto();
  118 + } //mode auto
  119 + else
  120 + {
  121 + send_to_robot_manu(cmd[0]);
  122 + xtimer_sleep(1);
  123 + } //mode manu
117 124 }
118 125 return NULL;
119 126 }
... ... @@ -133,7 +140,7 @@ void *sock_client_thread(void *arg)
133 140 remote.addr.ipv6[2] = 0xa5;
134 141 remote.addr.ipv6[3] = 0x55;
135 142 remote.addr.ipv6[14] = 0x17;
136   - remote.addr.ipv6[15] = 0x2a;
  143 + remote.addr.ipv6[15] = 0x36;
137 144  
138 145 for (;;)
139 146 {
... ... @@ -144,7 +151,7 @@ void *sock_client_thread(void *arg)
144 151 {
145 152 puts("Error sending message");
146 153 }
147   - if ((res = sock_udp_recv(&sock,message,MAX_MESSAGE_LENGTH, 14 * MS_PER_SEC,&remote)) < 0)
  154 + if ((res = sock_udp_recv(&sock,message,MAX_MESSAGE_LENGTH, 20 * SEC_PER_MIN,&remote)) < 0)
148 155 {
149 156 if (res == -ETIMEDOUT)
150 157 {
... ... @@ -166,8 +173,9 @@ void *sock_server_thread(void *arg)
166 173 {
167 174 (void) arg;
168 175 local.port = 1234;
  176 + int count = 0;
169 177 uint32_t server_msg[1];
170   - //uint32_t auto_r;
  178 + uint32_t auto_r;
171 179 msg_t msg;
172 180  
173 181 if (sock_udp_create(&sock, &local, NULL, 0) < 0)
... ... @@ -183,18 +191,23 @@ void *sock_server_thread(void *arg)
183 191  
184 192 /* wait for incoming packets */
185 193 if ((sock_udp_recv(&sock,server_msg, sizeof(server_msg), 5 * SEC_PER_MIN,&remote) >= 0)){
186   - msg.content.value = server_msg[0];
  194 +
187 195 //send ack
188 196 if (sock_udp_send(&sock,"ok",sizeof("ok"), &remote) < 0)
189 197 {
190 198 puts("Error sending reply");
191 199 }
  200 + msg.content.value = server_msg[0];
  201 + count = 0;
192 202 msg_send(&msg, robot_pid);
193 203 }
194 204 else{
195   - //auto_r = 4;
196   - // msg.content.value = auto_r;
197   - //msg_send(&msg, robot_pid);//auto
  205 + auto_r = 4;
  206 + msg.content.value = auto_r;
  207 + if(count < 3) {
  208 + msg_send(&msg, robot_pid);
  209 + count++;
  210 + }//auto
198 211  
199 212 }
200 213  
... ... @@ -231,13 +244,12 @@ static void _init_interface(void)
231 244 {
232 245 crea_rpl_dodag_root(1, addr);
233 246 client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread");
234   - } else if((addr.u8[14]==0x17)&&(addr.u8[15]==0x36)){
235   - }
236   - else if((addr.u8[14]==0x17)&&(addr.u8[15]==0x2a))
  247 + }
  248 + else if((addr.u8[14]==0x17)&&(addr.u8[15]==0x36))
237 249 {
238 250  
239 251 server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread");
240   - robot_pid=thread_create(robot_stack,sizeof(robot_stack),5,THREAD_CREATE_STACKTEST,robot_thread,NULL,"robot_thread");
  252 + robot_pid=thread_create(robot_stack,sizeof(robot_stack),7,THREAD_CREATE_STACKTEST,robot_thread,NULL,"robot_thread");
241 253 }
242 254 else
243 255 {
... ...
RIOT/examples/robot_app_dynamic/motor.c
... ... @@ -44,7 +44,7 @@
44 44 #define MOTOR2_IN2 GPIO_PIN(PORT_E,3)
45 45 #define MOTOR2_ECD GPIO_PIN(PORT_A,9)
46 46  
47   -#define STDBY GPIO_PIN(PORT_D,4)
  47 +#define STDBY GPIO_PIN(PORT_D,5)
48 48  
49 49 robot_t motor_1;
50 50 robot_t motor_2;
... ... @@ -150,7 +150,8 @@ void send_to_robot_manu(uint32_t msg)
150 150  
151 151 void send_to_robot_auto(void)
152 152 {
153   - robot_spin_right(&motor_1,&motor_2,700,60);
  153 + robot_spin_right(&motor_1,&motor_2,600,60);
  154 + xtimer_sleep(1);
154 155 }
155 156  
156 157 int init_robot(robot_t *dev1, robot_t *dev2)
... ...