record_current_and_voltage.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License");
00006 # you may not use this file except in compliance with the License.
00007 # You may obtain a copy of the License at
00008 #
00009 #   http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS,
00013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 # See the License for the specific language governing permissions and
00015 # limitations under the License.
00016 
00017 
00018 import rospy
00019 from cob_phidgets.msg import *
00020 
00021 def callback(data):
00022         #print "voltage=", data.value[1] # voltage sensor is on the second port of the phidgets board
00023         #print "current=", data.value[0] # current sensor is on the first port of the phidgets board
00024         writer.writerow( ( round((rospy.Time.now() - starttime).to_sec(),5), data.value[1], data.value[0]) )
00025 
00026 def record():
00027         rospy.init_node('record_current_and_voltage')
00028         global starttime
00029         starttime = rospy.Time.now()
00030 
00031         global f
00032         global writer
00033         filename = rospy.get_param("~filename")
00034         global port_voltage, port_current
00035         port_voltage = rospy.get_param("~port_voltage")
00036         port_current = rospy.get_param("~port_current")
00037         f = open(filename, 'wt', 1)
00038         writer = csv.writer(f)
00039         writer.writerow(("time_from_start", "voltage", "current"))
00040 
00041         rospy.Subscriber("/analog_sensors", AnalogSensor, callback)
00042 
00043         rospy.spin()
00044 
00045 if __name__ == '__main__':
00046         record()
00047 


cob_voltage_control
Author(s): Alexander Bubeck
autogenerated on Sat Jun 8 2019 21:02:33