本文整理匯總了Python中navigation.Navigation.velocitiesToNextSubtarget方法的典型用法代碼示例。如果您正苦於以下問題:Python Navigation.velocitiesToNextSubtarget方法的具體用法?Python Navigation.velocitiesToNextSubtarget怎麽用?Python Navigation.velocitiesToNextSubtarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類navigation.Navigation
的用法示例。
在下文中一共展示了Navigation.velocitiesToNextSubtarget方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from navigation import Navigation [as 別名]
# 或者: from navigation.Navigation import velocitiesToNextSubtarget [as 別名]
#.........這裏部分代碼省略.........
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()
# Get the submodules' speeds
[l_sonar, a_sonar] = self.produceSpeedsSonars()
[l_laser, a_laser] = self.produceSpeedsLaser()
[l_goal, a_goal] = self.navigation.velocitiesToNextSubtarget()
self.linear_velocity = 0
self.angular_velocity = 0
# Combine the speeds following the subsumption architecture
# YOUR CODE HERE ------------------------------------------------------
# ---------------------------------------------------------------------
# Combines the speeds into one output using a motor schema approach
def produceSpeedsMotorSchema(self):
# Produce target if not existent
if self.move_with_target == True and self.navigation.target_exists == False:
self.navigation.selectTarget()
# Get the submodule's speeds
[l_sonar, a_sonar] = self.produceSpeedsSonars()
[l_laser, a_laser] = self.produceSpeedsLaser()
[l_goal, a_goal] = self.navigation.velocitiesToNextSubtarget()
self.linear_velocity = 0
self.angular_velocity = 0
# Get the speeds using the motor schema approach
# YOUR CODE HERE ------------------------------------------------------
# ---------------------------------------------------------------------
# Assistive functions - Do you have to call them somewhere?
def stopRobot(self):
self.stop_robot = True
def resumeRobot(self):
self.stop_robot = False