From 22b4f208a29bcb7d277b59a820ecab215eb0ee2c Mon Sep 17 00:00:00 2001 From: jieshoudaxue <1641395022@qq.com> Date: Wed, 13 Dec 2023 11:27:14 +0800 Subject: [PATCH] [fix] up it --- robot_hunt_maze/launch/go_maze.launch | 7 +++ robot_hunt_maze/scripts/exploring_maze.py | 41 +++++++++++++---- robot_hunt_maze/scripts/maze_detect.py | 2 +- robot_hunt_maze/scripts/move_to_target.py | 56 ++++++++++++++++++----- 4 files changed, 86 insertions(+), 20 deletions(-) diff --git a/robot_hunt_maze/launch/go_maze.launch b/robot_hunt_maze/launch/go_maze.launch index 775d702..00c6309 100644 --- a/robot_hunt_maze/launch/go_maze.launch +++ b/robot_hunt_maze/launch/go_maze.launch @@ -14,6 +14,13 @@ output="screen" /> --> + + GET_TARGET_SIZE: + status_flag = STATUS_GO_HOME + + state_msg = Int8() + state_msg.data = status_flag + state_pub.publish(state_msg) + + req = StringToVoiceRequest() + req.data = "拿到宝藏了,回家数数" + resp = voice_client(req) + rospy.loginfo("send txt %s, resp %d" %(req.data, resp.success)) + elif status_flag == STATUS_CLOSE_TARGET: + vel_msg = Twist() + vel_msg.linear.x = (100000 - pose.position.z) / 100000 * 0.3 + vel_msg.angular.z = (640 - pose.position.x) / 640 * 0.3 + + cmd_pub.publish(vel_msg) + def main(): rospy.init_node("move_to_target", anonymous=True) - - cmd_pub = rospy.Publisher("/cmd_vel", Twist, queue_size=1) - bind_pose_cb = partial(pose_cb, cmd_pub=cmd_pub) - rospy.Subscriber("/maze_pose", Pose, bind_pose_cb) - - + state_pub = rospy.Publisher("/state_cmd", Int8, queue_size=1) + voice_client = rospy.ServiceProxy("str2voice", StringToVoice) rospy.wait_for_service("str2voice") - req = StringToVoiceRequest() - req.data = "找到宝藏了,现在回家" - resp = voice_client(req) - print("send txt %s, resp %d" %(req.data, resp.success)) + + bind_pose_cb = partial(pose_cb, state_pub=state_pub, cmd_pub=cmd_pub, voice_client=voice_client) + rospy.Subscriber("/maze_pose", Pose, bind_pose_cb) rospy.spin()