feat: 增加接口
This commit is contained in:
93
by_cmd.c
93
by_cmd.c
@@ -79,7 +79,6 @@ void by_cmd_send_speed_x(float speed)
|
|||||||
{
|
{
|
||||||
uint8_t buff[4] = {0};
|
uint8_t buff[4] = {0};
|
||||||
memcpy(buff, &speed, 4);
|
memcpy(buff, &speed, 4);
|
||||||
|
|
||||||
by_frame_send(0x31, buff, 4);
|
by_frame_send(0x31, buff, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +91,6 @@ void by_cmd_send_speed_y(float speed)
|
|||||||
{
|
{
|
||||||
uint8_t buff[4] = {0};
|
uint8_t buff[4] = {0};
|
||||||
memcpy(buff, &speed, 4);
|
memcpy(buff, &speed, 4);
|
||||||
|
|
||||||
by_frame_send(0x32, buff, 4);
|
by_frame_send(0x32, buff, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +103,6 @@ void by_cmd_send_speed_omega(float speed)
|
|||||||
{
|
{
|
||||||
uint8_t buff[4] = {0};
|
uint8_t buff[4] = {0};
|
||||||
memcpy(buff, &speed, 4);
|
memcpy(buff, &speed, 4);
|
||||||
|
|
||||||
by_frame_send(0x33, buff, 4);
|
by_frame_send(0x33, buff, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,42 +178,76 @@ int by_cmd_send_reset_end_effector(void)
|
|||||||
return (by_cmd_reg_listerning(0x43, 1000));
|
return (by_cmd_reg_listerning(0x43, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置 x 轴增量位置
|
||||||
|
*
|
||||||
|
* @param speed
|
||||||
|
* @param distance
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
int by_cmd_send_distance_axis_x(uint8_t speed, float distance)
|
int by_cmd_send_distance_axis_x(uint8_t speed, float distance)
|
||||||
{
|
{
|
||||||
uint8_t buff[8] = {0};
|
uint8_t buff[8] = {0};
|
||||||
memcpy(buff, &speed, 1);
|
memcpy(buff, &speed, 1);
|
||||||
memcpy(buff + 4, &distance, 4);
|
memcpy(buff + 1, &distance, 4);
|
||||||
by_frame_send(0x44, buff, 8);
|
by_frame_send(0x44, buff, 8);
|
||||||
return (by_cmd_reg_listerning(0x44, 1000));
|
return (by_cmd_reg_listerning(0x44, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置 z 轴增量位置
|
||||||
|
*
|
||||||
|
* @param speed
|
||||||
|
* @param distance
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
int by_cmd_send_distance_axis_z(uint8_t speed, float distance)
|
int by_cmd_send_distance_axis_z(uint8_t speed, float distance)
|
||||||
{
|
{
|
||||||
uint8_t buff[8] = {0};
|
uint8_t buff[8] = {0};
|
||||||
memcpy(buff, &speed, 1);
|
memcpy(buff, &speed, 1);
|
||||||
memcpy(buff + 4, &distance, 4);
|
memcpy(buff + 1, &distance, 4);
|
||||||
by_frame_send(0x46, buff, 8);
|
by_frame_send(0x46, buff, 8);
|
||||||
return (by_cmd_reg_listerning(0x46, 1000));
|
return (by_cmd_reg_listerning(0x46, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 发送 x 轴绝对位置
|
||||||
|
*
|
||||||
|
* @param speed
|
||||||
|
* @param position
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
int by_cmd_send_position_axis_x(uint8_t speed, float position)
|
int by_cmd_send_position_axis_x(uint8_t speed, float position)
|
||||||
{
|
{
|
||||||
uint8_t buff[8] = {0};
|
uint8_t buff[8] = {0};
|
||||||
memcpy(buff, &speed, 1);
|
memcpy(buff, &speed, 1);
|
||||||
memcpy(buff + 4, &position, 4);
|
memcpy(buff + 1, &position, 4);
|
||||||
by_frame_send(0x47, buff, 8);
|
by_frame_send(0x47, buff, 8);
|
||||||
return (by_cmd_reg_listerning(0x47, 1000));
|
return (by_cmd_reg_listerning(0x47, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 发送 z 轴绝对位置
|
||||||
|
*
|
||||||
|
* @param speed
|
||||||
|
* @param position
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
int by_cmd_send_position_axis_z(uint8_t speed, float position)
|
int by_cmd_send_position_axis_z(uint8_t speed, float position)
|
||||||
{
|
{
|
||||||
uint8_t buff[8] = {0};
|
uint8_t buff[8] = {0};
|
||||||
memcpy(buff, &speed, 1);
|
memcpy(buff, &speed, 1);
|
||||||
memcpy(buff + 4, &position, 4);
|
memcpy(buff + 1, &position, 4);
|
||||||
by_frame_send(0x49, buff, 8);
|
by_frame_send(0x49, buff, 8);
|
||||||
return (by_cmd_reg_listerning(0x49, 1000));
|
return (by_cmd_reg_listerning(0x49, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置夹爪摇臂角度
|
||||||
|
*
|
||||||
|
* @param angle
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
int by_cmd_send_angle_claw_arm(float angle)
|
int by_cmd_send_angle_claw_arm(float angle)
|
||||||
{
|
{
|
||||||
uint8_t buff[4] = {0};
|
uint8_t buff[4] = {0};
|
||||||
@@ -225,6 +256,12 @@ int by_cmd_send_angle_claw_arm(float angle)
|
|||||||
return (by_cmd_reg_listerning(0x50, 1000));
|
return (by_cmd_reg_listerning(0x50, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置夹爪角度
|
||||||
|
*
|
||||||
|
* @param angle
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
int by_cmd_send_angle_claw(float angle)
|
int by_cmd_send_angle_claw(float angle)
|
||||||
{
|
{
|
||||||
uint8_t buff[4] = {0};
|
uint8_t buff[4] = {0};
|
||||||
@@ -233,6 +270,48 @@ int by_cmd_send_angle_claw(float angle)
|
|||||||
return (by_cmd_reg_listerning(0x51, 1000));
|
return (by_cmd_reg_listerning(0x51, 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置摄像头角度
|
||||||
|
*
|
||||||
|
* @param angle
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int by_cmd_send_angle_camera(float angle)
|
||||||
|
{
|
||||||
|
uint8_t buff[4] = {0};
|
||||||
|
memcpy(buff, &angle, 4);
|
||||||
|
by_frame_send(0x52, buff, 4);
|
||||||
|
return (by_cmd_reg_listerning(0x52, 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置顶端抓取机构角度
|
||||||
|
*
|
||||||
|
* @param angle
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int by_cmd_send_angle_scoop(float angle)
|
||||||
|
{
|
||||||
|
uint8_t buff[4] = {0};
|
||||||
|
memcpy(buff, &angle, 4);
|
||||||
|
by_frame_send(0x53, buff, 4);
|
||||||
|
return (by_cmd_reg_listerning(0x53, 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置托盘角度
|
||||||
|
*
|
||||||
|
* @param angle
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int by_cmd_send_angle_storage(float angle)
|
||||||
|
{
|
||||||
|
uint8_t buff[4] = {0};
|
||||||
|
memcpy(buff, &angle, 4);
|
||||||
|
by_frame_send(0x54, buff, 4);
|
||||||
|
return (by_cmd_reg_listerning(0x54, 1000));
|
||||||
|
}
|
||||||
|
|
||||||
int by_cmd_send_ranging_start(void)
|
int by_cmd_send_ranging_start(void)
|
||||||
{
|
{
|
||||||
uint8_t buff[4] = {0};
|
uint8_t buff[4] = {0};
|
||||||
|
|||||||
3
by_cmd.h
3
by_cmd.h
@@ -26,6 +26,9 @@ int by_cmd_send_position_axis_z(uint8_t speed, float position);
|
|||||||
|
|
||||||
int by_cmd_send_angle_claw_arm(float angle);
|
int by_cmd_send_angle_claw_arm(float angle);
|
||||||
int by_cmd_send_angle_claw(float angle);
|
int by_cmd_send_angle_claw(float angle);
|
||||||
|
int by_cmd_send_angle_camera(float angle);
|
||||||
|
int by_cmd_send_angle_scoop(float angle);
|
||||||
|
int by_cmd_send_angle_storage(float angle);
|
||||||
|
|
||||||
int by_cmd_send_ranging_start(void);
|
int by_cmd_send_ranging_start(void);
|
||||||
int by_cmd_recv_ranging_data(float *distance);
|
int by_cmd_recv_ranging_data(float *distance);
|
||||||
|
|||||||
Reference in New Issue
Block a user