本文整理汇总了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