command_joint.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 <param.h>
40 #include <control.h>
41 #include <command.h>
42 #include <yprintf.h>
43 
44 /* ライブラリ用 */
45 #include <ypspur.h>
46 
47 void joint_torque_com(int id, double *data, SpurUserParamsPtr spur)
48 {
49  if (id > YP_PARAM_MAX_MOTOR_NUM)
50  {
51  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
52  return;
53  }
54  spur->torque[id] = data[0];
55  spur->wheel_mode[id] = MOTOR_CONTROL_FREE;
56 }
57 
58 void joint_vel_com(int id, double *data, SpurUserParamsPtr spur)
59 {
60  if (id > YP_PARAM_MAX_MOTOR_NUM)
61  {
62  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
63  return;
64  }
65  spur->wvelref[id] = data[0];
66  spur->wheel_mode[id] = MOTOR_CONTROL_VEL;
67 }
68 
69 void joint_ang_com(int id, double *data, SpurUserParamsPtr spur)
70 {
71  if (id > YP_PARAM_MAX_MOTOR_NUM)
72  {
73  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
74  return;
75  }
76  spur->wheel_angle[id] = data[0];
77  spur->wheel_mode[id] = MOTOR_CONTROL_ANGLE;
78 }
79 
80 void joint_ang_vel_com(int id, double *data, SpurUserParamsPtr spur)
81 {
82  if (id > YP_PARAM_MAX_MOTOR_NUM)
83  {
84  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
85  return;
86  }
87  spur->wheel_angle[id] = data[0];
88  spur->wheel_vel_end[id] = data[1];
90 }
91 
92 void set_joint_accel_com(int id, double *data, SpurUserParamsPtr spur)
93 {
94  if (id > YP_PARAM_MAX_MOTOR_NUM)
95  {
96  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
97  return;
98  }
99  spur->wheel_accel[id] = data[0];
100 }
101 
102 void set_joint_vel_com(int id, double *data, SpurUserParamsPtr spur)
103 {
104  if (id > YP_PARAM_MAX_MOTOR_NUM)
105  {
106  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
107  return;
108  }
109  spur->wheel_vel[id] = data[0];
110 }
111 
112 void get_joint_vel_com(int id, double *data, SpurUserParamsPtr spur)
113 {
115 
116  if (id > YP_PARAM_MAX_MOTOR_NUM)
117  {
118  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
119  return;
120  }
121  odometry = get_odometry_ptr();
122 
123  data[0] = odometry->wvel[id];
124  data[1] = odometry->time;
125 }
126 
127 void get_joint_vref_com(int id, double *data, SpurUserParamsPtr spur)
128 {
130 
131  if (id > YP_PARAM_MAX_MOTOR_NUM)
132  {
133  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
134  return;
135  }
136  odometry = get_odometry_ptr();
137 
138  data[0] = spur->wvelref[id];
139  data[1] = odometry->time;
140 }
141 
142 void get_joint_ang_com(int id, double *data, SpurUserParamsPtr spur)
143 {
145 
146  if (id > YP_PARAM_MAX_MOTOR_NUM)
147  {
148  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
149  return;
150  }
151  odometry = get_odometry_ptr();
152 
153  data[0] = odometry->wang[id];
154  data[1] = odometry->time;
155 }
156 
157 void get_joint_torque_com(int id, double *data, SpurUserParamsPtr spur)
158 {
160 
161  if (id > YP_PARAM_MAX_MOTOR_NUM)
162  {
163  yprintf(OUTPUT_LV_ERROR, "Motor id out of range (%d)\n", id);
164  return;
165  }
166  odometry = get_odometry_ptr();
167 
168  data[0] = odometry->wtorque[id];
169  data[1] = odometry->time;
170 }
void get_joint_vel_com(int id, double *data, SpurUserParamsPtr spur)
double wheel_vel_end[YP_PARAM_MAX_MOTOR_NUM]
Definition: command.h:75
double wvelref[YP_PARAM_MAX_MOTOR_NUM]
Definition: command.h:65
void get_joint_vref_com(int id, double *data, SpurUserParamsPtr spur)
void odometry(OdometryPtr xp, short *cnt, short *pwm, double dt, double time)
Definition: odometry.c:144
void joint_vel_com(int id, double *data, SpurUserParamsPtr spur)
Definition: command_joint.c:58
double torque[YP_PARAM_MAX_MOTOR_NUM]
Definition: command.h:68
double wheel_accel[YP_PARAM_MAX_MOTOR_NUM]
Definition: command.h:71
double time
Definition: odometry.h:38
double wang[YP_PARAM_MAX_MOTOR_NUM]
Definition: odometry.h:40
MotorControlMode wheel_mode[YP_PARAM_MAX_MOTOR_NUM]
Definition: command.h:76
double wtorque[YP_PARAM_MAX_MOTOR_NUM]
Definition: odometry.h:43
static YPSpur spur
Definition: libypspur.c:42
double wheel_angle[YP_PARAM_MAX_MOTOR_NUM]
Definition: command.h:74
void get_joint_ang_com(int id, double *data, SpurUserParamsPtr spur)
double wheel_vel[YP_PARAM_MAX_MOTOR_NUM]
Definition: command.h:72
void set_joint_accel_com(int id, double *data, SpurUserParamsPtr spur)
Definition: command_joint.c:92
void get_joint_torque_com(int id, double *data, SpurUserParamsPtr spur)
void joint_ang_vel_com(int id, double *data, SpurUserParamsPtr spur)
Definition: command_joint.c:80
#define YP_PARAM_MAX_MOTOR_NUM
Definition: ypparam.h:430
double wvel[YP_PARAM_MAX_MOTOR_NUM]
Definition: odometry.h:39
void yprintf(ParamOutputLv level, const char *format,...)
Definition: yprintf.c:32
OdometryPtr get_odometry_ptr()
Definition: odometry.c:332
void joint_torque_com(int id, double *data, SpurUserParamsPtr spur)
Definition: command_joint.c:47
void joint_ang_com(int id, double *data, SpurUserParamsPtr spur)
Definition: command_joint.c:69
void set_joint_vel_com(int id, double *data, SpurUserParamsPtr spur)


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