本文整理汇总了Python中navigation.Navigation.selectTarget方法的典型用法代码示例。如果您正苦于以下问题:Python Navigation.selectTarget方法的具体用法?Python Navigation.selectTarget怎么用?Python Navigation.selectTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类navigation.Navigation
的用法示例。
在下文中一共展示了Navigation.selectTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from navigation import Navigation [as 别名]
# 或者: from navigation.Navigation import selectTarget [as 别名]
class RobotController:
# Constructor
def __init__(self):
# Debugging purposes
self.print_velocities = rospy.get_param('print_velocities')
# Where and when should you use this?
self.stop_robot = False
# Create the needed objects
self.sonar_aggregation = SonarDataAggregator()
self.laser_aggregation = LaserDataAggregator()
self.navigation = Navigation()
self.linear_velocity = 0
self.angular_velocity = 0
# Check if the robot moves with target or just wanders
self.move_with_target = rospy.get_param("calculate_target")
# The timer produces events for sending the speeds every 110 ms
rospy.Timer(rospy.Duration(0.11), self.publishSpeeds)
self.velocity_publisher = rospy.Publisher(\
rospy.get_param('speeds_pub_topic'), Twist,\
queue_size = 10)
# Read the velocities architecture
self.velocity_arch = rospy.get_param("velocities_architecture")
print "The selected velocities architecture is " + self.velocity_arch
# This function publishes the speeds and moves the robot
def publishSpeeds(self, event):
# Choose architecture
if self.velocity_arch == "subsumption":
self.produceSpeedsSubsumption()
else:
self.produceSpeedsMotorSchema()
# Create the commands message
twist = Twist()
twist.linear.x = self.linear_velocity
twist.linear.y = 0
twist.linear.z = 0
twist.angular.x = 0
twist.angular.y = 0
twist.angular.z = self.angular_velocity
# Send the command
self.velocity_publisher.publish(twist)
# Print the speeds for debuggind purposes
if self.print_velocities == True:
print "[L,R] = [" + str(twist.linear.x) + " , " + \
str(twist.angular.z) + "]"
# Produce speeds from sonars
def produceSpeedsSonars(self):
# Get the sonars' measurements
front = self.sonar_aggregation.sonar_front_range
left = self.sonar_aggregation.sonar_left_range
right = self.sonar_aggregation.sonar_right_range
r_left = self.sonar_aggregation.sonar_rear_left_range
r_right = self.sonar_aggregation.sonar_rear_right_range
linear = 0
angular = 0
# YOUR CODE HERE ------------------------------------------------------
# Adjust the linear and angular velocities using the five sonars values
# ---------------------------------------------------------------------
return [linear, angular]
# Produces speeds from the laser
def produceSpeedsLaser(self):
# Get the laser scan
scan = self.laser_aggregation.laser_scan
linear = 0
angular = 0
# YOUR CODE HERE ------------------------------------------------------
# Adjust the linear and angular velocities using the laser scan
# ---------------------------------------------------------------------
return [linear, angular]
# Combines the speeds into one output using a subsumption approach
def produceSpeedsSubsumption(self):
# Produce target if not existent
if self.move_with_target == True and self.navigation.target_exists == False:
self.navigation.selectTarget()
#.........这里部分代码省略.........