Hire Experts For Answers
Order NowRelated Study Services
- Homework Answers
- Coursework writing help
- Term paper writing help
- Writing Help
- Paper Writing Help
- Research paper help
- Thesis Help
- Dissertation Help
- Case study writing service
- Capstone Project Writing Help
- Lab report Writing
- Take my online class
- Take my online exam
- Do my test for me
- Do my homework
- Do my math homework
- Online Assignment Help
- Do my assignment
- Essay Writing Help
- Write my college essay
- Write my essay for me
DESCRIPTION
Posted
Modified
Viewed
16
Write a python ROS node that will behave as follows:
a) Will rotate 360 degrees in place when started, with fixed angular velocity w=0.1 rps, and then
stop
b) At each step during the rotation, it will add gFrontDistance to any array (list) H, indexed by the
angle rotated.
You will need to add to the gPose[2] orientation so that it is always positive, and then map
that floating point number to an integer between 0 and a variable Pmax so that you can use it as
an index into the array. Initially pMax can be 8.
c) After one rotation, and the update of H, show a bar graph of the array.
d) Repeat the process at a rate 0.1 Hz (how often will this be repeated in seconds?)
Write a short explanation of how you implemented each of these three.
Step 2: Using the “enclosed.world” simulation world, move the robot using the Gazebo menu and the
mouse to the following points, and generate and record H for each one:
a) A short distance from reach of the four corners,
b) And approximately centered, just above the middle wall
Explain the appearance of each graph based on the location at which it was measured.
Step 3: Repeat the process for pMax=16. Explain any difference you see and comment on what effect
this might have on any future planned motions.
Step 4 Modify your ROS node by adding a function that when given H as an argument, will return the
index into H that reflects the furthest open space around the robot. Add code to rotate the robot to this
heading and move forward for 0.5 seconds at 0.5 m/s. (Remember you added .)
Place the robot in one of the corners and allow your ROS node to repeat at least 3 times. Explain what
happens using the bar charts you generated
The current code;
#!/usr/bin/env python
# license removed for brevity
#
# Example program that
# spins in place
# dml 2016
#
#
import sys
import math
import random
import rospy # needed for ROS
from geometry_msgs.msg import Twist # ROS Twist message
from sensor_msgs.msg import LaserScan # ROS laser scan message
from nav_msgs.msg import Odometry # ROS pose message
from tf.transformations import euler_from_quaternion # rotations are quaternions
# ROS topic names for turtlebot_gazebo
motionTopic ='/cmd_vel'
poseTopic = '/odom'
laserTopic = '/scan'
# Global variables
gFrontDistance=0 # average laser range distance in front of robot
gPose = [0,0,0]
# callback to accept pose information
# orientation is stored as a quaterion
# and needs to be translated to angles
#
def callback_pose(msg):
global gPose
orient = msg.pose.pose.orientation
quat = [axis for axis in [orient.x, orient.y, orient.z, orient.w]]
(roll,pitch,yaw)=euler_from_quaternion(quat)
gPose[0]= msg.pose.pose.position.x
gPose[1]= msg.pose.pose.position.y
gPose[2]= yaw
return
# callback for the laser range data
# calculates a front distance as an average
# laser reading over a few measurements in front
#
def callback_laser(msg):
'''Call back function for laser range data'''
global gFrontDistance
center = 0
width = 10 # region in front to average over
dist=0.0
count=0
for i in range(center-width,center+width):
if not math.isnan( msg.ranges[i] ) and \
not math.isinf( msg.ranges[i] ) and \
msg.ranges[i]>1.0:
dist += msg.ranges[i]
count += 1
if (count>0) :
gFrontDistance = dist/float(count)
else:
gFrontDistance=1000 # a big number, nothing in view
return
# spin_node
# will spin the robot aroud to reach the angle given as argument
# at speed given as second argument in rps
def spin_node(target_angle,vgain):
'''Spins the robot to target_angle with factor vgain'''
rospy.init_node('Spin_Node', anonymous=True)
# register publisher and two subscribers
vel_pub = rospy.Publisher(motionTopic, Twist, queue_size=0)
scan_sub = rospy.Subscriber(laserTopic, LaserScan, callback_laser)
pose_sub = rospy.Subscriber(poseTopic, Odometry, callback_pose)
rospy.sleep(1) # allow callbacks to happen before proceeding
rate = rospy.Rate(10) # Hz for main loop frequency
msg = Twist() # empty new velocity message
accuracy = 0.01 # radians
adist = abs(gPose[2]-target_angle)
direction2go = 1
if target_angle
Attachments
#!/usr/bin/env python
# license removed for brevity
#
# Example program that
# spins in place
# dml 2016
#
#
import sys
import math
import random
import rospy # needed for ROS
from geometry_msgs.msg import Twist # ROS Twist message
from sensor_msgs.msg import LaserScan # ROS laser scan message
from nav_msgs.msg import Odometry # ROS pose message
from tf.transformations import euler_from_quaternion # rotations are quaternions
# ROS topic names for turtlebot_gazebo
motionTopic ='/cmd_vel'
poseTopic = '/odom'
laserTopic = '/scan'
# Global variables
gFrontDistance=0 # average laser range distance in front of robot
gPose = [0,0,0]
# callback to accept pose information
# orientation is stored as a quaterion
# and needs to be translated to angles
#
def callback_pose(msg):
global gPose
orient = msg.pose.pose.orientation
quat = [axis for axis in [orient.x, orient.y, orient.z, orient.w]]
(roll,pitch,yaw)=euler_from_quaternion(quat)
gPose[0]= msg.pose.pose.position.x
gPose[1]= msg.pose.pose.position.y
gPose[2]= yaw
return
# callback for the laser range data
# calculates a front distance as an average
# laser reading over a few measurements in front
#
def callback_laser(msg):
'''Call back function for laser range data'''
global gFrontDistance
center = 0
width = 10 # region in front to average over
dist=0.0
count=0
for i in range(center-width,center+width):
if not math.isnan( msg.ranges[i] ) and \
not math.isinf( msg.ranges[i] ) and \
msg.ranges[i]>1.0:
dist += msg.ranges[i]
count += 1
if (count>0) :
gFrontDistance = dist/float(count)
else:
gFrontDistance=1000 # a big number, nothing in view
return
# spin_node
# will spin the robot aroud to reach the angle given as argument
# at speed given as second argument in rps
def spin_node(target_angle,vgain):
'''Spins the robot to target_angle with factor vgain'''
rospy.init_node('Spin_Node', anonymous=True)
# register publisher and two subscribers
vel_pub = rospy.Publisher(motionTopic, Twist, queue_size=0)
scan_sub = rospy.Subscriber(laserTopic, LaserScan, callback_laser)
pose_sub = rospy.Subscriber(poseTopic, Odometry, callback_pose)
rospy.sleep(1) # allow callbacks to happen before proceeding
rate = rospy.Rate(10) # Hz for main loop frequency
msg = Twist() # empty new velocity message
accuracy = 0.01 # radians
adist = abs(gPose[2]-target_angle)
direction2go = 1
if target_angle<gPose[2]: # turn +ve/CCW or -ve/CW
direction2go = -1
print ("Spinning to ",target_angle, " from ",gPose[2]," vgain= ",vgain)
while not rospy.is_shutdown() and adist>accuracy:
adist = abs(gPose[2]-target_angle)
msg.linear.x,msg.angular.z=0.0,direction2go*vgain*adist
vel_pub.publish(msg)
rate.sleep()
print ("Spin complete at ",gPose[2])
msg.linear.x,msg.angular.z=0.0,0.1 # stop now
vel_pub.publish(msg)
return
#
# Callback function for a controlled shutdown
#
def callback_shutdown():
print("Shutting down")
vpub = rospy.Publisher(motionTopic, Twist, queue_size=10)
msg = Twist()
msg.angular.z=0.0
msg.linear.x=0.0
vpub.publish(msg)
return
#-------------------------------MAIN program----------------------
if __name__ == '__main__':
try:
rospy.on_shutdown(callback_shutdown)
spin_node(float(sys.argv[1]),float(sys.argv[2]))
except rospy.ROSInterruptException:
pass
Explanations and Answers
0
No answers posted
Post your Answer - free or at a fee
NB: Post a homework question for free and get answers - free or paid homework help.
Get answers to: Computer Science - Intro To Robotincs or similar questions only at Tutlance.
Related Questions
- Write Two Additional Methods Within The Regionanalysis Class, That Uses Stacks And Queues
- Write Two Additional Methods Within The Regionanalysis Class, That Uses Stacks And Queues
- Java Binary Search Tree Assignment
- Computer Vision Sift Assignment
- To Use Revit To Create A Residential Project Using Specifics On Walls, Roof, And Floors. Pensgrove Project
- C# And Windows Presentation Foundation (Wpf), Design And Implement A Standalone Desktop Time Management Application
- Evaluating How Construction, Landfills, Agriculture, Impact Ground Water
- Simple Machine Learning Project Using Python With Pandas, Numpy And Sklearn
- C++ Phonebook Lab- Linked List
- C++ Phonebook Lab- Linked List
- Nasm Assembly Language Registers Lab
- Matlab Programming Problem To Write A Script
- Matlab Programming Problem To Write A Script
- Error Analysis And Programming Skills
- Janet Riley I-Human Case Study
- Review Existing Code Of Blackbox Test Cases And Command Line Areguements In Python
- Artificial Intelligence - Assignment 2: Ai Survey Program
- Help With A Programming Lab That Comes With A Walkthrough
- For This Programming Project, You Will Have The Freedom To Create A Creative Program Of Your Choice
- Sas Problem - Applied Linear Regression
- Personal Statement Essay About Anything Of Your Choosing
- Python Program That Detects Moving Objects
- Sas Homework (Statistical Programming)
- Sas Assignment For Data Analysis Using Required Data Set
- Sas Assignment For Data Analysis Using Required Data Set
- Convert Er Diagram To Relational Database
- Python Program That Detects Moving Objects
- R Assignments Over Linear And Logistic Regression
- Data Cleaning, Binning, Encoding, Feature Engineering
- Kotlin Android Associate Certification Exam
- Cats Vs Dogs Mlp With Minimal Pytorch Usage
- Python Coding Question Requiring The Use Of Class Methods And Inheritance
- Tree-Based Regression Methods For 3D Sinusoidal Data
- Python Homework - Q2: Simple Linear Regression With R2 Calculation
- Python Homework - Q2: Simple Linear Regression With R2 Calculation
- All The Requirements Are Already Listed Below. I Hope To Get An A Grade.
- Data Science Assignment Help Urgent
- Computer Science 100 Class Lab
- Use Turtle Graphics To Draw A Mickey Mouse Head On Python
- Use Turtle Graphics To Draw A Mickey Mouse Head On Python
- Use Turtle Graphics To Draw A Mickey Mouse Head On Python
- Two Data Science Problems Involving Python Notebooks
- Two Data Science Problems Involving Python Notebooks
- Do You Provide Help With College Admissions Essays
- Sas Performing Basic Sas Programing
- The Question Is About A Homework Problem Related To College Grading Book, Details Are Attached Below.
- The Question Is About A Homework Problem Related To College Grading Book, Details Are Attached Below.
- Nursing Statistics Using Stata
- Python Number Guessing Game. I Did The Basic Code But I Keep Getting Errors While Calling The Code
- Color Palette Using Arduino Uno And Processing