@@ -129,168 +129,3 @@ rt_err_t chassis_rotate(chassis_t chas, float angular_z)
129129 rt_int16_t * res_rpm = kinematics_get_rpm (* chas -> c_kinematics , target_velocity );
130130 return chassis_set_rpm (chas , res_rpm );
131131}
132-
133- static void chassis_stop (command_info_t info , void * param , rt_uint16_t size )
134- {
135- if (info -> target != RT_NULL )
136- {
137- chassis_straight (info -> target , 0 );
138- }
139- }
140-
141- static void chassis_forward (command_info_t info , void * param , rt_uint16_t size )
142- {
143- if (info -> target != RT_NULL )
144- {
145- chassis_straight (info -> target , DEFAULT_VELOCITY_LINEAR_X );
146- }
147- }
148-
149- static void chassis_backward (command_info_t info , void * param , rt_uint16_t size )
150- {
151- if (info -> target != RT_NULL )
152- {
153- chassis_straight (info -> target , - DEFAULT_VELOCITY_LINEAR_X );
154- }
155- }
156-
157- static void chassis_rotate_left (command_info_t info , void * param , rt_uint16_t size )
158- {
159- if (info -> target != RT_NULL )
160- {
161- chassis_rotate (info -> target , DEFAULT_VELOCITY_ANGULAR_Z );
162- }
163- }
164-
165- static void chassis_rotate_right (command_info_t info , void * param , rt_uint16_t size )
166- {
167- if (info -> target != RT_NULL )
168- {
169- chassis_rotate (info -> target , - DEFAULT_VELOCITY_ANGULAR_Z );
170- }
171- }
172-
173- static void chassis_move_left (command_info_t info , void * param , rt_uint16_t size )
174- {
175- if (info -> target != RT_NULL )
176- {
177- chassis_move (info -> target , DEFAULT_VELOCITY_LINEAR_Y );
178- }
179- }
180-
181- static void chassis_move_right (command_info_t info , void * param , rt_uint16_t size )
182- {
183- if (info -> target != RT_NULL )
184- {
185- chassis_move (info -> target , DEFAULT_VELOCITY_LINEAR_Y );
186- }
187- }
188-
189- // TODO
190-
191- static void chassis_forward_with_param (command_info_t info , void * param , rt_uint16_t size )
192- {
193- if (info -> target != RT_NULL )
194- {
195- if (size == sizeof (struct cmd_dt_velocity ))
196- {
197- struct cmd_dt_velocity * velocity_info = (struct cmd_dt_velocity * )param ;
198- if (velocity_info -> data .linear_x < 0 )
199- {
200- return ;
201- }
202- chassis_straight (info -> target , velocity_info -> data .linear_x );
203- }
204- }
205- }
206-
207- // TODO
208-
209- static void chassis_set_linear_x (command_info_t info , void * param , rt_uint16_t size )
210- {
211- if (info -> target != RT_NULL )
212- {
213- if (size == sizeof (struct cmd_dt_velocity ))
214- {
215- struct cmd_dt_velocity * velocity_info = (struct cmd_dt_velocity * )param ;
216- chassis_straight (info -> target , velocity_info -> data .linear_x );
217- }
218- }
219- }
220-
221- static void chassis_set_pid (command_info_t info , void * param , rt_uint16_t size )
222- {
223- if (info -> target != RT_NULL )
224- {
225- if (size == sizeof (struct cmd_dt_pid ))
226- {
227- chassis_t chas = (chassis_t )info -> target ;
228- struct cmd_dt_pid * pid_info = (struct cmd_dt_pid * )param ;
229- struct controller_param parameter = {
230- .data .pid .kp = pid_info -> kp ,
231- .data .pid .ki = pid_info -> ki ,
232- .data .pid .kd = pid_info -> kd
233- };
234-
235- switch (pid_info -> id )
236- {
237- case PID_ID_WHEEL_0 :
238- controller_set_param (chas -> c_wheels [0 ]-> w_controller , & parameter );
239- break ;
240- case PID_ID_WHEEL_1 :
241- controller_set_param (chas -> c_wheels [1 ]-> w_controller , & parameter );
242- break ;
243- case PID_ID_WHEEL_2 :
244- if (chas -> c_kinematics -> total_wheels > 2 )
245- {
246- controller_set_param (chas -> c_wheels [2 ]-> w_controller , & parameter );
247- }
248- break ;
249- case PID_ID_WHEEL_3 :
250- if (chas -> c_kinematics -> total_wheels > 3 )
251- {
252- controller_set_param (chas -> c_wheels [3 ]-> w_controller , & parameter );
253- }
254- break ;
255- default :
256- break ;
257- }
258- }
259- }
260- }
261-
262- static void chassis_response_request_pid (command_info_t info , void * param , rt_uint16_t size )
263- {
264- // TODO
265- if (info -> target != RT_NULL )
266- {
267- chassis_t chas = (chassis_t )info -> target ;
268- struct controller_param parameter ;
269- struct cmd_dt_pid pid_info ;
270-
271- controller_get_param (chas -> c_wheels [0 ]-> w_controller , & parameter );
272- pid_info .id = PID_ID_WHEEL_0 ;
273- pid_info .kp = parameter .data .pid .kp ;
274- pid_info .ki = parameter .data .pid .ki ;
275- pid_info .kd = parameter .data .pid .kd ;
276- command_send (info -> sender , COMMAND_SEND_PID , & pid_info , sizeof (struct cmd_dt_pid ));
277- }
278- }
279-
280- static int chassis_command_register (void )
281- {
282- // TODO
283- command_register (COMMAND_CAR_STOP , chassis_stop );
284-
285- command_register (COMMAND_CAR_FORWARD_WITH_PARAM , chassis_forward_with_param );
286-
287- command_register (COMMAND_SET_CAR_VELOCITY_LINEAR_X , chassis_set_linear_x );
288-
289- command_register (COMMAND_SET_PID , chassis_set_pid );
290-
291- command_register (COMMAND_REQUEST_PID , chassis_response_request_pid );
292-
293- return RT_EOK ;
294- }
295-
296- INIT_APP_EXPORT (chassis_command_register );
0 commit comments