|(22 intermediate revisions by the same user not shown)|
''The ROS script used for our project is given below
The ROS script used for our project is given below
# Standaard tue importeer shizzle
from robot_smach_states. util. startup import startup
# het type bericht dat gecommuniceerd wordt
from std_msgs. msg import Float64MultiArray
rospy. init_node(' armTrajCopier' )
# standaard opstart gedoe van de AMIGO
parser = argparse.ArgumentParser()
from "" data ""
parser.add_argument(' robot' , help=' Robot name' )
args = parser.parse_args()
rospy.loginfo(' args: %s' , args)
robot_name = args.robot
if robot_name == ' amigo' :
from robot_skills.amigo import Amigo as Robot
print " unknown robot"
self.robot = Robot()
multiArray = Float64MultiArray()
multiArray.data = [0.0, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0]
# begin een rostopic en subscribe hier op
rospy.Subscriber(" arm_angles" , Float64MultiArray, self.move_arms)
# blijf doorgaan
def move_arms( self, multiArray) :
# assign data
left = multiArray.data[0:7]
right = multiArray. data[7:15]
# clamp data
#self.clamp(self, left, 0, -1.57
max(min(left, 0.0 ), -1.57)
max(min(left, 1.57), -1.57)
max(min(left, 1.57), -1.57)
max(min(left, 2.23), 0.0)
max(min(left, 1.83), -1.83)
max(min(left, 0.95), -0.95)
max(min(left, 0.61), -0.61)
max(min(right[ 0], 0.0 ), -1.57)
max(min(right[ 1], 1. 57), -1.57)
max(min(right , 1.57), -1.57)
max(min(right , 2.23), 0.0)
max(min(right, 1.83), -1.83)
max(min(right, 0.95), -0.95)
max(min(right, 0.61), -0.61)
# maak een nieuwe trajectories voor links en rechts
self.robot.leftArm.default_trajectories[' newTrajL' ] = [ left ]
. . '''''' .
self. robot. rightArm.default_trajectories[' newTrajR' ] = [ right ]
# voer de trajectories uit
self.robot.leftArm.send_joint_trajectory(' newTrajL' , timeout=0.0)
self.robot.rightArm.send_joint_trajectory(' newTrajR' , timeout=0. 0)
################## intializing program ######################
if __name__ == ' __main__' :
armTrajCopier = ArmTrajCopier() ''
The ROS script used for our project involving AMIGO is given below. The description of the project can be found on another page
In the first lines 3-9 of the script a lot is imported. All import (..) lines are there to import and open
multiple kinds of software and files that are required to succesfully execute the script. Import python is meant
to indicate the code language python, which is the programming language this script is made with. Most other imported items
were derived from the example script this script was based on. Their function is not known to us, but they are required to
be imported nonetheless. Import startup in line 10 imports a file name startup. The part between "from" and "import" indicates the directory or
folder this file comes from. Import Float64MultiArray in line 14 imports a type of message from a folder. This is a predefined type of message
that is to send and received over the topic by the script. This type of message can be used to send arrays over a topic and is thus what
needed to receive the proper information from the Kinect.
It is to be noted that you need to have these folders and files installed in order to import them in the script. The message types come with
the installation of ROS and the startup file comes most likely once all AMIGO related software and files are installed.
A class is defined. This is done so that the script initializes and can be ran. Thereafter a node corresponding to the script is initialized
so that data can be received. This node is called "armTrajCopier".
This is followed by a few lines (22-25) that came with the example script. These are lines of code that execute parts of the starting up of the
script when it is executed. The code in lines 26-35 requires an extra argument to be given when the script is executed in the terminal. The word
"amigo" is required to be given, which will result in the script importing the robot model of AMIGO. If the word "amigo" is not inserted after the
running command the script will not run.(The script could normally be executed by typing /.armTrajCopier.py in the terminal, but due to this
code it can now only be executed by typing /.armTrajCopier.py amigo).
In the code in line 37 it is extra defined that the data to be received over the topic indicated with the name "multiarray" is a Float64MultiArray
type of message. In lines 38-39 an array of 14 numbers is defined. In line 40 an action called move_arms is called for. This more or less executes
the action in which an array of 14 can be processed into coordinates for AMIGO's arms. This action is defined in the next section of the script. The
array in lines 38-39 contains numbers that will result in AMIGO raising his arms.
The code in line 43 makes sure that the node "armTrajCopier" initiated can receive information from the topic "arm_angles" in the form of a Float64MultiArray.
The nodes we use to send the information from will use the this topic "arm_angles" to transmit data and now the node "armTrajCopier" is ready to receive the
transmitted over this topic.
The line of coderospy.spin() in line 45 makes sure that the script keeps running until it is manually terminated.
In this part of the script the action move_arms, called upon in an earlier part of the script, is described. This action is all about processing the received
data in the form of arrays into AMIGO's arm movement. The script in fact counts on arrays with 14 elements. In line 54-55 the script assigns the first 7 elements from received arrays to a smaller array size 1x7 that will serve as the seven joint coordinates for the left arm and the other 7 elements from the received array to another smaller array size 1x7 that will serve as the seven joint coordinates for the right arm.
In lines 59-73 the numbers in the arrays are clamped. AMIGO's arm joint have a limited range of positions they can be take on. If any of the numbers from the derived arrays have a value that lies outside the range they are rounded to either the minimum or maximum value possible for the joint they represent depending on whether the received number has a value smaller than the minimum value or larger than the maximum value respectively.(For example, a joint can only take on poses based on a number between -1.57 and 1.57. If the number in the received array that needs to represent this joint is smaller than -1.57 it will be rounded to -1.57 and if the number is larger than 1.57 it will be rounded to 1.57).
In line 76-77 the two 1x7 arrays are defined as trajectories for the arms. The seven numbers in the arrays will be the positions, angles or rotation of the seven joints in the arms. In lines 79-80 a command is given to AMIGO to move his arms in these previously defined position. It is designed so that the script will process the received arays continuously.
Finally in lines 84-85 it is defined that the script can be executed by typing the file name of the script(in this case "armTrajCopier.py") in the terminal. Once that is done the script will start up and execute all functions mentioned. It will however only receive data once the other required scripts and devices that send the data are running. As long as no data is published on the topic "arm_angles" the node "armTrajCopier" will simply keep waiting.