command_run.c
Go to the documentation of this file.
1 // Copyright (c) 2010-2016 The YP-Spur Authors, except where otherwise indicated.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #include <math.h>
22 #include <stdio.h>
23 #include <strings.h>
24 #include <unistd.h>
25 
26 #include <fcntl.h>
27 #include <sys/time.h>
28 #include <sys/types.h>
29 #include <time.h>
30 
31 #ifdef HAVE_CONFIG_H
32 #include <config.h>
33 #endif // HAVE_CONFIG_H
34 
35 /* ボディパラメータ */
36 #include <shvel-param.h>
37 
38 /* yp-spur用 */
39 #include <serial.h>
40 #include <param.h>
41 #include <control.h>
42 #include <command.h>
43 
44 /* ライブラリ用 */
45 #include <ypspur.h>
46 #include <cartesian2d.h>
47 
48 void line_com(int cs, double *data, SpurUserParamsPtr spur)
49 {
50  double x, y, theta;
51 
52  x = data[0];
53  y = data[1];
54  theta = data[2];
55 
56  cstrans_xy(cs, CS_SP, &x, &y, &theta);
57 
58  spur->x = x;
59  spur->y = y;
60  spur->theta = theta;
61  spur->run_mode = RUN_LINEFOLLOW;
62 }
63 
64 void stop_line_com(int cs, double *data, SpurUserParamsPtr spur)
65 {
66  double x, y, theta;
67 
68  x = data[0];
69  y = data[1];
70  theta = data[2];
71 
72  cstrans_xy(cs, CS_SP, &x, &y, &theta);
73 
74  spur->x = x;
75  spur->y = y;
76  spur->theta = theta;
77  spur->run_mode = RUN_STOP_LINE;
78 }
79 
80 void circle_com(int cs, double *data, SpurUserParamsPtr spur)
81 {
82  double x, y, theta;
83 
84  x = data[0];
85  y = data[1];
86  theta = 0;
87 
88  cstrans_xy(cs, CS_SP, &x, &y, &theta);
89 
90  spur->x = x;
91  spur->y = y;
92  spur->radius = data[2];
93  spur->run_mode = RUN_CIRCLEFOLLOW;
94 }
95 
96 void spin_com(int cs, double *data, SpurUserParamsPtr spur)
97 {
98  double x, y, theta;
99 
100  x = 0;
101  y = 0;
102  theta = data[0];
103 
104  cstrans_xy(cs, CS_SP, &x, &y, &theta);
105 
106  spur->theta = theta;
107  spur->run_mode = RUN_SPIN;
108 }
109 
110 void orient_com(int cs, double *data, SpurUserParamsPtr spur)
111 {
112  double x, y, theta;
113 
114  x = 0;
115  y = 0;
116  theta = data[0];
117 
118  cstrans_xy(cs, CS_SP, &x, &y, &theta);
119 
120  spur->theta = theta;
121  spur->run_mode = RUN_ORIENT;
122 }
123 
124 void stop_com(double *data, SpurUserParamsPtr spur)
125 {
126  spur->run_mode = RUN_STOP;
127 }
128 
129 void free_com(double *data, SpurUserParamsPtr spur)
130 {
131  spur->run_mode = RUN_FREE;
132 }
133 
135 {
136  spur->run_mode = RUN_OPENFREE;
137 }
138 
139 void vel_com(double *data, SpurUserParamsPtr spur)
140 {
141  spur->vref = data[0];
142  spur->wref = data[1];
143  spur->run_mode = RUN_VEL;
144 }
145 
147 {
148  spur->wvelref[0] = data[0];
149  spur->wvelref[1] = data[1];
150  spur->run_mode = RUN_WHEEL_VEL;
151 }
152 
154 {
155  double r, l;
156 
157  r = data[0];
158  l = data[1];
159 
161  {
164  }
166  {
169  }
171  {
174  }
176  {
179  }
180 
181  spur->wheel_angle[1] = l;
182  spur->wheel_angle[0] = r;
183  spur->run_mode = RUN_WHEEL_ANGLE;
184 }
void openfree_com(double *data, SpurUserParamsPtr spur)
Definition: command_run.c:134
Definition: ypparam.h:465
SpurRunMode run_mode
Definition: command.h:85
void cstrans_xy(YPSpur_cs src, YPSpur_cs dest, double *x, double *y, double *theta)
Definition: odometry.c:131
double wvelref[YP_PARAM_MAX_MOTOR_NUM]
Definition: command.h:65
double theta
Definition: command.h:78
void line_com(int cs, double *data, SpurUserParamsPtr spur)
Definition: command_run.c:48
void spin_com(int cs, double *data, SpurUserParamsPtr spur)
Definition: command_run.c:96
double p(YPSpur_param id, enum motor_id motor)
Definition: param.c:79
void stop_line_com(int cs, double *data, SpurUserParamsPtr spur)
Definition: command_run.c:64
void vel_com(double *data, SpurUserParamsPtr spur)
Definition: command_run.c:139
void wheel_angle_com(double *data, SpurUserParamsPtr spur)
Definition: command_run.c:153
double radius
Definition: command.h:79
static YPSpur spur
Definition: libypspur.c:42
double wheel_angle[YP_PARAM_MAX_MOTOR_NUM]
Definition: command.h:74
void wheel_vel_com(double *data, SpurUserParamsPtr spur)
Definition: command_run.c:146
void circle_com(int cs, double *data, SpurUserParamsPtr spur)
Definition: command_run.c:80
void stop_com(double *data, SpurUserParamsPtr spur)
Definition: command_run.c:124
int isset_p(YPSpur_param id, enum motor_id motor)
Definition: param.c:84
void orient_com(int cs, double *data, SpurUserParamsPtr spur)
Definition: command_run.c:110
void free_com(double *data, SpurUserParamsPtr spur)
Definition: command_run.c:129


yp-spur
Author(s):
autogenerated on Sat May 11 2019 02:08:24