增加云台相关指令
This commit is contained in:
79
by_cmd.c
79
by_cmd.c
@@ -114,12 +114,12 @@ void by_cmd_send_speed_omega(float speed)
|
||||
*
|
||||
* @param speed
|
||||
* @param time
|
||||
* @return true 发送成功
|
||||
* @return false 应答超时
|
||||
* @return 0 发送成功
|
||||
* @return -1 应答超时
|
||||
*/
|
||||
int by_cmd_send_distance_x(float speed, uint32_t time)
|
||||
{
|
||||
uint8_t buff[4] = {0};
|
||||
uint8_t buff[8] = {0};
|
||||
memcpy(buff, &speed, 4);
|
||||
memcpy(buff + 4, &time, 4);
|
||||
by_frame_send(0x34, buff, 8);
|
||||
@@ -136,7 +136,7 @@ int by_cmd_send_distance_x(float speed, uint32_t time)
|
||||
*/
|
||||
int by_cmd_send_distance_y(float speed, uint32_t time)
|
||||
{
|
||||
uint8_t buff[4] = {0};
|
||||
uint8_t buff[8] = {0};
|
||||
memcpy(buff, &speed, 4);
|
||||
memcpy(buff + 4, &time, 4);
|
||||
by_frame_send(0x35, buff, 8);
|
||||
@@ -179,4 +179,75 @@ int by_cmd_send_reset_end_effector(void)
|
||||
uint8_t buff[4] = {0};
|
||||
by_frame_send(0x43, buff, 4);
|
||||
return (by_cmd_reg_listerning(0x43, 1000));
|
||||
}
|
||||
|
||||
int by_cmd_send_distance_axis_x(uint8_t speed, float distance)
|
||||
{
|
||||
uint8_t buff[8] = {0};
|
||||
memcpy(buff, &speed, 1);
|
||||
memcpy(buff + 4, &distance, 4);
|
||||
by_frame_send(0x44, buff, 8);
|
||||
return (by_cmd_reg_listerning(0x44, 1000));
|
||||
}
|
||||
|
||||
int by_cmd_send_distance_axis_z(uint8_t speed, float distance)
|
||||
{
|
||||
uint8_t buff[8] = {0};
|
||||
memcpy(buff, &speed, 1);
|
||||
memcpy(buff + 4, &distance, 4);
|
||||
by_frame_send(0x46, buff, 8);
|
||||
return (by_cmd_reg_listerning(0x46, 1000));
|
||||
}
|
||||
|
||||
int by_cmd_send_position_axis_x(uint8_t speed, float position)
|
||||
{
|
||||
uint8_t buff[8] = {0};
|
||||
memcpy(buff, &speed, 1);
|
||||
memcpy(buff + 4, &position, 4);
|
||||
by_frame_send(0x47, buff, 8);
|
||||
return (by_cmd_reg_listerning(0x47, 1000));
|
||||
}
|
||||
|
||||
int by_cmd_send_position_axis_z(uint8_t speed, float position)
|
||||
{
|
||||
uint8_t buff[8] = {0};
|
||||
memcpy(buff, &speed, 1);
|
||||
memcpy(buff + 4, &position, 4);
|
||||
by_frame_send(0x49, buff, 8);
|
||||
return (by_cmd_reg_listerning(0x49, 1000));
|
||||
}
|
||||
|
||||
int by_cmd_send_angle_claw_arm(float angle)
|
||||
{
|
||||
uint8_t buff[4] = {0};
|
||||
memcpy(buff, &angle, 4);
|
||||
by_frame_send(0x50, buff, 4);
|
||||
return (by_cmd_reg_listerning(0x50, 1000));
|
||||
}
|
||||
|
||||
int by_cmd_send_angle_claw(float angle)
|
||||
{
|
||||
uint8_t buff[4] = {0};
|
||||
memcpy(buff, &angle, 4);
|
||||
by_frame_send(0x51, buff, 4);
|
||||
return (by_cmd_reg_listerning(0x51, 1000));
|
||||
}
|
||||
|
||||
int by_cmd_send_ranging_start(void)
|
||||
{
|
||||
uint8_t buff[4] = {0};
|
||||
by_frame_send(0x55, buff, 4);
|
||||
return (by_cmd_reg_listerning(0x55, 1000));
|
||||
}
|
||||
|
||||
int by_cmd_recv_ranging_data(float *distance)
|
||||
{
|
||||
uint8_t buff[4] = {0};
|
||||
by_frame_send(0x56, buff, 4);
|
||||
if (!by_cmd_reg_listerning(0x56, 1000)) {
|
||||
memcpy(distance, &received_data[0], 4);
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user