Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help understanding your explore algorithm #72

Open
PhilipAmadasun opened this issue Jul 22, 2022 · 0 comments
Open

Need help understanding your explore algorithm #72

PhilipAmadasun opened this issue Jul 22, 2022 · 0 comments

Comments

@PhilipAmadasun
Copy link

I am a student using your algorithms you made for this package as reference reference for my own custom algorithm. I have looked at the message types you have used but there is something I'm missing that I need help with.
I'm creating my own exploration algorithm in unknown environments with turtlebot3. I plan on :

-using turtlebot3 slam package for mapping(in order to get map info)

-have my custom algorithm use map info to create a target goals set in the known free space(according to the map data I'm getting fro slam)

-As the map data gets updated by slam I keep creating more target goals from the data.

I'm however having issues with the movebase action server. It doesnt seem to be active. This is my code(I just removed the script for my planner to be present it here for this question,but the rest of the code is what I'm trying to use):

#!/usr/bin/python2.7
import rospy
import math
import actionlib
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
from geometry_msgs.msg import PoseStamped
from nav_msgs.msg import Odometry
from nav_msgs.msg import OccupancyGrid
from nav_msgs.msg import Path
import tf

def callback(msg):
    pass

def mapcall(msg):
    pass
rospy.init_node("control")
#pub = rospy.Publisher("goal", PoseStamped, queue_size=1, latch=True)
rospy.Subscriber("/odom", Odometry, callback)
rospy.Subscriber("/map", OccupancyGrid, mapcall)


#while not rospy.is_shutdown():
#    pub.publish(goal)
#    rospy.sleep(10.5)
#    goal.pose.position.x = 0.203
#    goal.pose.position.y = -0.4769
#    pub.publish(goal)
#    rospy.sleep(10.5)
def planner(A, B, C, v, x, y, z, X, Y, dt, index):
    ..............................
def movebase_client():
    client = actionlib.SimpleActionClient('move_base', MoveBaseAction)
    listener = tf.TransformListener()
    listener.waitForTransform('map', 'base_footprint', rospy.Time(0), rospy.Duration(50))
    (trans, rot) = listener.lookupTransform('map', 'base_footprint', rospy.Time(0))
    target = planner(0.5,0.25,0.25,0.22,0,1,0,trans[0],trans[1],1.5,1)
    goal = MoveBaseGoal()
    goal.target_pose.header.stamp = rospy.get_rostime()
    goal.target_pose.header.frame_id = "map"
    goal.target_pose.pose.position.x = target[0]
    goal.target_pose.pose.position.y = target[1]
    goal.target_pose.pose.position.z = 0

    goal.target_pose.pose.orientation.x = 0
    goal.target_pose.pose.orientation.y = 0
    goal.target_pose.pose.orientation.z = 0
    goal.target_pose.pose.orientation.w = 1
    client.wait_for_server()



    client.send_goal(goal)
    wait = client.wait_for_result()

    if not wait:
            rospy.logerr("Action server not available!")
            rospy.signal_shutdown("Action server not available!")
    else:
        return client.get_result()

if __name__ == '__main__':
    try:
        result = movebase_client()
        if result:
            rospy.loginfo("Goal execution done!")
    except rospy.ROSInterruptException:
        rospy.loginfo("Naviga
```tion test finished.")

When I run it, nothing happens, is there some parameter in a config file for turtlebot3 that I'm supposed to set to something else. Is the code just wrong?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant