You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
(43) |
Apr
(196) |
May
(316) |
Jun
(518) |
Jul
(1293) |
Aug
(1446) |
Sep
(930) |
Oct
(1271) |
Nov
(1275) |
Dec
(1385) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(1622) |
Feb
(1546) |
Mar
(1236) |
Apr
(1512) |
May
(1782) |
Jun
(1551) |
Jul
(2300) |
Aug
(3088) |
Sep
(452) |
Oct
|
Nov
|
Dec
|
|
From: <tf...@us...> - 2008-03-28 22:28:36
|
Revision: 66
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=66&view=rev
Author: tfoote
Date: 2008-03-28 15:28:42 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
cleaning up displays
Modified Paths:
--------------
pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/watchBatteries.py
Modified: pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
===================================================================
--- pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py 2008-03-28 22:18:45 UTC (rev 65)
+++ pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py 2008-03-28 22:28:42 UTC (rev 66)
@@ -362,7 +362,9 @@
increment = 1.0
if time.time() - last_time > increment:
last_time = last_time + increment
+ print "displaying to screen"
myPow.print_remaining()
+ print "updating param server"
myPow.updateParamServer(master)
if __name__ == '__main__':
Modified: pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/watchBatteries.py
===================================================================
--- pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/watchBatteries.py 2008-03-28 22:18:45 UTC (rev 65)
+++ pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/watchBatteries.py 2008-03-28 22:28:42 UTC (rev 66)
@@ -82,17 +82,18 @@
print "Getting IBPS params from Parameter Server"
print "-------------------------------------------------------------------"
status_code, statusMessage, current = master.getParam('IBPS.current')
- print "Current"
+ print "Current (A into Battery)"
print current
status_code, statusMessage, voltage = master.getParam('IBPS.voltage')
- print "Voltage"
+ print "Voltage (V)"
print voltage
status_code, statusMessage, time_remaining = master.getParam('IBPS.time_remaining')
print "Time Remaining (minutes)"
print time_remaining
status_code, statusMessage, average_charge = master.getParam('IBPS.average_charge')
- print "Average Charge"
+ print "Average Charge (percentage)"
print average_charge
+
time.sleep(1.0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tf...@us...> - 2008-03-28 22:18:41
|
Revision: 65
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=65&view=rev
Author: tfoote
Date: 2008-03-28 15:18:45 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
monitorBatteries now publishes to the ParamServer. and watchBatteries now prints to screen.
Modified Paths:
--------------
pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
Added Paths:
-----------
pkg/trunk/IBPSBatteryInterface/nodes/watchBatteries
pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/watchBatteries.py
Added: pkg/trunk/IBPSBatteryInterface/nodes/watchBatteries
===================================================================
--- pkg/trunk/IBPSBatteryInterface/nodes/watchBatteries (rev 0)
+++ pkg/trunk/IBPSBatteryInterface/nodes/watchBatteries 2008-03-28 22:18:45 UTC (rev 65)
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+PKG = 'IBPSBatteryInterface'
+MODULE = 'IBPSBatteryInterface.watchBatteries' #this is the module that will be invoked by python
+
+######################################################
+# BOILERPLATE: Should not have to modify anything
+# below except for very last line
+######################################################
+# Bootstrap ourselves into latest rospy install
+import sys, os
+BOOTSTRAP_VERSION = "0.1"
+
+# Read in ROS_ROOT
+if not os.environ.has_key('ROS_ROOT'):
+ print """\nCannot run ROS: ROS_ROOT is not set.\nPlease set the ROS_ROOT environment variable to the
+location of your ROS install.\n"""
+ sys.exit(-1)
+rosRoot = os.environ['ROS_ROOT']
+
+# Read in the rospy directory location from the 'rospack latest rospy' command
+rospackLatest = os.popen(os.path.join(rosRoot,'rospack')+' latest rospy', 'r')
+rospyDir = rospackLatest.read()
+rospackLatest.close()
+if rospyDir is None or not os.path.isdir(rospyDir.strip()):
+ print "\nERROR: Cannot locate rospy installation.\n"
+ sys.exit(-1)
+
+# Run launcher bootstrapper
+sys.path.append(os.path.join(rospyDir.strip(),'scripts'))
+import launcher
+
+manifestFile = launcher.getManifestFile(sys.argv[0], PKG)
+launcher.init(BOOTSTRAP_VERSION)
+launchCommand, launchArgs, launchEnv = \
+ launcher.getLaunchCommands(manifestFile, MODULE)
+launcher.ready(launchCommand, launchArgs, launchEnv, BOOTSTRAP_VERSION)
+
+######################################################
+# END BOILERPLATE:
+# You may wish to modify the exec command below to
+# customize the behavior of your node, e.g.:
+# * env['FOO'] = bar
+# * launchArgs.append('--test')
+######################################################
+
+os.execvpe(launchCommand, launchArgs, launchEnv)
Property changes on: pkg/trunk/IBPSBatteryInterface/nodes/watchBatteries
___________________________________________________________________
Name: svn:executable
+ *
Modified: pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
===================================================================
--- pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py 2008-03-28 21:17:51 UTC (rev 64)
+++ pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py 2008-03-28 22:18:45 UTC (rev 65)
@@ -150,8 +150,13 @@
for message in control.latest_system_messages:
print message
+ def updateParamServer(self, master):
+ master.setParam('IBPS.current', (self.controllers[0].total_current(),self.controllers[1].total_current(),self.controllers[2].total_current(),self.controllers[3].total_current()))
+ master.setParam('IBPS.voltage', (self.controllers[0].average_voltage(),self.controllers[1].average_voltage(),self.controllers[2].average_voltage(),self.controllers[3].average_voltage()))
+ master.setParam('IBPS.time_remaining', (self.controllers[0].time_remaining,self.controllers[1].time_remaining,self.controllers[2].time_remaining,self.controllers[3].time_remaining))
+ master.setParam('IBPS.average_charge', (self.controllers[0].average_charge,self.controllers[1].average_charge,self.controllers[2].average_charge,self.controllers[3].average_charge))
+
-
def setupPorts():
os.system('stty 19200 </dev/ttyUSB0')
@@ -358,8 +363,7 @@
if time.time() - last_time > increment:
last_time = last_time + increment
myPow.print_remaining()
-
-
+ myPow.updateParamServer(master)
if __name__ == '__main__':
try:
Added: pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/watchBatteries.py
===================================================================
--- pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/watchBatteries.py (rev 0)
+++ pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/watchBatteries.py 2008-03-28 22:18:45 UTC (rev 65)
@@ -0,0 +1,111 @@
+# Software License Agreement (BSD License)
+#
+# Copyright (c) 2008, Willow Garage, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided
+# with the distribution.
+# * Neither the name of the Willow Garage nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+"""
+viewGraph
+
+To run, invoke nodes/viewGraph
+"""
+
+import os, sys, getopt, traceback, logging
+import rospy
+import time
+
+
+NAME = 'watchBatteries'
+
+def usage(stdout, progname):
+ print >>stdout, """%s [-h] [-s SERVER_ADDRESS] [-p SERVER_PORT]
+
+"""%progname+rospy.USAGE_ENV
+
+def viewGraphMain(argv, stdout, env):
+ # default arguments
+ server = "http://localhost"
+ server_port = rospy.DEFAULT_TEST_PORT
+
+ #check arguments for a help flag
+ optlist, args = getopt.getopt(argv[1:], "h?p:s:", ["help","port=","server=","test"])
+ for o, a in optlist:
+ if o in ("-h","-?","--help"):
+ usage(stdout, argv[0])
+ return
+ elif o in ("--test"):
+ server_port = rospy.DEFAULT_TEST_PORT
+ elif o in ("-p", "--port"):
+ server_port = a
+ elif o in ("-s", "--server"):
+ server = a
+
+
+ serverUri = '%s:%s/'%(server,server_port)
+ print "Looking for server at %s"%serverUri
+ os.environ[rospy.ROS_MASTER_URI] = serverUri
+ os.environ[rospy.ROS_NODE] = "watchBatteries"
+ os.environ[rospy.ROS_PORT] = str(0) # any
+
+
+ master = rospy.getMaster()
+ rospy.ready()
+
+ while 1:
+ print "-------------------------------------------------------------------"
+ print "Getting IBPS params from Parameter Server"
+ print "-------------------------------------------------------------------"
+ status_code, statusMessage, current = master.getParam('IBPS.current')
+ print "Current"
+ print current
+ status_code, statusMessage, voltage = master.getParam('IBPS.voltage')
+ print "Voltage"
+ print voltage
+ status_code, statusMessage, time_remaining = master.getParam('IBPS.time_remaining')
+ print "Time Remaining (minutes)"
+ print time_remaining
+ status_code, statusMessage, average_charge = master.getParam('IBPS.average_charge')
+ print "Average Charge"
+ print average_charge
+
+ time.sleep(1.0)
+
+if __name__ == '__main__':
+ try:
+ viewGraphMain(sys.argv, sys.stdout, os.environ)
+ except Exception, e:
+ traceback.print_exc()
+ #attempt to log, may fail if logger is not properly initialized
+ logger = logging.getLogger(NAME)
+ logger.error(str(e)+"\n"+traceback.format_exc())
+ print "Exception is causing %s exit, check log for details"%NAME
+
+ print "exiting"
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tf...@us...> - 2008-03-28 21:18:18
|
Revision: 64
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=64&view=rev
Author: tfoote
Date: 2008-03-28 14:17:51 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
proper registration for viewGraph too
Modified Paths:
--------------
pkg/trunk/exploreGraph/src/exploreGraph/renderGraph.py
pkg/trunk/exploreGraph/src/exploreGraph/viewGraph.py
Modified: pkg/trunk/exploreGraph/src/exploreGraph/renderGraph.py
===================================================================
--- pkg/trunk/exploreGraph/src/exploreGraph/renderGraph.py 2008-03-28 21:17:34 UTC (rev 63)
+++ pkg/trunk/exploreGraph/src/exploreGraph/renderGraph.py 2008-03-28 21:17:51 UTC (rev 64)
@@ -85,7 +85,7 @@
serverUri = '%s:%s/'%(server,server_port)
print "Looking for server at %s"%serverUri
os.environ[rospy.ROS_MASTER_URI] = serverUri
- os.environ[rospy.ROS_NODE] = "viewGraph"
+ os.environ[rospy.ROS_NODE] = NAME
os.environ[rospy.ROS_PORT] = str(0) # any
Modified: pkg/trunk/exploreGraph/src/exploreGraph/viewGraph.py
===================================================================
--- pkg/trunk/exploreGraph/src/exploreGraph/viewGraph.py 2008-03-28 21:17:34 UTC (rev 63)
+++ pkg/trunk/exploreGraph/src/exploreGraph/viewGraph.py 2008-03-28 21:17:51 UTC (rev 64)
@@ -76,6 +76,7 @@
master = rospy.getMaster()
+ rospy.ready()
while 1:
status_code, statusMessage, [nodes,flows] = master.getGraph()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tf...@us...> - 2008-03-28 21:18:06
|
Revision: 63
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=63&view=rev
Author: tfoote
Date: 2008-03-28 14:17:34 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
making IBPS register properly
Modified Paths:
--------------
pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
Modified: pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
===================================================================
--- pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py 2008-03-28 21:17:14 UTC (rev 62)
+++ pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py 2008-03-28 21:17:34 UTC (rev 63)
@@ -181,16 +181,16 @@
serverUri = '%s:%s/'%(server,server_port)
print "Looking for server at %s"%serverUri
os.environ[rospy.ROS_MASTER_URI] = serverUri
- os.environ[rospy.ROS_NODE] = "viewGraph"
+ os.environ[rospy.ROS_NODE] = NAME
os.environ[rospy.ROS_PORT] = str(0) # any
master = rospy.getMaster()
+ rospy.ready()
-
setupPorts()
#f= open('testfile.txt','r')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tf...@us...> - 2008-03-28 21:17:46
|
Revision: 62
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=62&view=rev
Author: tfoote
Date: 2008-03-28 14:17:14 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
removing comitted autogenerated flows
Removed Paths:
-------------
pkg/trunk/pyImageViewer/flows/python/pyImageViewer/pyImageString.py
pkg/trunk/pyImageViewer/src/pyImageViewer/pyImageString.py
Deleted: pkg/trunk/pyImageViewer/flows/python/pyImageViewer/pyImageString.py
===================================================================
--- pkg/trunk/pyImageViewer/flows/python/pyImageViewer/pyImageString.py 2008-03-28 19:00:51 UTC (rev 61)
+++ pkg/trunk/pyImageViewer/flows/python/pyImageViewer/pyImageString.py 2008-03-28 21:17:14 UTC (rev 62)
@@ -1,83 +0,0 @@
-import rospy
-import struct
-import itertools
-class pyImageString(object):
- __slots__ = ['publish_count','stamp_secs','stamp_nsecs','imageString','imageFormat','height','width']
-
- def __init__(self, *args):
- """
- @param args: fields to set, in .flow order. Optionally, stamp_secs and stamp_nsecs may be included as the last two arguments
- """
- self.publish_count = 0
- if args:
- timestampSet = len(args) == 6
- assert len(args) == 4 or timestampSet
- if timestampSet:
- self.stamp_secs = args[-2]
- self.stamp_nsecs = args[-1]
- else:
- self.stamp_secs = self.stamp_nsecs = None
- self.imageString = args[0]
- self.imageFormat = args[1]
- self.height = args[2]
- self.width = args[3]
- else:
- self.stamp_secs = None
- self.stamp_nsecs = None
- self.imageString = None
- self.imageFormat = None
- self.height = None
- self.width = None
-
- def serialize(self, buff):
- buff.write(struct.pack('<iii', self.publish_count, self.stamp_secs, self.stamp_nsecs))
- length = len(self.imageString)
- buff.write(struct.pack('<I%ss'%length, length, self.imageString))
- length = len(self.imageFormat)
- buff.write(struct.pack('<I%ss'%length, length, self.imageFormat))
- buff.write(struct.pack('<II', self.height, self.width))
-
- def deserialize(self, str):
- try:
- if str is None or len(str) == 0:
- raise rospy.DeserializationError, 'buffer underfill'
- end = 0
- start = end
- end += struct.calcsize('<iii')
- (self.publish_count, self.stamp_secs, self.stamp_nsecs,) = struct.unpack('<iii',str[start:end])
- start = end
- end += 4
- (length,) = struct.unpack('<I',str[start:end])
- pattern = '<%ss'%length
- start = end
- end += struct.calcsize(pattern)
- (self.imageString,) = struct.unpack(pattern, str[start:end])
- start = end
- end += 4
- (length,) = struct.unpack('<I',str[start:end])
- pattern = '<%ss'%length
- start = end
- end += struct.calcsize(pattern)
- (self.imageFormat,) = struct.unpack(pattern, str[start:end])
- start = end
- end += struct.calcsize('<II')
- (self.height, self.width,) = struct.unpack('<II',str[start:end])
- return self
- except struct.error, e:
- raise rospy.DeserializationError, e #most likely buffer underfill
-
-class FlowpyImageString(rospy.FlowBase):
-
- def __init__(self, name, direction):
- super(FlowpyImageString, self).__init__(name, direction, 'pyImageViewer/pyImageString')
-
- def _receive(self, str, data=None):
- if not data:
- data = pyImageString()
- return data.deserialize(str)
-class InflowpyImageString(FlowpyImageString):
- def __init__(self, name):
- super(InflowpyImageString, self).__init__(name, 'inflow')
-class OutflowpyImageString(FlowpyImageString):
- def __init__(self, name):
- super(OutflowpyImageString, self).__init__(name, 'outflow')
Deleted: pkg/trunk/pyImageViewer/src/pyImageViewer/pyImageString.py
===================================================================
--- pkg/trunk/pyImageViewer/src/pyImageViewer/pyImageString.py 2008-03-28 19:00:51 UTC (rev 61)
+++ pkg/trunk/pyImageViewer/src/pyImageViewer/pyImageString.py 2008-03-28 21:17:14 UTC (rev 62)
@@ -1,83 +0,0 @@
-import rospy
-import struct
-import itertools
-class pyImageString(object):
- __slots__ = ['publish_count','stamp_secs','stamp_nsecs','imageString','imageFormat','height','width']
-
- def __init__(self, *args):
- """
- @param args: fields to set, in .flow order. Optionally, stamp_secs and stamp_nsecs may be included as the last two arguments
- """
- self.publish_count = 0
- if args:
- timestampSet = len(args) == 6
- assert len(args) == 4 or timestampSet
- if timestampSet:
- self.stamp_secs = args[-2]
- self.stamp_nsecs = args[-1]
- else:
- self.stamp_secs = self.stamp_nsecs = None
- self.imageString = args[0]
- self.imageFormat = args[1]
- self.height = args[2]
- self.width = args[3]
- else:
- self.stamp_secs = None
- self.stamp_nsecs = None
- self.imageString = None
- self.imageFormat = None
- self.height = None
- self.width = None
-
- def serialize(self, buff):
- buff.write(struct.pack('<iii', self.publish_count, self.stamp_secs, self.stamp_nsecs))
- length = len(self.imageString)
- buff.write(struct.pack('<I%ss'%length, length, self.imageString))
- length = len(self.imageFormat)
- buff.write(struct.pack('<I%ss'%length, length, self.imageFormat))
- buff.write(struct.pack('<II', self.height, self.width))
-
- def deserialize(self, str):
- try:
- if str is None or len(str) == 0:
- raise rospy.DeserializationError, 'buffer underfill'
- end = 0
- start = end
- end += struct.calcsize('<iii')
- (self.publish_count, self.stamp_secs, self.stamp_nsecs,) = struct.unpack('<iii',str[start:end])
- start = end
- end += 4
- (length,) = struct.unpack('<I',str[start:end])
- pattern = '<%ss'%length
- start = end
- end += struct.calcsize(pattern)
- (self.imageString,) = struct.unpack(pattern, str[start:end])
- start = end
- end += 4
- (length,) = struct.unpack('<I',str[start:end])
- pattern = '<%ss'%length
- start = end
- end += struct.calcsize(pattern)
- (self.imageFormat,) = struct.unpack(pattern, str[start:end])
- start = end
- end += struct.calcsize('<II')
- (self.height, self.width,) = struct.unpack('<II',str[start:end])
- return self
- except struct.error, e:
- raise rospy.DeserializationError, e #most likely buffer underfill
-
-class FlowpyImageString(rospy.FlowBase):
-
- def __init__(self, name, direction):
- super(FlowpyImageString, self).__init__(name, direction, 'pyImageViewer/pyImageString')
-
- def _receive(self, str, data=None):
- if not data:
- data = pyImageString()
- return data.deserialize(str)
-class InflowpyImageString(FlowpyImageString):
- def __init__(self, name):
- super(InflowpyImageString, self).__init__(name, 'inflow')
-class OutflowpyImageString(FlowpyImageString):
- def __init__(self, name):
- super(OutflowpyImageString, self).__init__(name, 'outflow')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ge...@us...> - 2008-03-28 19:00:51
|
Revision: 61
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=61&view=rev
Author: gerkey
Date: 2008-03-28 12:00:51 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
added simple rosbuild
Added Paths:
-----------
pkg/trunk/erratic_player/rosbuild
Added: pkg/trunk/erratic_player/rosbuild
===================================================================
--- pkg/trunk/erratic_player/rosbuild (rev 0)
+++ pkg/trunk/erratic_player/rosbuild 2008-03-28 19:00:51 UTC (rev 61)
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+make $*
Property changes on: pkg/trunk/erratic_player/rosbuild
___________________________________________________________________
Name: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ge...@us...> - 2008-03-28 19:00:24
|
Revision: 60
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=60&view=rev
Author: gerkey
Date: 2008-03-28 12:00:31 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
added command inflow
Modified Paths:
--------------
pkg/trunk/erratic_player/erratic_player.cc
Modified: pkg/trunk/erratic_player/erratic_player.cc
===================================================================
--- pkg/trunk/erratic_player/erratic_player.cc 2008-03-28 18:22:34 UTC (rev 59)
+++ pkg/trunk/erratic_player/erratic_player.cc 2008-03-28 19:00:31 UTC (rev 60)
@@ -7,8 +7,9 @@
// roscpp
#include <ros/ros_slave.h>
-// I'm using a RobotBase2D flow
-#include <common_flows/FlowRobotBase2D.h>
+// Flows that I need
+#include <common_flows/FlowRobotBase2DOdom.h>
+#include <common_flows/FlowRobotBase2DCmdVel.h>
#define PLAYER_QUEUE_LEN 32
@@ -21,6 +22,9 @@
public:
QueuePointer q;
+ FlowRobotBase2DOdom* odom;
+ FlowRobotBase2DCmdVel* cmdvel;
+
ErraticNode() : ROS_Slave()
{
// libplayercore boiler plate
@@ -62,6 +66,10 @@
// Create a message queue
this->q = QueuePointer(false,PLAYER_QUEUE_LEN);
+
+ this->register_source(this->odom = new FlowRobotBase2DOdom(".odometry"));
+ this->register_sink(this->cmdvel = new FlowRobotBase2DCmdVel(".cmdvel"),
+ ROS_CALLBACK(ErraticNode, cmdvelReceived));
}
~ErraticNode()
@@ -71,7 +79,7 @@
player_globals_fini();
}
- int Start()
+ int start()
{
// Subscribe to device, which causes it to startup
if(this->device->Subscribe(this->q) != 0)
@@ -83,7 +91,7 @@
return(0);
}
- int Stop()
+ int stop()
{
// Unsubscribe from the device, which causes it to shutdown
if(device->Unsubscribe(this->q) != 0)
@@ -95,6 +103,48 @@
return(0);
}
+ int setMotorState(uint8_t state)
+ {
+ Message* msg;
+ // Enable the motors
+ player_position2d_power_config_t motorconfig;
+ motorconfig.state = state;
+ if(!(msg = this->device->Request(this->q,
+ PLAYER_MSGTYPE_REQ,
+ PLAYER_POSITION2D_REQ_MOTOR_POWER,
+ (void*)&motorconfig,
+ sizeof(motorconfig), NULL, false)))
+ {
+ return(-1);
+ }
+ else
+ {
+ delete msg;
+ return(0);
+ }
+ }
+
+ void cmdvelReceived()
+ {
+ printf("received cmd: (%.3f,%.3f,%.3f)\n",
+ this->cmdvel->vx,
+ this->cmdvel->vy,
+ this->cmdvel->vyaw);
+
+ player_position2d_cmd_vel_t cmd;
+ memset(&cmd, 0, sizeof(cmd));
+
+ cmd.vel.px = this->cmdvel->vx;
+ cmd.vel.py = this->cmdvel->vy;
+ cmd.vel.pa = this->cmdvel->vyaw;
+ cmd.state = 1;
+
+ this->device->PutMsg(this->q,
+ PLAYER_MSGTYPE_CMD,
+ PLAYER_POSITION2D_CMD_VEL,
+ (void*)&cmd,sizeof(cmd),NULL);
+ }
+
private:
Driver* driver;
Device* device;
@@ -108,27 +158,12 @@
Message* msg;
// Start up the robot
- if(en.Start() != 0)
+ if(en.start() != 0)
exit(-1);
- // Declare a flow
- FlowRobotBase2D fl(".odometry");
-
-#if 0
// Enable the motors
- player_position2d_power_config_t motorconfig;
- motorconfig.state = 1;
- if(!(msg = this->position->Request(this->InQueue,
- PLAYER_MSGTYPE_REQ,
- PLAYER_POSITION2D_REQ_MOTOR_POWER,
- (void*)&motorconfig,
- sizeof(motorconfig), NULL, false)))
- {
- PLAYER_WARN("failed to enable motors");
- }
- else
- delete msg;
-#endif
+ if(en.setMotorState(1) < 0)
+ puts("failed to enable motors");
/////////////////////////////////////////////////////////////////
// Main loop; grab messages off our queue and republish them via ROS
@@ -149,18 +184,19 @@
player_position2d_data_t* pdata = (player_position2d_data_t*)msg->GetPayload();
// Translate from Player data to ROS data
- fl.px = pdata->pos.px;
- fl.py = pdata->pos.py;
- fl.pyaw = pdata->pos.pa;
- fl.vx = pdata->vel.px;
- fl.vy = pdata->vel.py;
- fl.vyaw = pdata->vel.pa;
- fl.stall = pdata->stall;
+ en.odom->px = pdata->pos.px;
+ en.odom->py = pdata->pos.py;
+ en.odom->pyaw = pdata->pos.pa;
+ en.odom->vx = pdata->vel.px;
+ en.odom->vy = pdata->vel.py;
+ en.odom->vyaw = pdata->vel.pa;
+ en.odom->stall = pdata->stall;
// Publish the new data
- fl.publish();
+ en.odom->publish();
- printf("Published new odom: (%.3f,%.3f,%.3f)\n", fl.px,fl.py,fl.pyaw);
+ printf("Published new odom: (%.3f,%.3f,%.3f)\n",
+ en.odom->px, en.odom->py, en.odom->pyaw);
}
else
{
@@ -178,7 +214,7 @@
/////////////////////////////////////////////////////////////////
// Stop the robot
- en.Stop();
+ en.stop();
// To quote Morgan, Hooray!
return(0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-28 18:22:30
|
Revision: 59
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=59&view=rev
Author: morgan_quigley
Date: 2008-03-28 11:22:34 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
the cv_cam package uses opencv to grab whatever camera it can find. it won't work until i get the image flows running, however, which requires flowgen_cpp to be modernized... TIME2CODE
Modified Paths:
--------------
pkg/trunk/image_viewer/manifest.xml
pkg/trunk/image_viewer/src/image_viewer/image_viewer.cpp
Added Paths:
-----------
pkg/trunk/cv_cam/
pkg/trunk/cv_cam/build.yaml
pkg/trunk/cv_cam/manifest.xml
pkg/trunk/cv_cam/nodes/
pkg/trunk/cv_cam/nodes/test_cv_cam
pkg/trunk/cv_cam/rosbuild
pkg/trunk/cv_cam/src/
pkg/trunk/cv_cam/src/cv_cam/
pkg/trunk/cv_cam/src/cv_cam/Makefile
pkg/trunk/cv_cam/src/cv_cam/cv_cam.cpp
Added: pkg/trunk/cv_cam/build.yaml
===================================================================
--- pkg/trunk/cv_cam/build.yaml (rev 0)
+++ pkg/trunk/cv_cam/build.yaml 2008-03-28 18:22:34 UTC (rev 59)
@@ -0,0 +1,3 @@
+cpp:
+ make:
+ - src/cv_cam
Added: pkg/trunk/cv_cam/manifest.xml
===================================================================
--- pkg/trunk/cv_cam/manifest.xml (rev 0)
+++ pkg/trunk/cv_cam/manifest.xml 2008-03-28 18:22:34 UTC (rev 59)
@@ -0,0 +1,13 @@
+<package>
+<description brief="Simple OpenCV-based camera grabber">
+
+This is a simple program which grabs frames from a V4L device using OpenCV and publishes them.
+
+</description>
+<author>Morgan Quigley (email: mqu...@cs...)</author>
+<license>BSD</license>
+<url>http://stair.stanford.edu</url>
+<depend package="common_flows"/>
+<depend package="opencv"/>
+</package>
+
Added: pkg/trunk/cv_cam/nodes/test_cv_cam
===================================================================
--- pkg/trunk/cv_cam/nodes/test_cv_cam (rev 0)
+++ pkg/trunk/cv_cam/nodes/test_cv_cam 2008-03-28 18:22:34 UTC (rev 59)
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+require "#{`#{ENV['ROS_ROOT']}/rospack latest yamlgraph`}/lib/yamlgraph/ygl.rb"
+g = YAMLGraph.new
+g.param 'cv_cam.show_image',0
+g.node 'cv_cam/cv_cam', {'launch' => 'xterm'}
+g.node 'image_viewer/image_viewer', {'launch' => 'xterm'}
+g.flow 'cv_cam:image','image_viewer:image'
+YAMLGraphLauncher.new.launch g
+
Property changes on: pkg/trunk/cv_cam/nodes/test_cv_cam
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/cv_cam/rosbuild
===================================================================
--- pkg/trunk/cv_cam/rosbuild (rev 0)
+++ pkg/trunk/cv_cam/rosbuild 2008-03-28 18:22:34 UTC (rev 59)
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec("#{`#{ENV['ROS_ROOT']}/rospack find rostools`}/scripts/yamlbuild", 'build.yaml', *ARGV)
Property changes on: pkg/trunk/cv_cam/rosbuild
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/cv_cam/src/cv_cam/Makefile
===================================================================
--- pkg/trunk/cv_cam/src/cv_cam/Makefile (rev 0)
+++ pkg/trunk/cv_cam/src/cv_cam/Makefile 2008-03-28 18:22:34 UTC (rev 59)
@@ -0,0 +1,5 @@
+SRC = cv_cam.cpp
+OUT = ../../nodes/cv_cam
+PKG = cv_cam
+LFLAGS = -lhighgui
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Added: pkg/trunk/cv_cam/src/cv_cam/cv_cam.cpp
===================================================================
--- pkg/trunk/cv_cam/src/cv_cam/cv_cam.cpp (rev 0)
+++ pkg/trunk/cv_cam/src/cv_cam/cv_cam.cpp 2008-03-28 18:22:34 UTC (rev 59)
@@ -0,0 +1,96 @@
+///////////////////////////////////////////////////////////////////////////////
+// The cv_cam package provides a simple node which grabs images from a camera
+// using OpenCV and publishes them.
+//
+// Copyright (C) 2008, Morgan Quigley
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#include "ros/ros_slave.h"
+#include "common_flows/FlowImage.h"
+#include "common_flows/ImageCvBridge.h"
+#include "opencv/highgui.h"
+
+class CVCam : public ROS_Slave
+{
+public:
+ FlowImage *image_f;
+ ImageCvBridge<FlowImage> *cv_bridge;
+ CvCapture *capture;
+ IplImage *cam_image;
+ double last_image_time;
+ int show_image;
+
+ CVCam() : ROS_Slave(), last_image_time(0), show_image(0)
+ {
+ register_source(image_f = new FlowImage("image"));
+ image_f->frame_id = 0; // frame is zero unless specified
+ get_int_param(".frame_id", &image_f->frame_id);
+ get_int_param(".show_image", &show_image);
+ cv_bridge = new ImageCvBridge<FlowImage>(image_f);
+ capture = cvCaptureFromCAM(CV_CAP_ANY);
+ if (!capture)
+ log(ROS::ERROR,"woah! couldn't open a camera. is one connected?\n");
+ }
+ virtual ~CVCam()
+ {
+ if (capture)
+ cvReleaseCapture(&capture);
+ }
+ bool take_and_send_picture()
+ {
+ if (!capture)
+ return false;
+ cam_image = cvQueryFrame(capture);
+ double t = runtime();
+ double dt = t - last_image_time;
+ printf("dt = %f\t(%f fps)\n", dt, 1.0 / dt);
+ last_image_time = t;
+ if (show_image)
+ cvShowImage("CV Cam", cam_image);
+ image_f->compression = "raw";
+ cv_bridge->from_cv(cam_image);
+ cv_bridge->set_flow_data();
+ image_f->publish();
+ return true;
+ }
+};
+
+int main(int argc, char **argv)
+{
+ CVCam a;
+ if (a.show_image)
+ cvNamedWindow("CV Cam", CV_WINDOW_AUTOSIZE);
+ while (a.happy())
+ {
+ if (a.show_image)
+ cvWaitKey(5);
+ if (!a.take_and_send_picture())
+ usleep(100000);
+ }
+ if (a.show_image)
+ cvDestroyWindow("CV Cam");
+ return 0;
+}
+
Modified: pkg/trunk/image_viewer/manifest.xml
===================================================================
--- pkg/trunk/image_viewer/manifest.xml 2008-03-28 18:08:35 UTC (rev 58)
+++ pkg/trunk/image_viewer/manifest.xml 2008-03-28 18:22:34 UTC (rev 59)
@@ -6,7 +6,7 @@
<license>BSD</license>
<url>http://stair.stanford.edu</url>
<depend package="roscpp"/>
-<depend package="image_flows"/>
+<depend package="common_flows"/>
<depend package="sdl"/>
</package>
Modified: pkg/trunk/image_viewer/src/image_viewer/image_viewer.cpp
===================================================================
--- pkg/trunk/image_viewer/src/image_viewer/image_viewer.cpp 2008-03-28 18:08:35 UTC (rev 58)
+++ pkg/trunk/image_viewer/src/image_viewer/image_viewer.cpp 2008-03-28 18:22:34 UTC (rev 59)
@@ -40,7 +40,8 @@
ImageViewer() : ROS_Slave(), blit_prep(NULL)
{
- register_sink(image = new FlowImage("image"), ROS_CALLBACK(ImageViewer, image_received));
+ register_sink(image = new FlowImage("image"),
+ ROS_CALLBACK(ImageViewer, image_cb));
codec = new ImageFlowCodec<FlowImage>(image);
register_with_master();
}
@@ -50,12 +51,13 @@
screen = SDL_SetVideoMode(320, 240, 24, 0);
return (screen ? true : false);
}
- void image_received()
+ void image_cb()
{
if (!screen)
return; // paranoia. shouldn't happen. we should have bailed by now.
if (screen->h != image->height || screen->w != image->width)
{
+ printf("resizing for a %d by %d image\n", image->width, image->height);
screen = SDL_SetVideoMode(image->width, image->height, 24, 0);
if (!screen)
{
@@ -64,7 +66,9 @@
exit(1);
}
}
- if (!blit_prep || blit_prep->w != image->width || blit_prep->h != image->width)
+ if (!blit_prep ||
+ blit_prep->w != image->width ||
+ blit_prep->h != image->width)
{
if (blit_prep)
SDL_FreeSurface(blit_prep);
@@ -120,9 +124,7 @@
exit(1);
}
while (v.happy())
- {
usleep(1000000);
- }
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-28 18:08:32
|
Revision: 58
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=58&view=rev
Author: morgan_quigley
Date: 2008-03-28 11:08:35 -0700 (Fri, 28 Mar 2008)
Log Message:
-----------
add package dependency on ffmpeg for opencv
Modified Paths:
--------------
pkg/trunk/opencv/manifest.xml
Modified: pkg/trunk/opencv/manifest.xml
===================================================================
--- pkg/trunk/opencv/manifest.xml 2008-03-28 02:05:43 UTC (rev 57)
+++ pkg/trunk/opencv/manifest.xml 2008-03-28 18:08:35 UTC (rev 58)
@@ -12,5 +12,6 @@
<author>Gary Bradski and many others. See web page for a full contributor list. ROS package maintained by Morgan Quigley.</author>
<license>BSD</license>
<url>http://opencvlibrary.sourceforge.net</url>
+<depend package="ffmpeg"/>
</package>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-28 02:05:39
|
Revision: 57
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=57&view=rev
Author: morgan_quigley
Date: 2008-03-27 19:05:43 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
major changes to axis_cam to bring in functionality first implemented by jeremy: get/set focus and get/set iris, as well as using libcurl for everything (prior to today it was using wget for ptz)
Modified Paths:
--------------
pkg/trunk/axis_cam/include/axis_cam/axis_cam.h
pkg/trunk/axis_cam/manifest.xml
pkg/trunk/axis_cam/src/axis_cam/axis_cam.cpp
pkg/trunk/axis_cam/src/libaxis_cam/axis_cam.cpp
Added Paths:
-----------
pkg/trunk/axis_cam/test/test_camcontrol/
pkg/trunk/axis_cam/test/test_camcontrol/Makefile
pkg/trunk/axis_cam/test/test_camcontrol/kbhit.cpp
pkg/trunk/axis_cam/test/test_camcontrol/kbhit.h
pkg/trunk/axis_cam/test/test_camcontrol/test_camcontrol.cpp
Modified: pkg/trunk/axis_cam/include/axis_cam/axis_cam.h
===================================================================
--- pkg/trunk/axis_cam/include/axis_cam/axis_cam.h 2008-03-28 01:57:04 UTC (rev 56)
+++ pkg/trunk/axis_cam/include/axis_cam/axis_cam.h 2008-03-28 02:05:43 UTC (rev 57)
@@ -32,6 +32,7 @@
#include <curl/curl.h>
#include <string>
+#include <sstream>
using namespace std;
class AxisCam
@@ -41,19 +42,30 @@
~AxisCam();
bool get_jpeg(uint8_t ** const fetch_jpeg_buf, uint32_t *fetch_buf_size);
- bool ptz(double pan, double tilt, double zoom);
+ bool set_ptz(double pan, double tilt, double zoom, bool relative = false);
+ bool set_focus(int focus = 0, bool relative = false); // zero for autofocus
+ int get_focus();
+ bool set_iris(int iris = 0, bool relative = false); // zero for autoiris
+ int get_iris();
private:
string ip;
uint8_t *jpeg_buf;
uint32_t jpeg_buf_size, jpeg_file_size;
- CURL *jpeg_curl;
+ CURL *jpeg_curl, *getptz_curl, *setptz_curl;
+ char *image_url, *ptz_url;
+ stringstream ptz_ss; // need to mutex this someday...
inline double clamp(double d, double low, double high)
{
return (d < low ? low : (d > high ? high : d));
}
static size_t jpeg_write(void *buf, size_t size, size_t nmemb, void *userp);
- char *image_url;
+ static size_t ptz_write(void *buf, size_t size, size_t nmemb, void *userp);
+ bool send_params(string params);
+ bool query_params();
+ int last_iris, last_focus;
+ double last_pan, last_tilt, last_zoom;
+ bool last_autofocus_enabled, last_autoiris_enabled;
};
#endif
Modified: pkg/trunk/axis_cam/manifest.xml
===================================================================
--- pkg/trunk/axis_cam/manifest.xml 2008-03-28 01:57:04 UTC (rev 56)
+++ pkg/trunk/axis_cam/manifest.xml 2008-03-28 02:05:43 UTC (rev 57)
@@ -13,5 +13,6 @@
<url>http://stair.stanford.edu</url>
<depend package="common_flows"/>
<depend package="image_viewer"/>
+<depend package="string_utils"/>
</package>
Modified: pkg/trunk/axis_cam/src/axis_cam/axis_cam.cpp
===================================================================
--- pkg/trunk/axis_cam/src/axis_cam/axis_cam.cpp 2008-03-28 01:57:04 UTC (rev 56)
+++ pkg/trunk/axis_cam/src/axis_cam/axis_cam.cpp 2008-03-28 02:05:43 UTC (rev 57)
@@ -28,10 +28,10 @@
// POSSIBILITY OF SUCH DAMAGE.
#include "ros/ros_slave.h"
-#include "image_flows/FlowImage.h"
+#include "common_flows/FlowImage.h"
#include "axis_cam/axis_cam.h"
-class AxisCamWget : public ROS_Slave
+class AxisCamNode : public ROS_Slave
{
public:
FlowImage *image;
@@ -39,7 +39,7 @@
AxisCam *cam;
int frame_id;
- AxisCamWget() : ROS_Slave(), cam(NULL), frame_id(0)
+ AxisCamNode() : ROS_Slave(), cam(NULL), frame_id(0)
{
register_source(image = new FlowImage("image"));
if (!get_string_param(".host", axis_host))
@@ -52,7 +52,7 @@
cam = new AxisCam(axis_host);
printf("package path is [%s]\n", get_my_package_path().c_str());
}
- virtual ~AxisCamWget()
+ virtual ~AxisCamNode()
{
if (cam)
delete cam;
@@ -80,7 +80,7 @@
int main(int argc, char **argv)
{
- AxisCamWget a;
+ AxisCamNode a;
while (a.happy())
if (!a.take_and_send_image())
{
Modified: pkg/trunk/axis_cam/src/libaxis_cam/axis_cam.cpp
===================================================================
--- pkg/trunk/axis_cam/src/libaxis_cam/axis_cam.cpp 2008-03-28 01:57:04 UTC (rev 56)
+++ pkg/trunk/axis_cam/src/libaxis_cam/axis_cam.cpp 2008-03-28 02:05:43 UTC (rev 57)
@@ -29,7 +29,9 @@
// POSSIBILITY OF SUCH DAMAGE.
#include <sstream>
+#include <iostream>
#include "axis_cam/axis_cam.h"
+#include "string_utils/string_utils.h"
AxisCam::AxisCam(string ip) : ip(ip)
{
@@ -42,12 +44,34 @@
image_url = new char[oss.str().length()+1];
strcpy(image_url, oss.str().c_str());
+ oss.str(""); // clear it
+ oss << "http://" << ip << "/axis-cgi/com/ptz.cgi";
+ ptz_url = new char[oss.str().length()+1];
+ strcpy(ptz_url, oss.str().c_str());
+
jpeg_curl = curl_easy_init();
curl_easy_setopt(jpeg_curl, CURLOPT_URL, image_url);
curl_easy_setopt(jpeg_curl, CURLOPT_WRITEFUNCTION, AxisCam::jpeg_write);
curl_easy_setopt(jpeg_curl, CURLOPT_WRITEDATA, this);
- printf("Getting images from [%s]", oss.str().c_str());
+ getptz_curl = curl_easy_init();
+ curl_easy_setopt(getptz_curl, CURLOPT_URL, ptz_url);
+ curl_easy_setopt(getptz_curl, CURLOPT_WRITEFUNCTION, AxisCam::ptz_write);
+ curl_easy_setopt(getptz_curl, CURLOPT_WRITEDATA, this);
+ curl_easy_setopt(getptz_curl, CURLOPT_POSTFIELDS, "query=position");
+
+ setptz_curl = curl_easy_init();
+ curl_easy_setopt(setptz_curl, CURLOPT_URL, ptz_url);
+ curl_easy_setopt(setptz_curl, CURLOPT_WRITEFUNCTION, AxisCam::ptz_write);
+ curl_easy_setopt(setptz_curl, CURLOPT_WRITEDATA, this);
+
+ printf("Getting images from [%s]\n", oss.str().c_str());
+ if (!query_params())
+ printf("sad! I couldn't query the camera parameters.\n");
+ if (!query_params())
+ printf("sad! I couldn't query the camera parameters.\n");
+ if (!query_params())
+ printf("sad! I couldn't query the camera parameters.\n");
}
AxisCam::~AxisCam()
@@ -101,45 +125,121 @@
a->jpeg_file_size += size*nmemb;
return size*nmemb;
}
+
+size_t AxisCam::ptz_write(void *buf, size_t size, size_t nmemb, void *userp)
+{
+ if (size * nmemb == 0)
+ return 0;
+ AxisCam *a = (AxisCam *)userp;
+ a->ptz_ss << string((char *)buf, size*nmemb);
+ printf("%d bytes\n", size*nmemb);
+ //cout << string((char *)buf, size*nmemb);
+ return size*nmemb;
+}
+
+bool AxisCam::set_ptz(double pan, double tilt, double zoom, bool relative)
+{
+ ostringstream oss;
+ if (relative)
+ oss << "rpan=" << pan
+ << "&rtilt=" << tilt
+ << "&rzoom=" << zoom;
+ else
+ oss << "pan=" << clamp(pan, -175, 175)
+ << "&tilt=" << clamp(tilt, -45, 90)
+ << "&zoom=" << clamp(zoom, 0, 50000); // not sure of upper bound
+ return send_params(oss.str());
+}
+
+int AxisCam::get_focus()
+{
+ if (last_autofocus_enabled)
+ {
+ set_focus(0, true); // manual focus but don't move it
+ query_params();
+ set_focus(0); // re-enable autofocus
+ return last_focus;
+ }
+ query_params();
+ return last_focus;
+}
- /*
- if (jpeg_file_size > jpeg_buf_size)
+bool AxisCam::set_focus(int focus, bool relative)
+{
+ ostringstream oss;
+ if (focus == 0 && !relative)
+ oss << string("autofocus=on");
+ else
{
- if (jpeg_buf)
- delete[] jpeg_buf;
- jpeg_buf_size = (uint32_t)(1.5*jpeg_file_size);
- jpeg_buf = new uint8_t[jpeg_buf_size]; // go big to save reallocs
+ last_autofocus_enabled = false;
+ oss << string("autofocus=off&")
+ << (relative ? "r" : "") << string("focus=") << focus;
}
- size_t bytes_read = fread(jpeg_buf, 1, jpeg_file_size, jpeg_file);
- if (bytes_read != jpeg_file_size)
+ return send_params(oss.str());
+}
+
+bool AxisCam::set_iris(int iris, bool relative)
+{
+ ostringstream oss;
+ if (iris == 0)
+ oss << "autoiris=on";
+ else
+ oss << string("autoiris=off&")
+ << (relative ? "r" : "") << string("iris=") << iris;
+ return send_params(oss.str());
+}
+
+bool AxisCam::send_params(string params)
+{
+ ptz_ss.str("");
+ curl_easy_setopt(setptz_curl, CURLOPT_POSTFIELDS, params.c_str());
+ CURLcode code;
+ if (code = curl_easy_perform(setptz_curl))
{
- printf("couldn't read entire jpeg file\n");
+ printf("woah! curl error: [%s]\n", curl_easy_strerror(code));
return false;
}
- fclose(jpeg_file);
- *fetch_jpeg_buf = jpeg_buf;
- *fetch_buf_size = jpeg_file_size;
- */
+ return true;
+}
-bool AxisCam::ptz(double pan, double tilt, double zoom)
+bool AxisCam::query_params()
{
- pan = clamp(pan, -175, 175);
- tilt = clamp(tilt, -45, 90);
- zoom = clamp(zoom, 0, 50000); // not sure of the real upper bound. units are rather magical.
- ostringstream oss;
- oss << string("wget -q -O/dev/null \"") << ip << string("/axis-cgi/com/ptz.cgi?camera=1&pan=") << pan
- << string("&tilt=") << tilt << string("&zoom=") << zoom << string("\"");
- //printf("about to execute: [%s]\n", oss.str().c_str());
- int retval = system(oss.str().c_str());
- if (retval > 0)
+ ptz_ss.str("");
+ CURLcode code;
+ if (code = curl_easy_perform(getptz_curl))
{
- printf("ahhh nonzero return value from wget during ptz: %d\n", retval);
+ printf("woah! curl error: [%s]\n", curl_easy_strerror(code));
return false;
}
- else if (retval < 0)
+ printf("response:\n%s\n", ptz_ss.str().c_str());
+ while (ptz_ss.good())
{
- // not sure what's happening here, but it appears to be benign.
- //printf("odd wget system retval = %d\n", retval);
+ string line;
+ getline(ptz_ss, line);
+ vector<string> tokens;
+ string_utils::split(line, tokens, "=");
+ if (tokens.size() != 2)
+ continue;
+ if (tokens[0] == string("pan"))
+ last_pan = atof(tokens[1].c_str());
+ else if (tokens[0] == string("tilt"))
+ last_tilt = atof(tokens[1].c_str());
+ else if (tokens[0] == string("zoom"))
+ last_zoom = atof(tokens[1].c_str());
+ else if (tokens[0] == string("focus"))
+ last_focus = atoi(tokens[1].c_str());
+ else if (tokens[0] == string("iris"))
+ last_iris = atoi(tokens[1].c_str());
+ else if (tokens[0] == string("autofocus"))
+ last_autofocus_enabled = (tokens[1] == string("on") ? true : false);
+ else if (tokens[0] == string("autoiris"))
+ last_autoiris_enabled = (tokens[1] == string("on") ? true : false);
+/*
+ printf("line has %d tokens:\n", tokens.size());
+ for (int i = 0; i < tokens.size(); i++)
+ printf(" [%s] ", tokens[i].c_str());
+ printf("\n");
+*/
}
return true;
}
Added: pkg/trunk/axis_cam/test/test_camcontrol/Makefile
===================================================================
--- pkg/trunk/axis_cam/test/test_camcontrol/Makefile (rev 0)
+++ pkg/trunk/axis_cam/test/test_camcontrol/Makefile 2008-03-28 02:05:43 UTC (rev 57)
@@ -0,0 +1,6 @@
+SRC = test_camcontrol.cpp kbhit.cpp
+OUT = test_camcontrol
+LFLAGS = -L../../lib -laxis_cam -lcurl -lstring_utils
+LIBDEPS = ../../lib/libaxis_cam.a
+PKG = axis_cam
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Added: pkg/trunk/axis_cam/test/test_camcontrol/kbhit.cpp
===================================================================
--- pkg/trunk/axis_cam/test/test_camcontrol/kbhit.cpp (rev 0)
+++ pkg/trunk/axis_cam/test/test_camcontrol/kbhit.cpp 2008-03-28 02:05:43 UTC (rev 57)
@@ -0,0 +1,51 @@
+#include "kbhit.h"
+#include <termios.h>
+#include <unistd.h>
+
+static struct termios initial_settings, new_settings;
+static int peek_character = -1;
+
+void init_keyboard()
+{
+ tcgetattr(0, &initial_settings);
+ new_settings = initial_settings;
+ new_settings.c_lflag &= ~ICANON;
+ new_settings.c_lflag &= ~ECHO;
+// new_settings.c_lflag &= ~ISIG;
+ new_settings.c_cc[VMIN] = 1;
+ new_settings.c_cc[VTIME] = 0;
+ tcsetattr(0, TCSANOW, &new_settings);
+}
+
+void close_keyboard()
+{
+ tcsetattr(0, TCSANOW, &initial_settings);
+}
+
+int _kbhit()
+{
+ unsigned char ch;
+ int nread;
+ new_settings.c_cc[VMIN] = 0;
+ tcsetattr(0, TCSANOW, &new_settings);
+ nread = read(0, &ch, 1);
+ new_settings.c_cc[VMIN] = 1;
+ tcsetattr(0, TCSANOW, &new_settings);
+ if (nread == 1)
+ {
+ peek_character = ch;
+ return 1;
+ }
+ else
+ {
+ peek_character = 0;
+ return 0;
+ }
+}
+
+char _getch()
+{
+ char c = peek_character;
+ peek_character = 0;
+ return c;
+}
Added: pkg/trunk/axis_cam/test/test_camcontrol/kbhit.h
===================================================================
--- pkg/trunk/axis_cam/test/test_camcontrol/kbhit.h (rev 0)
+++ pkg/trunk/axis_cam/test/test_camcontrol/kbhit.h 2008-03-28 02:05:43 UTC (rev 57)
@@ -0,0 +1,13 @@
+#ifndef KBHIT_H
+#define KBHIT_H
+
+// this code copied from linux-sys.org, where it was copied from "Beginning
+// Linux Programming" a book by Wrox Press
+
+void init_keyboard(void);
+void close_keyboard(void);
+int _kbhit(void);
+char _getch(void);
+
+#endif
+
Added: pkg/trunk/axis_cam/test/test_camcontrol/test_camcontrol.cpp
===================================================================
--- pkg/trunk/axis_cam/test/test_camcontrol/test_camcontrol.cpp (rev 0)
+++ pkg/trunk/axis_cam/test/test_camcontrol/test_camcontrol.cpp 2008-03-28 02:05:43 UTC (rev 57)
@@ -0,0 +1,91 @@
+///////////////////////////////////////////////////////////////////////////////
+// The axis_cam package provides a library that talks to Axis IP-based cameras
+// as well as ROS nodes which use these libraries
+//
+// This file Copyright (C) 2008, Morgan Quigley
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#include <cstdio>
+#include "axis_cam/axis_cam.h"
+#include "kbhit.h"
+
+int main(int argc, char **argv)
+{
+ AxisCam *axis = new AxisCam("192.168.1.90");
+
+ init_keyboard();
+ int focus = 2000, iris = 2000;
+ while (1)
+ {
+ if (_kbhit())
+ {
+ char c = _getch();
+ if (c == 'q')
+ break;
+ switch(c)
+ {
+ case 'F':
+ printf("enabling autofocus\n");
+ axis->set_focus(0);
+ break;
+ case 'f':
+ focus += 500;
+ printf("focus = %d\n", focus);
+ axis->set_focus(focus);
+ break;
+ case 'd':
+ focus -= 500;
+ printf("focus = %d\n", focus);
+ axis->set_focus(focus);
+ break;
+ case 'I':
+ printf("enabling autoiris\n");
+ axis->set_iris(0);
+ break;
+ case 'i':
+ iris += 500;
+ printf("iris = %d\n", iris);
+ axis->set_iris(iris);
+ break;
+ case 'u':
+ iris -= 500;
+ printf("iris = %d\n", iris);
+ axis->set_iris(iris);
+ break;
+ case '?':
+ printf("focus: [%d]\n", axis->get_focus());
+ break;
+ default:
+ printf("unknown char [%c]\n", c);
+ }
+ }
+ usleep(10000);
+ }
+ close_keyboard();
+
+ delete axis;
+ return 0;
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ge...@us...> - 2008-03-28 01:56:59
|
Revision: 56
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=56&view=rev
Author: gerkey
Date: 2008-03-27 18:57:04 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
added wrapped Player erratic driver
Added Paths:
-----------
pkg/trunk/erratic_player/
pkg/trunk/erratic_player/Makefile
pkg/trunk/erratic_player/erratic_player.cc
pkg/trunk/erratic_player/manifest.xml
pkg/trunk/erratic_player/nodes/
Added: pkg/trunk/erratic_player/Makefile
===================================================================
--- pkg/trunk/erratic_player/Makefile (rev 0)
+++ pkg/trunk/erratic_player/Makefile 2008-03-28 01:57:04 UTC (rev 56)
@@ -0,0 +1,12 @@
+CPP = g++
+AR = ar
+CPPFLAGS = -g -Wall -Werror `pkg-config --cflags playercore playerxdr playerutils playerdrivers` `rospack cflags roscpp` `rospack cflags common_flows`
+LDFLAGS = `pkg-config --libs playercore playerxdr playerutils playerdrivers` `rospack lflags roscpp` `rospack lflags common_flows`
+
+all: nodes/erratic_player
+
+nodes/erratic_player: erratic_player.cc
+ $(CPP) $(CPPFLAGS) -o $@ $< $(LDFLAGS)
+
+clean:
+ rm -f *.o nodes/erratic_player
Added: pkg/trunk/erratic_player/erratic_player.cc
===================================================================
--- pkg/trunk/erratic_player/erratic_player.cc (rev 0)
+++ pkg/trunk/erratic_player/erratic_player.cc 2008-03-28 01:57:04 UTC (rev 56)
@@ -0,0 +1,185 @@
+#include <assert.h>
+
+// For core Player stuff (message queues, config file objects, etc.)
+#include <libplayercore/playercore.h>
+// TODO: remove XDR dependency
+#include <libplayerxdr/playerxdr.h>
+
+// roscpp
+#include <ros/ros_slave.h>
+// I'm using a RobotBase2D flow
+#include <common_flows/FlowRobotBase2D.h>
+
+#define PLAYER_QUEUE_LEN 32
+
+// Must prototype this function here. It's implemented inside
+// libplayerdrivers.
+Driver* Erratic_Init(ConfigFile* cf, int section);
+
+class ErraticNode: public ROS_Slave
+{
+ public:
+ QueuePointer q;
+
+ ErraticNode() : ROS_Slave()
+ {
+ // libplayercore boiler plate
+ player_globals_init();
+ itable_init();
+
+ // TODO: remove XDR dependency
+ playerxdr_ftable_init();
+
+ // The Player address that will be assigned to this device. The format
+ // is interface:index. The interface must match what the driver is
+ // expecting to provide. The value of the index doesn't really matter,
+ // but 0 is most common.
+ const char* player_addr = "position2d:0";
+
+ // Create a ConfigFile object, into which we'll stuff parameters.
+ // Drivers assume that this object will persist throughout execution
+ // (e.g., they store pointers to data inside it). So it must NOT be
+ // deleted until after the driver is shut down.
+ this->cf = new ConfigFile();
+
+ // Insert (name,value) pairs into the ConfigFile object. These would
+ // presumably come from the param server
+ this->cf->InsertFieldValue(0,"provides",player_addr);
+ this->cf->InsertFieldValue(0,"port","/dev/ttyUSB0");
+
+ // Create an instance of the driver, passing it the ConfigFile object.
+ // The -1 tells it to look into the "global" section of the ConfigFile,
+ // which is where ConfigFile::InsertFieldValue() put the parameters.
+ assert((this->driver = Erratic_Init(cf, -1)));
+
+ // Print out warnings about parameters that were set, but which the
+ // driver never looked at.
+ cf->WarnUnused();
+
+ // Grab from the global deviceTable a pointer to the Device that was
+ // created as part of the driver's initialization.
+ assert((this->device = deviceTable->GetDevice(player_addr,false)));
+
+ // Create a message queue
+ this->q = QueuePointer(false,PLAYER_QUEUE_LEN);
+ }
+
+ ~ErraticNode()
+ {
+ delete driver;
+ delete cf;
+ player_globals_fini();
+ }
+
+ int Start()
+ {
+ // Subscribe to device, which causes it to startup
+ if(this->device->Subscribe(this->q) != 0)
+ {
+ puts("Failed to subscribe the driver");
+ return(-1);
+ }
+ else
+ return(0);
+ }
+
+ int Stop()
+ {
+ // Unsubscribe from the device, which causes it to shutdown
+ if(device->Unsubscribe(this->q) != 0)
+ {
+ puts("Failed to start the driver");
+ return(-1);
+ }
+ else
+ return(0);
+ }
+
+ private:
+ Driver* driver;
+ Device* device;
+ ConfigFile* cf;
+};
+
+int
+main(void)
+{
+ ErraticNode en;
+ Message* msg;
+
+ // Start up the robot
+ if(en.Start() != 0)
+ exit(-1);
+
+ // Declare a flow
+ FlowRobotBase2D fl(".odometry");
+
+#if 0
+ // Enable the motors
+ player_position2d_power_config_t motorconfig;
+ motorconfig.state = 1;
+ if(!(msg = this->position->Request(this->InQueue,
+ PLAYER_MSGTYPE_REQ,
+ PLAYER_POSITION2D_REQ_MOTOR_POWER,
+ (void*)&motorconfig,
+ sizeof(motorconfig), NULL, false)))
+ {
+ PLAYER_WARN("failed to enable motors");
+ }
+ else
+ delete msg;
+#endif
+
+ /////////////////////////////////////////////////////////////////
+ // Main loop; grab messages off our queue and republish them via ROS
+ for(;;)
+ {
+ // Block until there's a message on the queue
+ en.q->Wait();
+
+ // Pop off one message (we own the resulting memory)
+ assert((msg = en.q->Pop()));
+
+ // Is the message one we care about?
+ player_msghdr_t* hdr = msg->GetHeader();
+ if((hdr->type == PLAYER_MSGTYPE_DATA) &&
+ (hdr->subtype == PLAYER_POSITION2D_DATA_STATE))
+ {
+ // Cast the message payload appropriately
+ player_position2d_data_t* pdata = (player_position2d_data_t*)msg->GetPayload();
+
+ // Translate from Player data to ROS data
+ fl.px = pdata->pos.px;
+ fl.py = pdata->pos.py;
+ fl.pyaw = pdata->pos.pa;
+ fl.vx = pdata->vel.px;
+ fl.vy = pdata->vel.py;
+ fl.vyaw = pdata->vel.pa;
+ fl.stall = pdata->stall;
+
+ // Publish the new data
+ fl.publish();
+
+ printf("Published new odom: (%.3f,%.3f,%.3f)\n", fl.px,fl.py,fl.pyaw);
+ }
+ else
+ {
+ printf("%d:%d:%d:%d\n",
+ hdr->type,
+ hdr->subtype,
+ hdr->addr.interf,
+ hdr->addr.index);
+
+ }
+
+ // We're done with the message now
+ delete msg;
+ }
+ /////////////////////////////////////////////////////////////////
+
+ // Stop the robot
+ en.Stop();
+
+ // To quote Morgan, Hooray!
+ return(0);
+}
Added: pkg/trunk/erratic_player/manifest.xml
===================================================================
--- pkg/trunk/erratic_player/manifest.xml (rev 0)
+++ pkg/trunk/erratic_player/manifest.xml 2008-03-28 01:57:04 UTC (rev 56)
@@ -0,0 +1,7 @@
+<package>
+ <description>A ROS node that wraps up the Player erratic driver, which provides access to the Erratic mobile robot.</description>
+ <author>Brian P. Gerkey</author>
+ <license>BSD</license>
+ <depend package="roscpp" />
+ <depend package="common_flows" />
+</package>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tf...@us...> - 2008-03-28 01:51:10
|
Revision: 55
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=55&view=rev
Author: tfoote
Date: 2008-03-27 18:51:17 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
moving functionality of parseIBPS inside of monitorBatteries to allow easier integration with param server
Modified Paths:
--------------
pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/parseIBPS.py
Modified: pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
===================================================================
--- pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py 2008-03-28 01:36:42 UTC (rev 54)
+++ pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py 2008-03-28 01:51:17 UTC (rev 55)
@@ -39,7 +39,10 @@
import os, sys, getopt, traceback, logging
import rospy
import time
-import IBPSBatteryInterface.parseIBPS
+import operator
+import select
+import time
+import os
NAME = 'monitorBatteries'
@@ -48,6 +51,115 @@
"""%progname+rospy.USAGE_ENV
+# returns total as checksum
+# input - string
+def checksum(st):
+ return reduce(operator.add, map(ord, st))
+# returns total mod 256 as checksum
+# input - string
+def checksum256(st):
+ return reduce(operator.add, map(ord, st)) % 256
+# return reduce(operator.add, map(ord, st)) % 256
+
+def hex2dec(s):
+ """return the integer value of a hexadecimal string s"""
+ return int(s, 16)
+
+def readmask(hexstr):
+ char = hex2dec(hexstr)
+ mask = []
+ for i in range(0,8):
+ if char & (1 << i):
+ mask.append(True)
+ else:
+ mask.append(False)
+ return mask
+
+
+#todo: automatically set
+# set serial ports to 19200
+# the same as doing below
+# stty 19200 </dev/ttyUSBX
+
+
+class powerBattery:
+ def __init__(self):
+ self.present = False
+ self.charging = False
+ self.supplying_power = False
+ self.w_charge_power = False
+ self.power_no_good = False
+ self.charge_inhibited = False
+ self.voltage = 0.0
+ self.current = 0.0
+ self.error = False
+
+class powerController:
+ def __init__(self):
+ self.time_remaining = 0
+ self.average_charge = 0
+ self.batteries = [powerBattery(),powerBattery(),powerBattery(),powerBattery(),powerBattery(),powerBattery(),powerBattery(),powerBattery()]
+ self.latest_system_messages = []
+
+ def new_system_message(self, mess):
+ self.latest_system_messages.append(mess)
+ while len(self.latest_system_messages) > 10:
+ self.latest_system_messages.pop(0)
+
+ def total_current(self):
+ total_current = 0.0;
+ for batt in self.batteries:
+ total_current += batt.current
+ return total_current
+
+ def average_voltage(self):
+ total_voltage = 0.0;
+ count = 0
+ for batt in self.batteries:
+ if batt.present:
+ total_voltage += batt.voltage
+ count += 1
+
+ if count == 0:
+ return 0.0
+ else:
+ return total_voltage/float(count)
+
+class robotPower:
+ def __init__(self):
+ print "made robot power"
+ self.controllers = [powerController(),powerController(),powerController(),powerController()]
+
+ def print_remaining(self):
+ print "___________________________________"
+ print "Battery Controller Information:"
+ print "-----------------------------------"
+ print 'time remaining per battery pack in minutes'
+ print '1: %d, 2:%d, 3:%d, 4:%d'%(self.controllers[0].time_remaining,self.controllers[1].time_remaining,self.controllers[2].time_remaining,self.controllers[3].time_remaining)
+ print "average charge percentage"
+ print '1: %d, 2:%d, 3:%d, 4:%d'%(self.controllers[0].average_charge,self.controllers[1].average_charge,self.controllers[2].average_charge,self.controllers[3].average_charge)
+ print "total_current"
+ print '1: %f, 2:%f, 3:%f, 4:%f'%(self.controllers[0].total_current(),self.controllers[1].total_current(),self.controllers[2].total_current(),self.controllers[3].total_current())
+ print "average_voltage"
+ print '1: %f, 2:%f, 3:%f, 4:%f'%(self.controllers[0].average_voltage(),self.controllers[1].average_voltage(),self.controllers[2].average_voltage(),self.controllers[3].average_voltage())
+
+
+ for control in self.controllers:
+ if len(control.latest_system_messages) > 0:
+ print "latest system messages:"
+ for message in control.latest_system_messages:
+ print message
+
+
+
+def setupPorts():
+
+ os.system('stty 19200 </dev/ttyUSB0')
+ os.system('stty 19200 </dev/ttyUSB1')
+ os.system('stty 19200 </dev/ttyUSB2')
+ os.system('stty 19200 </dev/ttyUSB3')
+
+
def monitorBatteriesMain(argv, stdout, env):
# default arguments
server = "http://localhost"
@@ -76,7 +188,178 @@
master = rospy.getMaster()
- IBPSBatteryInterface.parseIBPS.main()
+
+
+
+ setupPorts()
+
+#f= open('testfile.txt','r')
+ f0 = open('/dev/ttyUSB0','r')
+ f1 = open('/dev/ttyUSB1','r')
+ f2 = open('/dev/ttyUSB2','r')
+ f3 = open('/dev/ttyUSB3','r')
+# split on % to string and checksum
+# check checksum
+
+ myPow = robotPower()
+
+ start_time = time.time()
+ last_time = start_time
+ while True:
+ current, blah, blah2 = select.select([f0,f1,f2,f3],[],[],1)
+ for f in current:
+ if f == f0:
+ port = 0;
+ port_string = 'f0'
+ if f == f1:
+ port = 1;
+ port_string = 'f1'
+ if f == f2:
+ port = 2;
+ port_string = 'f2'
+ if f == f3:
+ port = 3;
+ port_string = 'f3'
+ line = f.readline()
+ halves = line.split('%')
+ if len(halves) != 2:
+ # print 'I did not split on \% correctly'
+ continue
+ halves[1]=halves[1].strip()
+ halves[0]=halves[0].lstrip('$')
+
+# print line
+# print halves
+# print len(halves)
+# print checksum256(halves[0])
+# print hex2dec(halves[1])
+ # print hex(255)
+
+
+ # read first char and switch
+ message = halves[0]
+
+ # case C controller
+
+ # split on commas
+ # first element is controller number
+ # for each pair
+ # read index 01-07
+ # record value
+ if len(message) < 2:
+ print "error message too short: \"%s\" from \"%s\""%(message, line)
+ print "This often indicates a misconfigured serial port check port:"
+ print f
+ continue
+ if message[0] == 'C':
+ controller_number = int(message[1])
+ #print 'Controller on port %s says:'%(port_string)
+ splitmessage = message.split(',')
+
+ #print 'batteries present'
+ #print readmask(splitmessage[2])
+ mask = readmask(splitmessage[2])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].present = mask[i]
+ #print 'batteries charging'
+ #print readmask(splitmessage[4])
+ mask = readmask(splitmessage[2])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].charging = mask[i]
+ #print 'batteries supplying power to system'
+ #print readmask(splitmessage[6])
+ mask = readmask(splitmessage[6])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].supplying_power = mask[i]
+ #print 'batteries which have charge power present'
+ #print readmask(splitmessage[10])
+ mask = readmask(splitmessage[10])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].w_charge_power = mask[i]
+ #print 'batteries with "Power no good"'
+ #print readmask(splitmessage[12])
+ mask = readmask(splitmessage[12])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].power_no_good = mask[i]
+ #print 'batteries charge inhibited'
+ #print readmask(splitmessage[14])
+ mask = readmask(splitmessage[14])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].charge_inhibited = mask[i]
+
+ else:
+ pass
+
+ if message[0] == 'B':
+ controller_number = int(message[1])
+ battery_number = int(message[2])
+
+ #print 'Battery %d on Controller %d'%(battery_number, controller_number)
+
+ splitmessage = message.split(',')
+
+ for i in range(0,(len(splitmessage)-1)/2):
+ key = splitmessage[i*2+1]
+ value = splitmessage[i*2+2]
+# print 'key %s , value %s'%(splitmessage[i*2+1],splitmessage[i*2+2])
+# print 'key %s , value dec %s'%(splitmessage[i*2+1],hex2dec(splitmessage[i*2+2]))
+
+
+
+ if key == '09':
+ #print 'voltage is %f'%(float(hex2dec(value))/1000.0)
+ myPow.controllers[port].batteries[battery_number].voltage = float(hex2dec(value))/1000.0
+
+
+ if key == '0A':
+ intval = float(hex2dec(value))
+ if intval < 32767:
+ val = intval
+ else:
+ val = (intval - 65636.0)
+ #print 'current is %f'%(val/1000.0)
+ myPow.controllers[port].batteries[battery_number].current = val/1000.0
+
+
+# case B battery
+# split on commas
+# first number is battery number
+# foreach pair
+# lookup index
+# record value cast properly so pages 13 to 35
+
+#case S system data
+ if message[0] == 'S':
+ splitmessage = message.split(',')
+ #print 'System Message'
+ for i in range(0,(len(splitmessage)-1)/2):
+ key = splitmessage[i*2+1]
+ value = splitmessage[i*2+2]
+# print 'key %s , value %s'%(key,value)
+# print 'key %s , value dec %s'%(key,hex2dec(value))
+
+ if key == '01':
+ #print 'time until exhaustion = %s minutes'%hex2dec(value)
+ myPow.controllers[port].time_remaining = int(hex2dec(value))
+ if key == '02':
+ #reserved
+ pass
+
+ if key == '03':
+ #print 'text message to the system %s'%value
+ myPow.controllers[port].new_system_message(value)
+
+ if key == '04':
+ #print 'average charge percent %d'% hex2dec(value)
+ myPow.controllers[port].average_charge = int(hex2dec(value))
+
+ #print time.time()
+ increment = 1.0
+ if time.time() - last_time > increment:
+ last_time = last_time + increment
+ myPow.print_remaining()
+
+
if __name__ == '__main__':
try:
Modified: pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/parseIBPS.py
===================================================================
--- pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/parseIBPS.py 2008-03-28 01:36:42 UTC (rev 54)
+++ pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/parseIBPS.py 2008-03-28 01:51:17 UTC (rev 55)
@@ -279,4 +279,4 @@
myPow.print_remaining()
-#main()
+main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-28 01:36:36
|
Revision: 54
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=54&view=rev
Author: morgan_quigley
Date: 2008-03-27 18:36:42 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
a silly little string-wrapping library so i don't have to write it in every stupid package
Added Paths:
-----------
pkg/trunk/string_utils/
pkg/trunk/string_utils/build.yaml
pkg/trunk/string_utils/include/
pkg/trunk/string_utils/include/string_utils/
pkg/trunk/string_utils/include/string_utils/string_utils.h
pkg/trunk/string_utils/lib/
pkg/trunk/string_utils/manifest.xml
pkg/trunk/string_utils/rosbuild
pkg/trunk/string_utils/src/
pkg/trunk/string_utils/src/libstring_utils/
pkg/trunk/string_utils/src/libstring_utils/Makefile
pkg/trunk/string_utils/src/libstring_utils/string_utils.cpp
Added: pkg/trunk/string_utils/build.yaml
===================================================================
--- pkg/trunk/string_utils/build.yaml (rev 0)
+++ pkg/trunk/string_utils/build.yaml 2008-03-28 01:36:42 UTC (rev 54)
@@ -0,0 +1,3 @@
+cpp:
+ make:
+ - src/libstring_utils
Added: pkg/trunk/string_utils/include/string_utils/string_utils.h
===================================================================
--- pkg/trunk/string_utils/include/string_utils/string_utils.h (rev 0)
+++ pkg/trunk/string_utils/include/string_utils/string_utils.h 2008-03-28 01:36:42 UTC (rev 54)
@@ -0,0 +1,15 @@
+#ifndef STRING_UTILS_STRING_UTILS_H
+#define STRING_UTILS_STRING_UTILS_H
+
+#include <string>
+#include <vector>
+
+namespace string_utils
+{
+void split(const std::string &str,
+ std::vector<std::string> &token_vec,
+ const std::string &delim);
+}
+
+#endif
+
Added: pkg/trunk/string_utils/manifest.xml
===================================================================
--- pkg/trunk/string_utils/manifest.xml (rev 0)
+++ pkg/trunk/string_utils/manifest.xml 2008-03-28 01:36:42 UTC (rev 54)
@@ -0,0 +1,15 @@
+<package>
+ <description brief="String Utilities">
+
+ This package provides a simple static library which makes dealing
+ with strings in C++ a bit less of a headache. This includes tokenizer
+ wrappers, etc. I suppose we could add utilities for other languages
+ in here, but most modern languages seem to have nice string stuff
+ provided already.
+
+ </description>
+ <author>Morgan Quigley (email: mqu...@cs...)</author>
+ <license>BSD</license>
+ <url>http://stair.stanford.edu</url>
+</package>
+
Added: pkg/trunk/string_utils/rosbuild
===================================================================
--- pkg/trunk/string_utils/rosbuild (rev 0)
+++ pkg/trunk/string_utils/rosbuild 2008-03-28 01:36:42 UTC (rev 54)
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec("#{`#{ENV['ROS_ROOT']}/rospack find rostools`}/scripts/yamlbuild", 'build.yaml', *ARGV)
Property changes on: pkg/trunk/string_utils/rosbuild
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/string_utils/src/libstring_utils/Makefile
===================================================================
--- pkg/trunk/string_utils/src/libstring_utils/Makefile (rev 0)
+++ pkg/trunk/string_utils/src/libstring_utils/Makefile 2008-03-28 01:36:42 UTC (rev 54)
@@ -0,0 +1,4 @@
+SRC = string_utils.cpp
+OUT = ../../lib/libstring_utils.a
+PKG = string_utils
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/lib.mk
Added: pkg/trunk/string_utils/src/libstring_utils/string_utils.cpp
===================================================================
--- pkg/trunk/string_utils/src/libstring_utils/string_utils.cpp (rev 0)
+++ pkg/trunk/string_utils/src/libstring_utils/string_utils.cpp 2008-03-28 01:36:42 UTC (rev 54)
@@ -0,0 +1,19 @@
+#include "string_utils/string_utils.h"
+using namespace std;
+
+namespace string_utils
+{
+
+void split(const string &s, vector<string> &t, const string &d)
+{
+ t.clear();
+ size_t start = 0, end;
+ while ((end = s.find_first_of(d, start)) != string::npos)
+ {
+ t.push_back(s.substr(start, end-start));
+ start = end + 1;
+ }
+ t.push_back(s.substr(start));
+}
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ge...@us...> - 2008-03-28 01:24:01
|
Revision: 53
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=53&view=rev
Author: gerkey
Date: 2008-03-27 18:24:08 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
added nodes that wraps player's urglaser driver, which can control a variety of Hokuyo lasers
Added Paths:
-----------
pkg/trunk/hokuyourg_player/
pkg/trunk/hokuyourg_player/Makefile
pkg/trunk/hokuyourg_player/hokuyourg_player.cc
pkg/trunk/hokuyourg_player/manifest.xml
pkg/trunk/hokuyourg_player/nodes/
pkg/trunk/hokuyourg_player/rosbuild
Added: pkg/trunk/hokuyourg_player/Makefile
===================================================================
--- pkg/trunk/hokuyourg_player/Makefile (rev 0)
+++ pkg/trunk/hokuyourg_player/Makefile 2008-03-28 01:24:08 UTC (rev 53)
@@ -0,0 +1,12 @@
+CPP = g++
+AR = ar
+CPPFLAGS = -g -Wall -Werror `pkg-config --cflags playercore playerxdr playerutils playerdrivers` `rospack cflags roscpp` `rospack cflags common_flows`
+LDFLAGS = `pkg-config --libs playercore playerxdr playerutils playerdrivers` `rospack lflags roscpp` `rospack lflags common_flows`
+
+all: nodes/hokuyourg_player
+
+nodes/hokuyourg_player: hokuyourg_player.cc
+ $(CPP) $(CPPFLAGS) -o $@ $< $(LDFLAGS)
+
+clean:
+ rm -f *.o nodes/hokuyourg_player
Added: pkg/trunk/hokuyourg_player/hokuyourg_player.cc
===================================================================
--- pkg/trunk/hokuyourg_player/hokuyourg_player.cc (rev 0)
+++ pkg/trunk/hokuyourg_player/hokuyourg_player.cc 2008-03-28 01:24:08 UTC (rev 53)
@@ -0,0 +1,163 @@
+#include <assert.h>
+
+// For core Player stuff (message queues, config file objects, etc.)
+#include <libplayercore/playercore.h>
+// TODO: remove XDR dependency
+#include <libplayerxdr/playerxdr.h>
+
+// roscpp
+#include <ros/ros_slave.h>
+// I'm using a LaserScan flow
+#include <common_flows/FlowLaserScan.h>
+
+#define PLAYER_QUEUE_LEN 32
+
+// Must prototype this function here. It's implemented inside
+// libplayerdrivers.
+Driver* URGLaserDriver_Init(ConfigFile* cf, int section);
+
+class HokuyoNode: public ROS_Slave
+{
+ public:
+ QueuePointer q;
+
+ HokuyoNode() : ROS_Slave()
+ {
+ // libplayercore boiler plate
+ player_globals_init();
+ itable_init();
+
+ // TODO: remove XDR dependency
+ playerxdr_ftable_init();
+
+ // The Player address that will be assigned to this device. The format
+ // is interface:index. The interface must match what the driver is
+ // expecting to provide. The value of the index doesn't really matter,
+ // but 0 is most common.
+ const char* player_addr = "laser:0";
+
+ // Create a ConfigFile object, into which we'll stuff parameters.
+ // Drivers assume that this object will persist throughout execution
+ // (e.g., they store pointers to data inside it). So it must NOT be
+ // deleted until after the driver is shut down.
+ this->cf = new ConfigFile();
+
+ // Insert (name,value) pairs into the ConfigFile object. These would
+ // presumably come from the param server
+ this->cf->InsertFieldValue(0,"provides",player_addr);
+ this->cf->InsertFieldValue(0,"port","/dev/ttyACM0");
+
+ // Create an instance of the driver, passing it the ConfigFile object.
+ // The -1 tells it to look into the "global" section of the ConfigFile,
+ // which is where ConfigFile::InsertFieldValue() put the parameters.
+ assert((this->driver = URGLaserDriver_Init(cf, -1)));
+
+ // Print out warnings about parameters that were set, but which the
+ // driver never looked at.
+ cf->WarnUnused();
+
+ // Grab from the global deviceTable a pointer to the Device that was
+ // created as part of the driver's initialization.
+ assert((this->device = deviceTable->GetDevice(player_addr,false)));
+
+ // Create a message queue
+ this->q = QueuePointer(false,PLAYER_QUEUE_LEN);
+ }
+
+ ~HokuyoNode()
+ {
+ delete driver;
+ delete cf;
+ player_globals_fini();
+ }
+
+ int Start()
+ {
+ // Subscribe to device, which causes it to startup
+ if(this->device->Subscribe(this->q) != 0)
+ {
+ puts("Failed to subscribe the driver");
+ return(-1);
+ }
+ else
+ return(0);
+ }
+
+ int Stop()
+ {
+ // Unsubscribe from the device, which causes it to shutdown
+ if(device->Unsubscribe(this->q) != 0)
+ {
+ puts("Failed to start the driver");
+ return(-1);
+ }
+ else
+ return(0);
+ }
+
+ private:
+ Driver* driver;
+ Device* device;
+ ConfigFile* cf;
+};
+
+int
+main(void)
+{
+ HokuyoNode hn;
+
+ // Start up the laser
+ if(hn.Start() != 0)
+ exit(-1);
+
+ // Declare a flow
+ FlowLaserScan fl(".laser");
+
+ /////////////////////////////////////////////////////////////////
+ // Main loop; grab messages off our queue and republish them via ROS
+ for(;;)
+ {
+ // Block until there's a message on the queue
+ hn.q->Wait();
+
+ // Pop off one message (we own the resulting memory)
+ Message* msg;
+ assert((msg = hn.q->Pop()));
+
+ // Is the message a laser scan?
+ player_msghdr_t* hdr = msg->GetHeader();
+ if((hdr->type == PLAYER_MSGTYPE_DATA) &&
+ (hdr->subtype == PLAYER_LASER_DATA_SCAN))
+ {
+ // Cast the message payload appropriately
+ player_laser_data_t* pdata = (player_laser_data_t*)msg->GetPayload();
+
+ // Translate from Player data to ROS data
+ fl.px = fl.py = fl.pyaw = 0.0;
+ fl.angle_min = pdata->min_angle;
+ fl.angle_max = pdata->max_angle;
+ fl.angle_increment = pdata->resolution;
+ fl.set_ranges_size(pdata->ranges_count);
+ for(unsigned int i=0;i<pdata->ranges_count;i++)
+ fl.ranges[i] = pdata->ranges[i];
+ fl.set_intensities_size(pdata->intensity_count);
+ for(unsigned int i=0;i<pdata->intensity_count;i++)
+ fl.intensities[i] = pdata->intensity[i];
+
+ // Publish the new data
+ fl.publish();
+
+ printf("Published a scan with %d ranges\n", pdata->ranges_count);
+ }
+
+ // We're done with the message now
+ delete msg;
+ }
+ /////////////////////////////////////////////////////////////////
+
+ // Stop the laser
+ hn.Stop();
+
+ // To quote Morgan, Hooray!
+ return(0);
+}
Added: pkg/trunk/hokuyourg_player/manifest.xml
===================================================================
--- pkg/trunk/hokuyourg_player/manifest.xml (rev 0)
+++ pkg/trunk/hokuyourg_player/manifest.xml 2008-03-28 01:24:08 UTC (rev 53)
@@ -0,0 +1,7 @@
+<package>
+ <description>A ROS node that wraps up the Player urglaser driver, which provides access to a wide range of Hokuyo URG lasers.</description>
+ <author>Brian P. Gerkey</author>
+ <license>BSD</license>
+ <depend package="roscpp" />
+ <depend package="common_flows" />
+</package>
Added: pkg/trunk/hokuyourg_player/rosbuild
===================================================================
--- pkg/trunk/hokuyourg_player/rosbuild (rev 0)
+++ pkg/trunk/hokuyourg_player/rosbuild 2008-03-28 01:24:08 UTC (rev 53)
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+make $*
Property changes on: pkg/trunk/hokuyourg_player/rosbuild
___________________________________________________________________
Name: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tf...@us...> - 2008-03-28 01:20:44
|
Revision: 52
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=52&view=rev
Author: tfoote
Date: 2008-03-27 18:20:50 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
basic ros node calling parseIBPS to read from batteries
Modified Paths:
--------------
pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/parseIBPS.py
Added Paths:
-----------
pkg/trunk/IBPSBatteryInterface/nodes/
pkg/trunk/IBPSBatteryInterface/nodes/monitorBatteries
pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
Added: pkg/trunk/IBPSBatteryInterface/nodes/monitorBatteries
===================================================================
--- pkg/trunk/IBPSBatteryInterface/nodes/monitorBatteries (rev 0)
+++ pkg/trunk/IBPSBatteryInterface/nodes/monitorBatteries 2008-03-28 01:20:50 UTC (rev 52)
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+PKG = 'IBPSBatteryInterface'
+MODULE = 'IBPSBatteryInterface.monitorBatteries' #this is the module that will be invoked by python
+
+######################################################
+# BOILERPLATE: Should not have to modify anything
+# below except for very last line
+######################################################
+# Bootstrap ourselves into latest rospy install
+import sys, os
+BOOTSTRAP_VERSION = "0.1"
+
+# Read in ROS_ROOT
+if not os.environ.has_key('ROS_ROOT'):
+ print """\nCannot run ROS: ROS_ROOT is not set.\nPlease set the ROS_ROOT environment variable to the
+location of your ROS install.\n"""
+ sys.exit(-1)
+rosRoot = os.environ['ROS_ROOT']
+
+# Read in the rospy directory location from the 'rospack latest rospy' command
+rospackLatest = os.popen(os.path.join(rosRoot,'rospack')+' latest rospy', 'r')
+rospyDir = rospackLatest.read()
+rospackLatest.close()
+if rospyDir is None or not os.path.isdir(rospyDir.strip()):
+ print "\nERROR: Cannot locate rospy installation.\n"
+ sys.exit(-1)
+
+# Run launcher bootstrapper
+sys.path.append(os.path.join(rospyDir.strip(),'scripts'))
+import launcher
+
+manifestFile = launcher.getManifestFile(sys.argv[0], PKG)
+launcher.init(BOOTSTRAP_VERSION)
+launchCommand, launchArgs, launchEnv = \
+ launcher.getLaunchCommands(manifestFile, MODULE)
+launcher.ready(launchCommand, launchArgs, launchEnv, BOOTSTRAP_VERSION)
+
+######################################################
+# END BOILERPLATE:
+# You may wish to modify the exec command below to
+# customize the behavior of your node, e.g.:
+# * env['FOO'] = bar
+# * launchArgs.append('--test')
+######################################################
+
+os.execvpe(launchCommand, launchArgs, launchEnv)
Property changes on: pkg/trunk/IBPSBatteryInterface/nodes/monitorBatteries
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py
===================================================================
--- pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py (rev 0)
+++ pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/monitorBatteries.py 2008-03-28 01:20:50 UTC (rev 52)
@@ -0,0 +1,93 @@
+# Software License Agreement (BSD License)
+#
+# Copyright (c) 2008, Willow Garage, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided
+# with the distribution.
+# * Neither the name of the Willow Garage nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+"""
+monitorBatteries
+
+To run, invoke nodes/monitorBatteries
+"""
+
+import os, sys, getopt, traceback, logging
+import rospy
+import time
+import IBPSBatteryInterface.parseIBPS
+
+NAME = 'monitorBatteries'
+
+def usage(stdout, progname):
+ print >>stdout, """%s [-h]
+
+"""%progname+rospy.USAGE_ENV
+
+def monitorBatteriesMain(argv, stdout, env):
+ # default arguments
+ server = "http://localhost"
+ server_port = rospy.DEFAULT_TEST_PORT
+
+ #check arguments for a help flag
+ optlist, args = getopt.getopt(argv[1:], "h?p:s:", ["help","port=","server=","test"])
+ for o, a in optlist:
+ if o in ("-h","-?","--help"):
+ usage(stdout, argv[0])
+ return
+ elif o in ("--test"):
+ server_port = rospy.DEFAULT_TEST_PORT
+ elif o in ("-p", "--port"):
+ server_port = a
+ elif o in ("-s", "--server"):
+ server = a
+
+ serverUri = '%s:%s/'%(server,server_port)
+ print "Looking for server at %s"%serverUri
+ os.environ[rospy.ROS_MASTER_URI] = serverUri
+ os.environ[rospy.ROS_NODE] = "viewGraph"
+ os.environ[rospy.ROS_PORT] = str(0) # any
+
+
+ master = rospy.getMaster()
+
+
+ IBPSBatteryInterface.parseIBPS.main()
+
+if __name__ == '__main__':
+ try:
+ monitorBatteriesMain(sys.argv, sys.stdout, os.environ)
+ except Exception, e:
+ traceback.print_exc()
+ #attempt to log, may fail if logger is not properly initialized
+ logger = logging.getLogger(NAME)
+ logger.error(str(e)+"\n"+traceback.format_exc())
+ print "Exception is causing %s exit, check log for details"%NAME
+
+ print "exiting"
+
+
Modified: pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/parseIBPS.py
===================================================================
--- pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/parseIBPS.py 2008-03-27 23:56:14 UTC (rev 51)
+++ pkg/trunk/IBPSBatteryInterface/src/IBPSBatteryInterface/parseIBPS.py 2008-03-28 01:20:50 UTC (rev 52)
@@ -104,139 +104,140 @@
+def main():
-os.system('stty 19200 </dev/ttyUSB0')
-os.system('stty 19200 </dev/ttyUSB1')
-os.system('stty 19200 </dev/ttyUSB2')
-os.system('stty 19200 </dev/ttyUSB3')
+ os.system('stty 19200 </dev/ttyUSB0')
+ os.system('stty 19200 </dev/ttyUSB1')
+ os.system('stty 19200 </dev/ttyUSB2')
+ os.system('stty 19200 </dev/ttyUSB3')
-
+
#f= open('testfile.txt','r')
-f0 = open('/dev/ttyUSB0','r')
-f1 = open('/dev/ttyUSB1','r')
-f2 = open('/dev/ttyUSB2','r')
-f3 = open('/dev/ttyUSB3','r')
+ f0 = open('/dev/ttyUSB0','r')
+ f1 = open('/dev/ttyUSB1','r')
+ f2 = open('/dev/ttyUSB2','r')
+ f3 = open('/dev/ttyUSB3','r')
# split on % to string and checksum
# check checksum
-myPow = robotPower()
+ myPow = robotPower()
-start_time = time.time()
-last_time = start_time
-while True:
- current, blah, blah2 = select.select([f0,f1,f2,f3],[],[],1)
- for f in current:
- if f == f0:
- port = 0;
- port_string = 'f0'
- if f == f1:
- port = 1;
- port_string = 'f1'
- if f == f2:
- port = 2;
- port_string = 'f2'
- if f == f3:
- port = 3;
- port_string = 'f3'
- line = f.readline()
- halves = line.split('%')
- if len(halves) != 2:
- # print 'I did not split on \% correctly'
- continue
- halves[1]=halves[1].strip()
- halves[0]=halves[0].lstrip('$')
+ start_time = time.time()
+ last_time = start_time
+ while True:
+ current, blah, blah2 = select.select([f0,f1,f2,f3],[],[],1)
+ for f in current:
+ if f == f0:
+ port = 0;
+ port_string = 'f0'
+ if f == f1:
+ port = 1;
+ port_string = 'f1'
+ if f == f2:
+ port = 2;
+ port_string = 'f2'
+ if f == f3:
+ port = 3;
+ port_string = 'f3'
+ line = f.readline()
+ halves = line.split('%')
+ if len(halves) != 2:
+ # print 'I did not split on \% correctly'
+ continue
+ halves[1]=halves[1].strip()
+ halves[0]=halves[0].lstrip('$')
# print line
# print halves
# print len(halves)
# print checksum256(halves[0])
# print hex2dec(halves[1])
- # print hex(255)
+ # print hex(255)
- # read first char and switch
- message = halves[0]
+ # read first char and switch
+ message = halves[0]
- # case C controller
+ # case C controller
- # split on commas
- # first element is controller number
- # for each pair
- # read index 01-07
- # record value
- if len(message) < 2:
- print "error message too short: \"%s\" from \"%s\""%(message, line)
- print "This often indicates a misconfigured serial port check port:"
- print f
- continue
- if message[0] == 'C':
- controller_number = int(message[1])
- #print 'Controller on port %s says:'%(port_string)
- splitmessage = message.split(',')
+ # split on commas
+ # first element is controller number
+ # for each pair
+ # read index 01-07
+ # record value
+ if len(message) < 2:
+ print "error message too short: \"%s\" from \"%s\""%(message, line)
+ print "This often indicates a misconfigured serial port check port:"
+ print f
+ continue
+ if message[0] == 'C':
+ controller_number = int(message[1])
+ #print 'Controller on port %s says:'%(port_string)
+ splitmessage = message.split(',')
- #print 'batteries present'
- #print readmask(splitmessage[2])
- mask = readmask(splitmessage[2])
- for i in range(0,8):
- myPow.controllers[port].batteries[i].present = mask[i]
- #print 'batteries charging'
- #print readmask(splitmessage[4])
- mask = readmask(splitmessage[2])
- for i in range(0,8):
- myPow.controllers[port].batteries[i].charging = mask[i]
- #print 'batteries supplying power to system'
- #print readmask(splitmessage[6])
- mask = readmask(splitmessage[6])
- for i in range(0,8):
- myPow.controllers[port].batteries[i].supplying_power = mask[i]
- #print 'batteries which have charge power present'
- #print readmask(splitmessage[10])
- mask = readmask(splitmessage[10])
- for i in range(0,8):
- myPow.controllers[port].batteries[i].w_charge_power = mask[i]
- #print 'batteries with "Power no good"'
- #print readmask(splitmessage[12])
- mask = readmask(splitmessage[12])
- for i in range(0,8):
- myPow.controllers[port].batteries[i].power_no_good = mask[i]
- #print 'batteries charge inhibited'
- #print readmask(splitmessage[14])
- mask = readmask(splitmessage[14])
- for i in range(0,8):
- myPow.controllers[port].batteries[i].charge_inhibited = mask[i]
+ #print 'batteries present'
+ #print readmask(splitmessage[2])
+ mask = readmask(splitmessage[2])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].present = mask[i]
+ #print 'batteries charging'
+ #print readmask(splitmessage[4])
+ mask = readmask(splitmessage[2])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].charging = mask[i]
+ #print 'batteries supplying power to system'
+ #print readmask(splitmessage[6])
+ mask = readmask(splitmessage[6])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].supplying_power = mask[i]
+ #print 'batteries which have charge power present'
+ #print readmask(splitmessage[10])
+ mask = readmask(splitmessage[10])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].w_charge_power = mask[i]
+ #print 'batteries with "Power no good"'
+ #print readmask(splitmessage[12])
+ mask = readmask(splitmessage[12])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].power_no_good = mask[i]
+ #print 'batteries charge inhibited'
+ #print readmask(splitmessage[14])
+ mask = readmask(splitmessage[14])
+ for i in range(0,8):
+ myPow.controllers[port].batteries[i].charge_inhibited = mask[i]
- else:
- pass
+ else:
+ pass
- if message[0] == 'B':
- controller_number = int(message[1])
- battery_number = int(message[2])
+ if message[0] == 'B':
+ controller_number = int(message[1])
+ battery_number = int(message[2])
- #print 'Battery %d on Controller %d'%(battery_number, controller_number)
+ #print 'Battery %d on Controller %d'%(battery_number, controller_number)
- splitmessage = message.split(',')
+ splitmessage = message.split(',')
- for i in range(0,(len(splitmessage)-1)/2):
- key = splitmessage[i*2+1]
- value = splitmessage[i*2+2]
+ for i in range(0,(len(splitmessage)-1)/2):
+ key = splitmessage[i*2+1]
+ value = splitmessage[i*2+2]
# print 'key %s , value %s'%(splitmessage[i*2+1],splitmessage[i*2+2])
# print 'key %s , value dec %s'%(splitmessage[i*2+1],hex2dec(splitmessage[i*2+2]))
- if key == '09':
- #print 'voltage is %f'%(float(hex2dec(value))/1000.0)
- myPow.controllers[port].batteries[battery_number].voltage = float(hex2dec(value))/1000.0
+ if key == '09':
+ #print 'voltage is %f'%(float(hex2dec(value))/1000.0)
+ myPow.controllers[port].batteries[battery_number].voltage = float(hex2dec(value))/1000.0
- if key == '0A':
- intval = float(hex2dec(value))
- if intval < 32767:
- val = intval
- else:
- val = (intval - 65636.0)
- #print 'current is %f'%(val/1000.0)
- myPow.controllers[port].batteries[battery_number].current = val/1000.0
+ if key == '0A':
+ intval = float(hex2dec(value))
+ if intval < 32767:
+ val = intval
+ else:
+ val = (intval - 65636.0)
+ #print 'current is %f'%(val/1000.0)
+ myPow.controllers[port].batteries[battery_number].current = val/1000.0
# case B battery
@@ -247,32 +248,35 @@
# record value cast properly so pages 13 to 35
#case S system data
- if message[0] == 'S':
- splitmessage = message.split(',')
- #print 'System Message'
- for i in range(0,(len(splitmessage)-1)/2):
- key = splitmessage[i*2+1]
- value = splitmessage[i*2+2]
+ if message[0] == 'S':
+ splitmessage = message.split(',')
+ #print 'System Message'
+ for i in range(0,(len(splitmessage)-1)/2):
+ key = splitmessage[i*2+1]
+ value = splitmessage[i*2+2]
# print 'key %s , value %s'%(key,value)
# print 'key %s , value dec %s'%(key,hex2dec(value))
- if key == '01':
- #print 'time until exhaustion = %s minutes'%hex2dec(value)
- myPow.controllers[port].time_remaining = int(hex2dec(value))
- if key == '02':
- #reserved
- pass
+ if key == '01':
+ #print 'time until exhaustion = %s minutes'%hex2dec(value)
+ myPow.controllers[port].time_remaining = int(hex2dec(value))
+ if key == '02':
+ #reserved
+ pass
- if key == '03':
- #print 'text message to the system %s'%value
- myPow.controllers[port].new_system_message(value)
+ if key == '03':
+ #print 'text message to the system %s'%value
+ myPow.controllers[port].new_system_message(value)
- if key == '04':
- #print 'average charge percent %d'% hex2dec(value)
- myPow.controllers[port].average_charge = int(hex2dec(value))
+ if key == '04':
+ #print 'average charge percent %d'% hex2dec(value)
+ myPow.controllers[port].average_charge = int(hex2dec(value))
- #print time.time()
- increment = 1.0
- if time.time() - last_time > increment:
- last_time = last_time + increment
- myPow.print_remaining()
+ #print time.time()
+ increment = 1.0
+ if time.time() - last_time > increment:
+ last_time = last_time + increment
+ myPow.print_remaining()
+
+
+#main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-27 23:56:08
|
Revision: 51
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=51&view=rev
Author: morgan_quigley
Date: 2008-03-27 16:56:14 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
copy my silly little serial port library from my personal svn
Added Paths:
-----------
pkg/trunk/serial_port/
pkg/trunk/serial_port/build.yaml
pkg/trunk/serial_port/include/
pkg/trunk/serial_port/include/serial_port/
pkg/trunk/serial_port/include/serial_port/lightweightserial.h
pkg/trunk/serial_port/lib/
pkg/trunk/serial_port/manifest.xml
pkg/trunk/serial_port/rosbuild
pkg/trunk/serial_port/src/
pkg/trunk/serial_port/src/libserial_port/
pkg/trunk/serial_port/src/libserial_port/Makefile
pkg/trunk/serial_port/src/libserial_port/lightweightserial.cpp
Added: pkg/trunk/serial_port/build.yaml
===================================================================
--- pkg/trunk/serial_port/build.yaml (rev 0)
+++ pkg/trunk/serial_port/build.yaml 2008-03-27 23:56:14 UTC (rev 51)
@@ -0,0 +1,3 @@
+cpp:
+ make:
+ - src/libserial_port
Added: pkg/trunk/serial_port/include/serial_port/lightweightserial.h
===================================================================
--- pkg/trunk/serial_port/include/serial_port/lightweightserial.h (rev 0)
+++ pkg/trunk/serial_port/include/serial_port/lightweightserial.h 2008-03-27 23:56:14 UTC (rev 51)
@@ -0,0 +1,62 @@
+///////////////////////////////////////////////////////////////////////////////
+// The serial_port package provides small, simple static libraries to access
+// serial devices
+//
+// Copyright (C) 2008, Morgan Quigley
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef SERIALPORT_LIGHTWEIGHT_SERIAL_H
+#define SERIALPORT_LIGHTWEIGHT_SERIAL_H
+
+#include <stdint.h>
+
+class LightweightSerial
+{
+ public:
+ LightweightSerial(const char *port, int baud);
+ ~LightweightSerial();
+
+ bool read(uint8_t *b);
+ int read_block(uint8_t *block, uint32_t max_read_len);
+
+ bool write(const uint8_t b);
+ bool write_block(const uint8_t *block, uint32_t write_len);
+
+ inline bool is_ok() { return happy; }
+
+ // type-conversion wrappers so we can handle either signed or unsigned
+ inline bool read(char *c) { return read((uint8_t *)c); }
+ inline int read_block(char *block, uint32_t max_read_len) { return read_block(block, max_read_len); }
+ inline bool write(char c) { return write((uint8_t)c); }
+ inline bool write_block(const char *block, uint32_t write_len) { return write_block((uint8_t *)block, write_len); }
+
+ private:
+ int baud;
+ int fd;
+ bool happy;
+};
+
+#endif
+
Added: pkg/trunk/serial_port/manifest.xml
===================================================================
--- pkg/trunk/serial_port/manifest.xml (rev 0)
+++ pkg/trunk/serial_port/manifest.xml 2008-03-27 23:56:14 UTC (rev 51)
@@ -0,0 +1,9 @@
+<package>
+<description brief="A few simple serial port classes">
+These are used all over the place for talking to hardware. These implementations are certainly suboptimal, but they do seem to work.
+</description>
+<author>Morgan Quigley (email: mqu...@cs...)</author>
+<license>BSD</license>
+<url>http://stair.stanford.edu</url>
+</package>
+
Added: pkg/trunk/serial_port/rosbuild
===================================================================
--- pkg/trunk/serial_port/rosbuild (rev 0)
+++ pkg/trunk/serial_port/rosbuild 2008-03-27 23:56:14 UTC (rev 51)
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec("#{`#{ENV['ROS_ROOT']}/rospack find rostools`}/scripts/yamlbuild", 'build.yaml', *ARGV)
Property changes on: pkg/trunk/serial_port/rosbuild
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/serial_port/src/libserial_port/Makefile
===================================================================
--- pkg/trunk/serial_port/src/libserial_port/Makefile (rev 0)
+++ pkg/trunk/serial_port/src/libserial_port/Makefile 2008-03-27 23:56:14 UTC (rev 51)
@@ -0,0 +1,5 @@
+SRC = lightweightserial.cpp
+OUT = ../../lib/libserial_port.a
+PKG = serial_port
+CFLAGS = -I../../include
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/only_rules_lib.mk
Added: pkg/trunk/serial_port/src/libserial_port/lightweightserial.cpp
===================================================================
--- pkg/trunk/serial_port/src/libserial_port/lightweightserial.cpp (rev 0)
+++ pkg/trunk/serial_port/src/libserial_port/lightweightserial.cpp 2008-03-27 23:56:14 UTC (rev 51)
@@ -0,0 +1,124 @@
+///////////////////////////////////////////////////////////////////////////////
+// The serial_port package provides small, simple static libraries to access
+// serial devices
+//
+// Copyright (C) 2008, Morgan Quigley
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#include "serial_port/lightweightserial.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <string.h>
+
+LightweightSerial::LightweightSerial(const char *port, int baud) :
+ baud(baud), happy(false), fd(0)
+{
+ printf("about to try to open [%s]\n", port);
+ fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
+ if (fd < 0)
+ {
+ printf(" ahhhhhhhhh couldn't open port [%s]\n", port);
+ return;
+ }
+ else
+ printf("opened [%s] successfully\n", port);
+ // put the port in nonblocking mode
+ struct termios oldtio, newtio;
+ if (tcgetattr(fd, &oldtio) < 0)
+ {
+ printf("ahhhhhhh couldn't run tcgetattr()\n");
+ return;
+ }
+ bzero(&newtio, sizeof(newtio));
+ newtio.c_iflag = IGNPAR | INPCK;
+ newtio.c_oflag = 0;
+ newtio.c_cflag = CS8 | CLOCAL | CREAD;
+ newtio.c_lflag = 0;
+ newtio.c_cc[VTIME] = 0;
+ newtio.c_cc[VMIN] = 0; // poll
+ cfsetspeed(&newtio, baud);
+ tcflush(fd, TCIOFLUSH);
+ if (tcsetattr(fd, TCSANOW, &newtio) < 0)
+ {
+ printf(" ahhhhhhhhhhh tcsetattr failed\n");
+ return;
+ }
+
+ // flush the buffer of the serial device
+ uint8_t b;
+ while (this->read(&b) > 0);
+ happy = true;
+}
+
+LightweightSerial::~LightweightSerial()
+{
+ if (fd > 0)
+ close(fd);
+ fd = 0; // prevent future reads...
+}
+
+bool LightweightSerial::read(uint8_t *b)
+{
+ if (!happy)
+ return false;
+ unsigned long nread;
+ nread = ::read(fd,b,1);
+ if (nread < 0)
+ {
+ printf("ahhhhhh read returned <0\n");
+ happy = false;
+ return false;
+ }
+ return (nread == 1);
+}
+
+int LightweightSerial::read_block(uint8_t *block, uint32_t max_read_len)
+{
+ if (!happy)
+ return false;
+ unsigned long nread = ::read(fd,block,(size_t)max_read_len);
+ return (nread < 0 ? 0 : nread);
+}
+
+bool LightweightSerial::write(const uint8_t b)
+{
+ if (!happy)
+ return false;
+ if (fd >= 0 && ::write(fd, &b, 1) < 0)
+ return false;
+ else
+ return true;
+}
+
+bool LightweightSerial::write_block(const uint8_t *block, uint32_t block_len)
+{
+ if (fd >= 0 && ::write(fd, block, block_len) < 0)
+ return false;
+ tcflush(fd, TCOFLUSH);
+ return true;
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-27 23:52:27
|
Revision: 50
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=50&view=rev
Author: morgan_quigley
Date: 2008-03-27 16:52:34 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
range flows package. copying over from my personal svn. this will need to eventually get absorbed into the common_flows package and a range_utils package (for tests, visualization, etc.)
Added Paths:
-----------
pkg/trunk/range_flows/
pkg/trunk/range_flows/build.yaml
pkg/trunk/range_flows/flows/
pkg/trunk/range_flows/flows/RangeScan.flow
pkg/trunk/range_flows/manifest.xml
pkg/trunk/range_flows/nodes/
pkg/trunk/range_flows/nodes/test_send_recv
pkg/trunk/range_flows/rosbuild
pkg/trunk/range_flows/src/
pkg/trunk/range_flows/src/test/
pkg/trunk/range_flows/src/test/range_receiver/
pkg/trunk/range_flows/src/test/range_receiver/Makefile
pkg/trunk/range_flows/src/test/range_receiver/range_receiver.cpp
pkg/trunk/range_flows/src/test/range_sender/
pkg/trunk/range_flows/src/test/range_sender/Makefile
pkg/trunk/range_flows/src/test/range_sender/range_sender.cpp
Added: pkg/trunk/range_flows/build.yaml
===================================================================
--- pkg/trunk/range_flows/build.yaml (rev 0)
+++ pkg/trunk/range_flows/build.yaml 2008-03-27 23:52:34 UTC (rev 50)
@@ -0,0 +1,4 @@
+cpp:
+ make:
+ - src/test/range_sender
+ - src/test/range_receiver
Added: pkg/trunk/range_flows/flows/RangeScan.flow
===================================================================
--- pkg/trunk/range_flows/flows/RangeScan.flow (rev 0)
+++ pkg/trunk/range_flows/flows/RangeScan.flow 2008-03-27 23:52:34 UTC (rev 50)
@@ -0,0 +1,5 @@
+int32 frame_id
+float32 start_angle
+float32 angle_increment
+float32[] scan
+
Added: pkg/trunk/range_flows/manifest.xml
===================================================================
--- pkg/trunk/range_flows/manifest.xml (rev 0)
+++ pkg/trunk/range_flows/manifest.xml 2008-03-27 23:52:34 UTC (rev 50)
@@ -0,0 +1,10 @@
+<package>
+ <description brief="Flows carrying ranges">
+ This package contains serialization/deserialization for range scans.
+ </description>
+ <author>Morgan Quigley (email: mqu...@cs...)</author>
+ <license>BSD</license>
+ <url>http://stair.stanford.edu</url>
+ <depend package="roscpp"/>
+</package>
+
Added: pkg/trunk/range_flows/nodes/test_send_recv
===================================================================
--- pkg/trunk/range_flows/nodes/test_send_recv (rev 0)
+++ pkg/trunk/range_flows/nodes/test_send_recv 2008-03-27 23:52:34 UTC (rev 50)
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+(puts "aaaaaa no ROS_ROOT"; exit) if !ENV['ROS_ROOT']
+require "#{`#{ENV['ROS_ROOT']}/rospack latest yamlgraph`}/lib/yamlgraph/ygl.rb"
+g = YAMLGraph.new
+g.param 'range_sender.freq', '1000.0'
+
+g.param 'ros_launch_args', ["/usr/bin/xterm", "-T", "%(node_name)s", "-e", "bash", "-c", "valgrind %(rospack)s run %(pkg)s %(node_type)s; bash"]
+
+g.node 'range_flows/range_sender'
+g.node 'range_flows/range_receiver'
+g.flow 'range_sender.scan', 'range_receiver.scan'
+YAMLGraphLauncher.new.launch g
Property changes on: pkg/trunk/range_flows/nodes/test_send_recv
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/range_flows/rosbuild
===================================================================
--- pkg/trunk/range_flows/rosbuild (rev 0)
+++ pkg/trunk/range_flows/rosbuild 2008-03-27 23:52:34 UTC (rev 50)
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec("#{`#{ENV['ROS_ROOT']}/rospack find rostools`}/scripts/yamlbuild", 'build.yaml', *ARGV)
Property changes on: pkg/trunk/range_flows/rosbuild
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/range_flows/src/test/range_receiver/Makefile
===================================================================
--- pkg/trunk/range_flows/src/test/range_receiver/Makefile (rev 0)
+++ pkg/trunk/range_flows/src/test/range_receiver/Makefile 2008-03-27 23:52:34 UTC (rev 50)
@@ -0,0 +1,4 @@
+SRC = range_receiver.cpp
+OUT = ../../../nodes/range_receiver
+PKG = range_flows
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Added: pkg/trunk/range_flows/src/test/range_receiver/range_receiver.cpp
===================================================================
--- pkg/trunk/range_flows/src/test/range_receiver/range_receiver.cpp (rev 0)
+++ pkg/trunk/range_flows/src/test/range_receiver/range_receiver.cpp 2008-03-27 23:52:34 UTC (rev 50)
@@ -0,0 +1,37 @@
+#include <sstream>
+#include "ros/ros_slave.h"
+#include "range_flows/FlowRangeScan.h"
+
+class RangeReceiver : public ROS_Slave
+{
+public:
+ FlowRangeScan *my_scan;
+ double freq;
+
+ RangeReceiver() : ROS_Slave(), freq(1)
+ {
+ register_sink(my_scan = new FlowRangeScan("scan"), ROS_CALLBACK(RangeReceiver, range_cb));
+ printf("params:\n");
+ print_param_names();
+ printf("EO talker params\n");
+ bool b = get_double_param("freq", &freq);
+ printf("b = %d freq = %f\n", b, freq);
+ }
+ virtual ~RangeReceiver() { }
+ void range_cb()
+ {
+ printf("count = %d secs = %d nsecs = %d\n", my_scan->publish_count, my_scan->get_stamp_secs(), my_scan->get_stamp_nsecs());
+ /*
+ for (int i = 0; i < my_scan->get_scan_size(); i++)
+ printf("range %d = %f\n", i, my_scan->scan[i]);
+ */
+ }
+};
+
+int main(int argc, char **argv)
+{
+ RangeReceiver rr;
+ printf("entering receiver spin loop\n");
+ rr.spin();
+ return 0;
+}
Added: pkg/trunk/range_flows/src/test/range_sender/Makefile
===================================================================
--- pkg/trunk/range_flows/src/test/range_sender/Makefile (rev 0)
+++ pkg/trunk/range_flows/src/test/range_sender/Makefile 2008-03-27 23:52:34 UTC (rev 50)
@@ -0,0 +1,4 @@
+SRC = range_sender.cpp
+OUT = ../../../nodes/range_sender
+PKG = range_flows
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Added: pkg/trunk/range_flows/src/test/range_sender/range_sender.cpp
===================================================================
--- pkg/trunk/range_flows/src/test/range_sender/range_sender.cpp (rev 0)
+++ pkg/trunk/range_flows/src/test/range_sender/range_sender.cpp 2008-03-27 23:52:34 UTC (rev 50)
@@ -0,0 +1,43 @@
+#include <sstream>
+#include "ros/ros_slave.h"
+#include "range_flows/FlowRangeScan.h"
+
+class RangeSender : public ROS_Slave
+{
+public:
+ FlowRangeScan *my_scan;
+ double freq;
+
+ RangeSender() : ROS_Slave(), freq(1)
+ {
+ register_source(my_scan = new FlowRangeScan("scan"));
+ my_scan->set_scan_size(10);
+ printf("TALKER params:\n");
+ print_param_names();
+ printf("EO talker params\n");
+ bool b = get_double_param(".freq", &freq);
+ printf("b = %d freq = %f\n", b, freq);
+ }
+ virtual ~RangeSender() { }
+ void send_scan()
+ {
+ for (int i = 0; i < my_scan->get_scan_size(); i++)
+ my_scan->scan[i] = rand() % 100;
+ my_scan->publish();
+ }
+};
+
+int main(int argc, char **argv)
+{
+ RangeSender rs;
+ printf("entering talker spin loop\n");
+ int sleep_usecs = (int)(1000000.0 / rs.freq);
+ printf("sleep usecs = %d\n", sleep_usecs);
+ while (rs.happy())
+ {
+ usleep(sleep_usecs);
+ rs.send_scan();
+ }
+ printf("rangesender says GOODNIGHT\n");
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-27 23:49:29
|
Revision: 49
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=49&view=rev
Author: morgan_quigley
Date: 2008-03-27 16:49:32 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
hokuyo driver copy from my personal svn
Added Paths:
-----------
pkg/trunk/hokuyo_top_urg/
pkg/trunk/hokuyo_top_urg/build.yaml
pkg/trunk/hokuyo_top_urg/include/
pkg/trunk/hokuyo_top_urg/include/hokuyo_top_urg/
pkg/trunk/hokuyo_top_urg/include/hokuyo_top_urg/hokuyo_top_urg.h
pkg/trunk/hokuyo_top_urg/lib/
pkg/trunk/hokuyo_top_urg/manifest.xml
pkg/trunk/hokuyo_top_urg/nodes/
pkg/trunk/hokuyo_top_urg/nodes/test
pkg/trunk/hokuyo_top_urg/rosbuild
pkg/trunk/hokuyo_top_urg/src/
pkg/trunk/hokuyo_top_urg/src/libhokuyo_top_urg/
pkg/trunk/hokuyo_top_urg/src/libhokuyo_top_urg/Makefile
pkg/trunk/hokuyo_top_urg/src/libhokuyo_top_urg/hokuyo_top_urg.cpp
pkg/trunk/hokuyo_top_urg/src/test_standalone/
pkg/trunk/hokuyo_top_urg/src/test_standalone/Makefile
pkg/trunk/hokuyo_top_urg/src/test_standalone/print_scans.cpp
pkg/trunk/hokuyo_top_urg/src/top_urg_node/
pkg/trunk/hokuyo_top_urg/src/top_urg_node/Makefile
pkg/trunk/hokuyo_top_urg/src/top_urg_node/top_urg_node.cpp
Added: pkg/trunk/hokuyo_top_urg/build.yaml
===================================================================
--- pkg/trunk/hokuyo_top_urg/build.yaml (rev 0)
+++ pkg/trunk/hokuyo_top_urg/build.yaml 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,5 @@
+cpp:
+ make:
+ - src/libhokuyo_top_urg
+ - src/test_standalone
+ - src/top_urg_node
Added: pkg/trunk/hokuyo_top_urg/include/hokuyo_top_urg/hokuyo_top_urg.h
===================================================================
--- pkg/trunk/hokuyo_top_urg/include/hokuyo_top_urg/hokuyo_top_urg.h (rev 0)
+++ pkg/trunk/hokuyo_top_urg/include/hokuyo_top_urg/hokuyo_top_urg.h 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,37 @@
+#ifndef STAIR_HOKUYO_TOP_URG_TOP_URG_H
+#define STAIR_HOKUYO_TOP_URG_TOP_URG_H
+
+#include <string>
+using namespace std;
+
+class LightweightSerial;
+
+class HokuyoTopUrg
+{
+public:
+ HokuyoTopUrg(string serial_str);
+ ~HokuyoTopUrg();
+ bool poll();
+ inline bool is_ok() { return happy; }
+ static const int num_ranges = 1128;
+ double latest_scan[num_ranges];
+ static const double SCAN_FOV;
+
+private:
+ bool happy;
+ uint16_t incoming_scan[num_ranges], incoming_idx;
+ void process_data_line(char *line, int line_num);
+ void process_response(char *d, unsigned n);
+ LightweightSerial *serial;
+ string serial_str;
+ enum decode_state_t
+ {
+ DS_BYTE_1,
+ DS_BYTE_2,
+ DS_BYTE_3,
+ } decode_state;
+ uint32_t range_idx, cur_range;
+};
+
+#endif
+
Added: pkg/trunk/hokuyo_top_urg/manifest.xml
===================================================================
--- pkg/trunk/hokuyo_top_urg/manifest.xml (rev 0)
+++ pkg/trunk/hokuyo_top_urg/manifest.xml 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,11 @@
+<package>
+<description brief="Driver for the Hokuyo TOP-URG scanner">
+This package just grabs scans from the Hokuyp TOP-URG laser scanner and publishes them.
+</description>
+<author>Morgan Quigley (email: mqu...@cs...)</author>
+<license>BSD</license>
+<url>http://stair.stanford.edu</url>
+<depend package="serial_port"/>
+<depend package="range_flows"/>
+</package>
+
Added: pkg/trunk/hokuyo_top_urg/nodes/test
===================================================================
--- pkg/trunk/hokuyo_top_urg/nodes/test (rev 0)
+++ pkg/trunk/hokuyo_top_urg/nodes/test 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+(puts "aaaaaa no ROS_ROOT"; exit) if !ENV['ROS_ROOT']
+require "#{`#{ENV['ROS_ROOT']}/rospack latest yamlgraph`}/lib/yamlgraph/ygl.rb"
+g = YAMLGraph.new
+#g.param 'ros_launch_args', '["/usr/bin/xterm", "-T", launch_node_name, "-e", launch_rospack, "run", launch_pkg, launch_node_exe]'
+g.param 'top_urg_node.device', '/dev/ttyACM0'
+g.node 'hokuyo_top_urg/top_urg_node'
+YAMLGraphLauncher.new.launch g
Property changes on: pkg/trunk/hokuyo_top_urg/nodes/test
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/hokuyo_top_urg/rosbuild
===================================================================
--- pkg/trunk/hokuyo_top_urg/rosbuild (rev 0)
+++ pkg/trunk/hokuyo_top_urg/rosbuild 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec("#{`#{ENV['ROS_ROOT']}/rospack find rostools`}/scripts/yamlbuild", 'build.yaml', *ARGV)
Property changes on: pkg/trunk/hokuyo_top_urg/rosbuild
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/hokuyo_top_urg/src/libhokuyo_top_urg/Makefile
===================================================================
--- pkg/trunk/hokuyo_top_urg/src/libhokuyo_top_urg/Makefile (rev 0)
+++ pkg/trunk/hokuyo_top_urg/src/libhokuyo_top_urg/Makefile 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,5 @@
+SRC = hokuyo_top_urg.cpp
+OUT = ../../lib/libstair__hokuyo_top_urg.a
+PKG = stair__hokuyo_top_urg
+CFLAGS = -I../../include -I$(shell $(ROS_ROOT)/rospack find stair__serial_port)/include
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/only_rules_lib.mk
Added: pkg/trunk/hokuyo_top_urg/src/libhokuyo_top_urg/hokuyo_top_urg.cpp
===================================================================
--- pkg/trunk/hokuyo_top_urg/src/libhokuyo_top_urg/hokuyo_top_urg.cpp (rev 0)
+++ pkg/trunk/hokuyo_top_urg/src/libhokuyo_top_urg/hokuyo_top_urg.cpp 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,109 @@
+#include <math.h>
+#include "stair__serial_port/lightweightserial.h"
+#include "stair__hokuyo_top_urg/hokuyo_top_urg.h"
+
+const double HokuyoTopUrg::SCAN_FOV = 270.0 * M_PI / 180.0;
+
+HokuyoTopUrg::HokuyoTopUrg(string serial_str) :
+ serial(NULL)
+{
+ serial = new LightweightSerial(serial_str.c_str(), 115200);
+ happy = serial->is_ok();
+}
+
+HokuyoTopUrg::~HokuyoTopUrg()
+{
+ if (serial)
+ delete serial;
+ serial = NULL;
+}
+
+void HokuyoTopUrg::process_data_line(char *line, int line_num)
+{
+ int linelen = strlen(line);
+ for (int i = 0; i < linelen-1; i++)
+ {
+ switch(decode_state)
+ {
+ case DS_BYTE_1:
+ incoming_scan[incoming_idx] = ((unsigned short)line[i] - 0x0030) << 12;
+ decode_state = DS_BYTE_2;
+ break;
+ case DS_BYTE_2:
+ incoming_scan[incoming_idx] += ((unsigned short)line[i] - 0x0030) << 6;
+ decode_state = DS_BYTE_3;
+ break;
+ case DS_BYTE_3:
+ incoming_scan[incoming_idx] += ((unsigned short)line[i] - 0x0030) << 0;
+ decode_state = DS_BYTE_1;
+ incoming_idx++;
+ break;
+ }
+ }
+}
+
+bool HokuyoTopUrg::poll()
+{
+ if (!happy)
+ return false;
+
+ unsigned char serbuf[4096];
+ serial->write_block("GD0000112700\n", 13); // get a whole scan
+ bool scan_complete = false;
+ int attempts = 0;
+ incoming_idx = 0;
+ decode_state = DS_BYTE_1;
+ char count = 0;
+ const int LINEBUF_LEN = 80;
+ char linebuf[LINEBUF_LEN];
+ char linepos = 0;
+ int line_num = 0;
+ enum { L_ECHO, L_STATUS, L_TIMESTAMP, L_DATA } line_type = L_ECHO;
+ while (!scan_complete)
+ {
+ char c;
+ count++;
+ if (!serial->read(&c))
+ {
+ attempts++;
+ if (++attempts > 1000)
+ {
+ printf("Hokuyo TOP-URG: no response (%d recv)\n", count-1);
+ count = 0;
+ happy = false;
+ break;
+ }
+ usleep(1000);
+ continue;
+ }
+ if (linepos >= LINEBUF_LEN-1)
+ {
+ printf("ahhh! tried to run through linebuf. DON'T THINK SO.\n");
+ linepos = 0;
+ continue;
+ }
+ if (c == '\n')
+ {
+ linebuf[linepos] = 0;
+ if (linepos == 0)
+ {
+ //printf("end of tx range_idx = %d\n", range_idx);
+ break;
+ }
+ switch(line_type)
+ {
+ case L_ECHO: line_type = L_STATUS; line_num = 0; break;
+ case L_STATUS: line_type = L_TIMESTAMP; break;
+ case L_TIMESTAMP: line_type = L_DATA; break;
+ case L_DATA: process_data_line(linebuf, line_num++); break;
+ }
+ linepos = 0;
+ }
+ else
+ linebuf[linepos++] = c;
+ }
+ for (int i = 0; i < num_ranges; i++)
+ latest_scan[i] = incoming_scan[i] * 0.001;
+ return true;
+}
+
Added: pkg/trunk/hokuyo_top_urg/src/test_standalone/Makefile
===================================================================
--- pkg/trunk/hokuyo_top_urg/src/test_standalone/Makefile (rev 0)
+++ pkg/trunk/hokuyo_top_urg/src/test_standalone/Makefile 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,6 @@
+SRC = print_scans.cpp
+OUT = print_scans
+PKG = hokuyo_top_urg
+CFLAGS = -I$(shell $(ROS_ROOT)/rospack find serial_port)/include -I../../include
+LFLAGS = -L$(shell $(ROS_ROOT)/rospack find serial_port)/lib -L../../lib -lhokuyo_top_urg -lserial_port
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/only_rules.mk
Added: pkg/trunk/hokuyo_top_urg/src/test_standalone/print_scans.cpp
===================================================================
--- pkg/trunk/hokuyo_top_urg/src/test_standalone/print_scans.cpp (rev 0)
+++ pkg/trunk/hokuyo_top_urg/src/test_standalone/print_scans.cpp 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,20 @@
+#include <cstdio>
+#include "hokuyo_top_urg/hokuyo_top_urg.h"
+
+int main(int argc, char **argv)
+{
+ HokuyoTopUrg h("/dev/ttyACM0");
+ while(h.is_ok())
+ {
+ char line[80] = {0};
+ fgets(line, 80, stdin);
+ printf("press enter to poll a scan. type 'q<enter>' to quit...\n");
+ if (line[0] == 'q')
+ break;
+ h.poll();
+ for (int i = 0; i < h.num_ranges; i += 200)
+ printf("range %d = %f meters\n", i, h.latest_scan[i]);
+ }
+ return 0;
+}
+
Added: pkg/trunk/hokuyo_top_urg/src/top_urg_node/Makefile
===================================================================
--- pkg/trunk/hokuyo_top_urg/src/top_urg_node/Makefile (rev 0)
+++ pkg/trunk/hokuyo_top_urg/src/top_urg_node/Makefile 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,4 @@
+SRC = top_urg_node.cpp
+OUT = ../../nodes/top_urg_node
+PKG = hokuyo_top_urg
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Added: pkg/trunk/hokuyo_top_urg/src/top_urg_node/top_urg_node.cpp
===================================================================
--- pkg/trunk/hokuyo_top_urg/src/top_urg_node/top_urg_node.cpp (rev 0)
+++ pkg/trunk/hokuyo_top_urg/src/top_urg_node/top_urg_node.cpp 2008-03-27 23:49:32 UTC (rev 49)
@@ -0,0 +1,52 @@
+#include <math.h>
+#include "ros/ros_slave.h"
+#include "range_flows/FlowRangeScan.h"
+#include "hokuyo_top_urg/hokuyo_top_urg.h"
+
+class TopUrgNode : public ROS_Slave
+{
+public:
+ FlowRangeScan *scan;
+ string urg_dev;
+ HokuyoTopUrg *h;
+
+ TopUrgNode() : ROS_Slave()
+ {
+ register_source(scan = new FlowRangeScan("scan"));
+ scan->start_angle = -HokuyoTopUrg::SCAN_FOV / 2.0;
+ scan->angle_increment = HokuyoTopUrg::SCAN_FOV / (double)HokuyoTopUrg::num_ranges;
+ if (!get_string_param(".device", urg_dev))
+ {
+ printf("woah! param 'device' not specified in the graph. defaulting to /dev/null\n");
+ urg_dev = "/dev/null";
+ }
+ printf("URG device set to [%s]\n", urg_dev.c_str());
+ h = new HokuyoTopUrg(urg_dev);
+ scan->set_scan_size(h->num_ranges);
+ }
+ bool send_scan()
+ {
+ if (!h->poll())
+ {
+ printf("couldn't poll the laser\n");
+ return false;
+ }
+ for (int i = 0; i < h->num_ranges; i++)
+ scan->scan[i] = h->latest_scan[i];
+ scan->publish();
+ return true;
+ }
+};
+
+int main(int argc, char **argv)
+{
+ TopUrgNode t;
+ while (t.happy())
+ if (!t.send_scan())
+ {
+ printf("couldn't get/send scan\n");
+ return 1;
+ }
+ printf("unhappy\n");
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tf...@us...> - 2008-03-27 23:39:29
|
Revision: 48
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=48&view=rev
Author: tfoote
Date: 2008-03-27 16:39:34 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
adding missing library to be linked against if running on gutsy
Modified Paths:
--------------
pkg/trunk/exploreGraph/nodes/renderGraph
Modified: pkg/trunk/exploreGraph/nodes/renderGraph
===================================================================
--- pkg/trunk/exploreGraph/nodes/renderGraph 2008-03-27 22:43:59 UTC (rev 47)
+++ pkg/trunk/exploreGraph/nodes/renderGraph 2008-03-27 23:39:34 UTC (rev 48)
@@ -40,8 +40,10 @@
# END BOILERPLATE:
# You may wish to modify the exec command below to
# customize the behavior of your node, e.g.:
-# * env['FOO'] = bar
+# * launchEnv['FOO'] = bar
# * launchArgs.append('--test')
######################################################
+launchEnv['LD_PRELOAD'] = '/usr/lib/libgvc.so.3'
+
os.execvpe(launchCommand, launchArgs, launchEnv)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-27 22:43:55
|
Revision: 47
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=47&view=rev
Author: morgan_quigley
Date: 2008-03-27 15:43:59 -0700 (Thu, 27 Mar 2008)
Log Message:
-----------
SHARKS WITH LASER BEAMS ON THEIR HEADS is a triangulation-based laser scanner. to save typing i just call it 'sharks'
Added Paths:
-----------
pkg/trunk/sharks/
pkg/trunk/sharks/README
pkg/trunk/sharks/build.yaml
pkg/trunk/sharks/include/
pkg/trunk/sharks/include/sharks/
pkg/trunk/sharks/include/sharks/sharks.h
pkg/trunk/sharks/lib/
pkg/trunk/sharks/manifest.xml
pkg/trunk/sharks/nodes/
pkg/trunk/sharks/nodes/data_collection
pkg/trunk/sharks/rosbuild
pkg/trunk/sharks/src/
pkg/trunk/sharks/src/libsharks/
pkg/trunk/sharks/src/libsharks/Makefile
pkg/trunk/sharks/src/libsharks/kbhit.cpp
pkg/trunk/sharks/src/libsharks/kbhit.h
pkg/trunk/sharks/src/libsharks/sharks.cpp
pkg/trunk/sharks/src/loneshark/
pkg/trunk/sharks/src/loneshark/Makefile
pkg/trunk/sharks/src/loneshark/loneshark.cpp
pkg/trunk/sharks/src/postprocess/
pkg/trunk/sharks/src/postprocess/extract_laser/
pkg/trunk/sharks/src/postprocess/extract_laser/Makefile
pkg/trunk/sharks/src/postprocess/extract_laser/extract_laser.cpp
pkg/trunk/sharks/src/postprocess/extract_laser/launcher
pkg/trunk/sharks/src/postprocess/log_fusion/
pkg/trunk/sharks/src/postprocess/log_fusion/Makefile
pkg/trunk/sharks/src/postprocess/log_fusion/log_fusion.cpp
pkg/trunk/sharks/src/postprocess/log_fusion/test_position.cpp
pkg/trunk/sharks/src/postprocess/project_points/
pkg/trunk/sharks/src/postprocess/project_points/project.m
pkg/trunk/sharks/src/sharks/
pkg/trunk/sharks/src/sharks/Makefile
pkg/trunk/sharks/src/sharks/sharks.cpp
pkg/trunk/sharks/src/sharks2/
pkg/trunk/sharks/src/sharks2/Makefile
pkg/trunk/sharks/src/sharks2/sharks2.cpp
Added: pkg/trunk/sharks/README
===================================================================
--- pkg/trunk/sharks/README (rev 0)
+++ pkg/trunk/sharks/README 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,11 @@
+Lots in here is highly experimental and should not be counted upon to do
+anything productive. At first, I wanted to have the SHARKS scanner be an actual
+ROS flow graph, but I soon realized that for a tightly coupled system such as
+this, that will introduce unnecessary complication and overhead. So now I am
+writing "libsharks" which brings in the static library drivers for the Axis
+camera and the IPDCMOT motor controller. This means that SHARKS is now tied to
+a particular camera and motor controller, but the payoff in terms of simplicity
+seems worth it for now.
+
+libsharks is then used by LONESHARK which is a standalone program that grabs
+scans.
Added: pkg/trunk/sharks/build.yaml
===================================================================
--- pkg/trunk/sharks/build.yaml (rev 0)
+++ pkg/trunk/sharks/build.yaml 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,4 @@
+cpp:
+ make:
+ - src/libsharks
+ - src/loneshark
Added: pkg/trunk/sharks/include/sharks/sharks.h
===================================================================
--- pkg/trunk/sharks/include/sharks/sharks.h (rev 0)
+++ pkg/trunk/sharks/include/sharks/sharks.h 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,54 @@
+///////////////////////////////////////////////////////////////////////////////
+// The sharks package provides a triangulation-based laser scanner.
+//
+// Copyright (C) 2008, Morgan Quigley
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef SHARKS_SHARKS_H
+#define SHARKS_SHARKS_H
+
+#include <string>
+#include "axis_cam/axis_cam.h"
+#include "ipdcmot/ipdcmot.h"
+using namespace std;
+
+class Sharks
+{
+public:
+ Sharks(string axis_ip, string ipdcmot_ip);
+ ~Sharks();
+ void loneshark();
+ inline bool ok() { return cam_ok && mot_ok; }
+
+private:
+ bool cam_ok, mot_ok;
+ string axis_ip, ipdcmot_ip;
+ AxisCam *cam;
+ IPDCMOT *mot;
+ bool get_and_save_image(string filename);
+};
+
+#endif
+
Added: pkg/trunk/sharks/manifest.xml
===================================================================
--- pkg/trunk/sharks/manifest.xml (rev 0)
+++ pkg/trunk/sharks/manifest.xml 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,24 @@
+<package>
+<description brief="A triangulation-based laser scanner">
+
+Sharks with laser beams on their heads. For all we know, they were using those
+laser beams to triangulate the distance to the nearest victim.
+
+This package uses a line laser mounted on a rotary stage (driven by the
+ipdcmot package) and the axis_cam camera package to create a
+triangulation-based laser range scanner.
+
+</description>
+<author>Morgan Quigley (email: mqu...@cs...)</author>
+<license>BSD</license>
+<url>http://stair.stanford.edu</url>
+<depend package="axis_cam"/>
+<depend package="sdl_image"/>
+<depend package="ipdcmot"/>
+<depend package="common_flows"/>
+<depend package="yamlgraph"/>
+<depend package="roscpp"/>
+<depend package="vacuum"/>
+<sys_depend lib="ncurses"/>
+</package>
+
Added: pkg/trunk/sharks/nodes/data_collection
===================================================================
--- pkg/trunk/sharks/nodes/data_collection (rev 0)
+++ pkg/trunk/sharks/nodes/data_collection 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+(puts "aaaaaaaa no ROS_ROOT"; exit) if !ENV['ROS_ROOT']
+require "#{`#{ENV['ROS_ROOT']}/rospack latest yamlgraph`}/lib/yamlgraph/ygl.rb"
+g = YAMLGraph.new
+g.param 'servo.host', '192.168.1.38'
+g.param 'axis_cam_wget_polled.host', '192.168.1.90'
+g.param 'sharks.start', '-25.0'
+g.param 'sharks.end', '25.0'
+g.param 'sharks.step', '0.5'
+g.node 'ipdcmot/servo', {'launch'=>'xterm'}
+g.node 'sharks/sharks2', {'launch'=>'xterm'}
+g.node 'axis_cam/axis_cam_wget_polled', {'launch'=>'xterm'}
+g.flow 'sharks:getpos_request', 'servo:getpos_blocking'
+g.flow 'servo:getpos_result', 'sharks:getpos_result'
+g.flow 'sharks:setpos_request', 'servo:setpos_blocking'
+g.flow 'servo:setpos_result', 'sharks:setpos_result'
+g.flow 'sharks:shutter', 'axis_cam_wget_polled:shutter'
+g.flow 'axis_cam_wget_polled:image', 'sharks:image'
+YAMLGraphLauncher.new.launch g
+
Property changes on: pkg/trunk/sharks/nodes/data_collection
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/sharks/rosbuild
===================================================================
--- pkg/trunk/sharks/rosbuild (rev 0)
+++ pkg/trunk/sharks/rosbuild 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec("#{`#{ENV['ROS_ROOT']}/rospack find rostools`}/scripts/yamlbuild", 'build.yaml', *ARGV)
Property changes on: pkg/trunk/sharks/rosbuild
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/sharks/src/libsharks/Makefile
===================================================================
--- pkg/trunk/sharks/src/libsharks/Makefile (rev 0)
+++ pkg/trunk/sharks/src/libsharks/Makefile 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,4 @@
+SRC = sharks.cpp kbhit.cpp
+OUT = ../../lib/libsharks.a
+PKG = sharks
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/lib.mk
Added: pkg/trunk/sharks/src/libsharks/kbhit.cpp
===================================================================
--- pkg/trunk/sharks/src/libsharks/kbhit.cpp (rev 0)
+++ pkg/trunk/sharks/src/libsharks/kbhit.cpp 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,51 @@
+#include "kbhit.h"
+#include <termios.h>
+#include <unistd.h>
+
+static struct termios initial_settings, new_settings;
+static int peek_character = -1;
+
+void init_keyboard()
+{
+ tcgetattr(0, &initial_settings);
+ new_settings = initial_settings;
+ new_settings.c_lflag &= ~ICANON;
+ new_settings.c_lflag &= ~ECHO;
+// new_settings.c_lflag &= ~ISIG;
+ new_settings.c_cc[VMIN] = 1;
+ new_settings.c_cc[VTIME] = 0;
+ tcsetattr(0, TCSANOW, &new_settings);
+}
+
+void close_keyboard()
+{
+ tcsetattr(0, TCSANOW, &initial_settings);
+}
+
+int _kbhit()
+{
+ unsigned char ch;
+ int nread;
+ new_settings.c_cc[VMIN] = 0;
+ tcsetattr(0, TCSANOW, &new_settings);
+ nread = read(0, &ch, 1);
+ new_settings.c_cc[VMIN] = 1;
+ tcsetattr(0, TCSANOW, &new_settings);
+ if (nread == 1)
+ {
+ peek_character = ch;
+ return 1;
+ }
+ else
+ {
+ peek_character = 0;
+ return 0;
+ }
+}
+
+char _getch()
+{
+ char c = peek_character;
+ peek_character = 0;
+ return c;
+}
Added: pkg/trunk/sharks/src/libsharks/kbhit.h
===================================================================
--- pkg/trunk/sharks/src/libsharks/kbhit.h (rev 0)
+++ pkg/trunk/sharks/src/libsharks/kbhit.h 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,13 @@
+#ifndef KBHIT_H
+#define KBHIT_H
+
+// this code copied from linux-sys.org, where it was copied from "Beginning
+// Linux Programming" a book by Wrox Press
+
+void init_keyboard(void);
+void close_keyboard(void);
+int _kbhit(void);
+char _getch(void);
+
+#endif
+
Added: pkg/trunk/sharks/src/libsharks/sharks.cpp
===================================================================
--- pkg/trunk/sharks/src/libsharks/sharks.cpp (rev 0)
+++ pkg/trunk/sharks/src/libsharks/sharks.cpp 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,111 @@
+///////////////////////////////////////////////////////////////////////////////
+// The sharks package provides a triangulation-based laser scanner.
+//
+// Copyright (C) 2008, Morgan Quigley, Stanford Univerity
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names
+// of its contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#include <sstream>
+#include "sharks/sharks.h"
+#include "axis_cam/axis_cam.h"
+#include "ipdcmot/ipdcmot.h"
+#include "kbhit.h"
+
+Sharks::Sharks(string axis_ip, string ipdcmot_ip)
+ : axis_ip(axis_ip), ipdcmot_ip(ipdcmot_ip),
+ cam_ok(true), mot_ok(true)
+{
+ cam = new AxisCam(axis_ip);
+ // make sure we can get an image
+ uint8_t *jpeg_buf;
+ uint32_t jpeg_buf_size;
+ if (!cam->get_jpeg(&jpeg_buf, &jpeg_buf_size))
+ printf("woah! couldn't get an image from [%s]\n",
+ axis_ip.c_str());
+ else
+ {
+ printf("cam ok. grabbed a %d-byte image.\n",
+ jpeg_buf_size);
+ }
+ printf("entering ipdcmot construct\n");
+ mot = new IPDCMOT(ipdcmot_ip, 0, false);
+ printf("done with ipdcmot construct\n");
+}
+
+Sharks::~Sharks()
+{
+ printf("sharks destructor\n");
+ mot->stop();
+}
+
+bool Sharks::get_and_save_image(string filename)
+{
+ uint8_t *jpeg_buf;
+ uint32_t jpeg_buf_size;
+ if (!cam->get_jpeg(&jpeg_buf, &jpeg_buf_size))
+ {
+ printf("woah! no image\n");
+ return false;
+ }
+ //printf("got a %d-byte image\n", jpeg_buf_size);
+ FILE *f = fopen(filename.c_str(), "wb");
+ fwrite(jpeg_buf, 1, jpeg_buf_size, f);
+ fclose(f);
+ return true;
+}
+
+void Sharks::loneshark()
+{
+ // this function is a standalone data-collection routine.
+ const double left_bound = 90.0, right_bound = 130.0;
+ int image_count = 1;
+ init_keyboard();
+ mot->set_pos_deg_blocking(left_bound);
+ mot->set_patrol(left_bound, right_bound, 10, 1);
+ printf("press any key to stop scanning\n");
+ while (!_kbhit())
+ {
+ double pos;
+ if (!mot->get_pos_blocking(&pos, NULL, 1))
+ {
+ printf("woah! couldn't get position\n");
+ break;
+ }
+ printf(".");
+ fflush(stdout);
+ char fnamebuf[500];
+ sprintf(fnamebuf, "img_%06d_%012.6f.jpg", image_count, pos);
+ image_count++;
+ if (!get_and_save_image(fnamebuf))
+ {
+ printf("woah! couldn't get an image\n");
+ break;
+ }
+ }
+ mot->set_pos_deg_blocking(left_bound); // stop the patrol
+ char c = _getch();
+ printf("you pressed: [%c]\n", c);
+ close_keyboard();
+}
+
Added: pkg/trunk/sharks/src/loneshark/Makefile
===================================================================
--- pkg/trunk/sharks/src/loneshark/Makefile (rev 0)
+++ pkg/trunk/sharks/src/loneshark/Makefile 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,5 @@
+SRC = loneshark.cpp
+OUT = loneshark
+LFLAGS = -L../../lib -laxis_cam -lcurl -lipdcmot
+PKG = sharks
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Added: pkg/trunk/sharks/src/loneshark/loneshark.cpp
===================================================================
--- pkg/trunk/sharks/src/loneshark/loneshark.cpp (rev 0)
+++ pkg/trunk/sharks/src/loneshark/loneshark.cpp 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,45 @@
+///////////////////////////////////////////////////////////////////////////////
+// The sharks package provides a triangulation-based laser scanner.
+//
+// Copyright (C) 2008, Morgan Quigley
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#include <cstdio>
+#include "sharks/sharks.h"
+
+int main(int argc, char **argv)
+{
+ printf("construct Sharks object...\n");
+ Sharks *sharks = new Sharks("192.168.1.90", "192.168.1.38");
+
+ printf("press enter to scan or type 'a' then enter to abort\n");
+ char c = fgetc(stdin);
+ if (c != 'a')
+ sharks->loneshark();
+
+ delete sharks;
+ return 0;
+}
+
Added: pkg/trunk/sharks/src/postprocess/extract_laser/Makefile
===================================================================
--- pkg/trunk/sharks/src/postprocess/extract_laser/Makefile (rev 0)
+++ pkg/trunk/sharks/src/postprocess/extract_laser/Makefile 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,6 @@
+SRC = extract_laser.cpp
+OUT = extract_laser
+PKG = stair__sharks
+CFLAGS = -I$(shell $(ROS_ROOT)/rospack find stair__sdl)/include -I$(shell $(ROS_ROOT)/rospack find stair__sdl_image)/include
+LFLAGS = -L$(shell $(ROS_ROOT)/rospack find stair__sdl)/lib -L$(shell $(ROS_ROOT)/rospack find stair__sdl_image)/lib -lSDL -lSDL_image
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/only_rules.mk
Added: pkg/trunk/sharks/src/postprocess/extract_laser/extract_laser.cpp
===================================================================
--- pkg/trunk/sharks/src/postprocess/extract_laser/extract_laser.cpp (rev 0)
+++ pkg/trunk/sharks/src/postprocess/extract_laser/extract_laser.cpp 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,152 @@
+#include "SDL/SDL.h"
+#include "SDL/SDL_image.h"
+#include <string>
+#include <vector>
+#include <math.h>
+using namespace std;
+
+void split(const string &s, vector<string> &t, const string &d)
+{
+ size_t start = 0, end;
+ while ((end = s.find_first_of(d, start)) != string::npos)
+ {
+ t.push_back(s.substr(start, end-start));
+ start = end + 1;
+ }
+ t.push_back(s.substr(start));
+}
+
+int main(int argc, char **argv)
+{
+ string bg, fg;
+ vector<string> fgs;
+ FILE *log = fopen("log.txt", "w");
+ if (argc < 3)
+ {
+ printf("give at least two filenames.\n");
+ //bg = string("test_bg.jpg");
+ //fg = string("test_fg.jpg");
+ bg = string("../../../stair__sharks_testdata/stapler_pen_apple/shark_00001_-024.99886_.jpg");
+ fgs.push_back(string("../../../stair__sharks_testdata/stapler_pen_apple/shark_00500_-000.05039_.jpg"));
+ fgs.push_back(string("../../../stair__sharks_testdata/stapler_pen_apple/shark_00501_-000.00508_.jpg"));
+ }
+ else
+ {
+ bg = string(argv[1]);
+ for (int i = 2; i < argc; i++)
+ fgs.push_back(string(argv[i]));
+ }
+
+ SDL_Surface *screen, *bg_image, *fg_image;
+ if (SDL_Init(SDL_INIT_VIDEO) < 0)
+ {
+ printf("SDL init error: %s\n", SDL_GetError());
+ return 1;
+ }
+ bg_image = IMG_Load(bg.c_str());
+ if (!bg_image)
+ {
+ printf("SDL image load error: %s\n", IMG_GetError());
+ SDL_Quit();
+ return 1;
+ }
+ screen = SDL_SetVideoMode(bg_image->w, bg_image->h, 32, SDL_ANYFORMAT);
+ if (!screen)
+ {
+ printf("SDL_SetVideoMode error: %s\n", SDL_GetError());
+ SDL_FreeSurface(bg_image);
+ SDL_FreeSurface(fg_image);
+ SDL_Quit();
+ return 1;
+ }
+
+ for (int f_idx = 0; f_idx < fgs.size(); f_idx++)
+ {
+ double lang = -1000;
+ fg = fgs[f_idx];
+ vector<string> tokens;
+ split(fg, tokens, "_");
+ if (tokens.size() < 2)
+ {
+ printf("woah! I expected at least two tokens separated by underscores in the filename\n");
+ return 5;
+ }
+// for (int i = 0; i < tokens.size(); i++)
+// printf("%d = [%s]\n", i, tokens[i].c_str());
+ string lang_str = tokens[tokens.size() - 2];
+// printf("lang str = [%s]\n", lang_str.c_str());
+ lang = atof(lang_str.c_str());
+ printf("lang = %f\n", lang);
+
+ fg_image = IMG_Load(fg.c_str());
+ if (!fg_image)
+ {
+ printf("SDL image load error: %s\n", IMG_GetError());
+ SDL_Quit();
+ return 1;
+ }
+ //printf("loaded %s: %dx%d %dbpp\n", argv[1], image->w, image->h, image->format->BitsPerPixel);
+ //printf("image bpp = %d\n", bg_image->format->BytesPerPixel);
+ for (int y = 0; y < bg_image->h; y++)
+ {
+ double centroid = 0, sum = 0;
+ for (int x = 0; x < bg_image->w; x++)
+ {
+ uint8_t *bg_p = (uint8_t *)bg_image->pixels + y*bg_image->pitch + x*3;
+ uint8_t *fg_p = (uint8_t *)fg_image->pixels + y*fg_image->pitch + x*3;
+ uint8_t bg_r = *(bg_p + bg_image->format->Rshift/8);
+ uint8_t fg_r = *(fg_p + fg_image->format->Rshift/8);
+ *(fg_p + fg_image->format->Gshift/8) = 0;
+ *(fg_p + bg_image->format->Bshift/8) = 0;
+ int diff = fg_r - bg_r;
+ if (diff > 50)
+ {
+ *(fg_p + fg_image->format->Rshift/8) = diff;
+ centroid += (diff) * x;
+ sum += diff;
+ }
+ else
+ *(fg_p + fg_image->format->Rshift/8) = 0;
+ }
+ centroid /= sum;
+ if (sum > 200)
+ {
+ //printf("centroid = %f sum = %f\n", centroid, sum);
+ int x = (int)floor(centroid);
+ if (x < 0) x = 0;
+ if (x >= fg_image->w) x = fg_image->w - 1;
+ uint8_t *fg_p = (uint8_t *)fg_image->pixels + y*fg_image->pitch + x*3;
+ *(fg_p + fg_image->format->Gshift/8) = 255;
+ fprintf(log, "%f %d %f %f\n", lang, y, centroid, sum);
+ }
+ }
+
+ SDL_BlitSurface(fg_image, 0, screen, 0);
+ SDL_Flip(screen);
+ SDL_FreeSurface(fg_image);
+ }
+ bool done = false;
+ SDL_Event event;
+ while (!done && SDL_WaitEvent(&event) != -1)
+ {
+ switch(event.type)
+ {
+ case SDL_KEYDOWN:
+ case SDL_QUIT:
+ done = true;
+ break;
+ case SDL_VIDEOEXPOSE:
+ SDL_BlitSurface(fg_image, 0, screen, 0);
+ SDL_Flip(screen);
+ break;
+ default:
+ break;
+ }
+ }
+ SDL_FreeSurface(bg_image);
+ SDL_Quit();
+ fclose(log);
+
+ return 0;
+}
+
Added: pkg/trunk/sharks/src/postprocess/extract_laser/launcher
===================================================================
--- pkg/trunk/sharks/src/postprocess/extract_laser/launcher (rev 0)
+++ pkg/trunk/sharks/src/postprocess/extract_laser/launcher 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+rp = "#{ENV['ROS_ROOT']}/rospack"
+olp = ENV['LD_LIBRARY_PATH']
+ENV['LD_LIBRARY_PATH'] = (olp ? olp + ':' : '') + "#{`#{rp} find stair.sdl`}/lib:#{`#{rp} find stair__sdl_image`}/lib"
+exec('./extract_laser', *ARGV)
Property changes on: pkg/trunk/sharks/src/postprocess/extract_laser/launcher
___________________________________________________________________
Name: svn:executable
+ *
Added: pkg/trunk/sharks/src/postprocess/log_fusion/Makefile
===================================================================
--- pkg/trunk/sharks/src/postprocess/log_fusion/Makefile (rev 0)
+++ pkg/trunk/sharks/src/postprocess/log_fusion/Makefile 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,6 @@
+SRC = log_fusion.cpp
+OUT = log_fusion
+#CFLAGS = -I../../include
+#LFLAGS = -L../../lib -lipdcmot -lrt
+PKG = sharks
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Added: pkg/trunk/sharks/src/postprocess/log_fusion/log_fusion.cpp
===================================================================
--- pkg/trunk/sharks/src/postprocess/log_fusion/log_fusion.cpp (rev 0)
+++ pkg/trunk/sharks/src/postprocess/log_fusion/log_fusion.cpp 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,13 @@
+#include "vacuum/vacuparse.h"
+
+int main(int argc, char **argv)
+{
+ VacuParse vp("string.dump");
+ uint32_t atom_len, publish_count, secs, nsecs;
+ uint8_t *atom_ptr;
+ vp.get_next_atom(&atom_len, &atom_ptr, &publish_count, &secs, &nsecs);
+ vp.get_next_atom(&atom_len, &atom_ptr, &publish_count, &secs, &nsecs);
+ vp.get_next_atom(&atom_len, &atom_ptr, &publish_count, &secs, &nsecs);
+ vp.get_next_atom(&atom_len, &atom_ptr, &publish_count, &secs, &nsecs);
+ return 0;
+}
Added: pkg/trunk/sharks/src/postprocess/log_fusion/test_position.cpp
===================================================================
--- pkg/trunk/sharks/src/postprocess/log_fusion/test_position.cpp (rev 0)
+++ pkg/trunk/sharks/src/postprocess/log_fusion/test_position.cpp 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,19 @@
+#include <cstdio>
+#include "ipdcmot/ipdcmot.h"
+
+int main(int argc, char **argv)
+{
+ IPDCMOT *mot = new IPDCMOT("192.168.1.38", 75);
+ printf("sleeping...\n");
+ usleep(1000000);
+ printf("going to 20 degrees\n");
+ mot->set_pos_deg_blocking(20);
+ printf("done. going to 40 degrees\n");
+ mot->set_pos_deg_blocking(40);
+ printf("done.\n");
+
+
+ delete mot;
+ return 0;
+}
+
Added: pkg/trunk/sharks/src/postprocess/project_points/project.m
===================================================================
--- pkg/trunk/sharks/src/postprocess/project_points/project.m (rev 0)
+++ pkg/trunk/sharks/src/postprocess/project_points/project.m 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,40 @@
+if ~exist('d')
+ d = load('laser.txt');
+ fprintf('ok, loaded %d scanlines\n', size(d,1));
+end
+baseline = 0.49;
+hres = 704;
+vres = 480;
+hfov = 50;
+vfov = hfov * vres / hres;
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+scene = [];
+r = 2000:length(d);
+lang = -d(r,1) * pi/180 + 40*pi/180;
+img_y = d(r,2);
+img_x = d(r,3);
+azi = ((hres/2-img_x) / hres * hfov + 90) * pi/180;
+ele = (vres/2-img_y) / vres * vfov * pi/180;
+ray = [cos(ele).*cos(azi) sin(ele) cos(ele).*sin(azi)];
+ln = [-cos(lang), zeros(length(lang),1), -sin(lang)];
+lorg = [baseline; 0; 0];
+numer = baseline * ln(:,1);
+denom = dot(ray',ln')';
+t = numer ./ denom;
+t = [t,t,t];
+proj = t .* ray;
+
+%plot_idx = 1:20:(length(proj));
+%plot3(proj(plot_idx,1),proj(plot_idx,3),proj(plot_idx,2),'.');
+%axis equal;
+
+%save -ascii 'test.txt' proj
+
+% in non-insane terms:
+%proj = t .* ray
+%for i=1:100:length(img_y)
+% t = lorg'*ln(i,:)' / (ray(i,:) * ln(i,:)');
+% proj = t * ray(i,:);
+% scene = [scene; proj];
+%end
+
Added: pkg/trunk/sharks/src/sharks/Makefile
===================================================================
--- pkg/trunk/sharks/src/sharks/Makefile (rev 0)
+++ pkg/trunk/sharks/src/sharks/Makefile 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,4 @@
+SRC = sharks.cpp
+OUT = ../../nodes/sharks
+PKG = sharks
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Added: pkg/trunk/sharks/src/sharks/sharks.cpp
===================================================================
--- pkg/trunk/sharks/src/sharks/sharks.cpp (rev 0)
+++ pkg/trunk/sharks/src/sharks/sharks.cpp 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,139 @@
+// You must have ncurses installed on your system.
+// on Ubuntu: sudo apt-get install libncurses-dev
+#include <ncurses.h>
+#include "ros/ros_slave.h"
+#include "ros/ros_flowpair.h"
+#include "common_flows/FlowInt32.h"
+#include "common_flows/FlowFloat64.h"
+#include "common_flows/FlowEmpty.h"
+#include "image_flows/FlowImage.h"
+#include "image_flows/image_flow_codec.h"
+
+class Sharks : public ROS_Slave
+{
+public:
+ FlowEmpty *shutter;
+ FlowFloat64 *setpos_request, *getpos_result;
+ FlowEmpty *getpos_request;
+ FlowInt32 *setpos_result;
+ FlowImage *image;
+ ImageFlowCodec<FlowImage> *codec;
+
+ double start_pos, end_pos, step;
+ ROS_FlowPair *setpos_pair, *getpos_pair, *cam_pair;
+ bool setpos_ok, image_ok;
+ double last_pos;
+ int image_count;
+
+ Sharks() : ROS_Slave(), image_count(0)
+ {
+ register_source(shutter = new FlowEmpty("shutter"));
+ register_source(setpos_request = new FlowFloat64("setpos_request"));
+ register_source(getpos_request = new FlowEmpty("getpos_request"));
+ register_sink(image = new FlowImage("image"), ROS_CALLBACK(Sharks, image_callback));
+ register_sink(setpos_result = new FlowInt32("setpos_result"), ROS_CALLBACK(Sharks, setpos_result_callback));
+ register_sink(getpos_result = new FlowFloat64("getpos_result"), ROS_CALLBACK(Sharks, getpos_result_callback));
+ setpos_pair = new ROS_FlowPair(setpos_request, setpos_result);
+ getpos_pair = new ROS_FlowPair(getpos_request, getpos_result);
+ cam_pair = new ROS_FlowPair(shutter, image);
+ register_with_master();
+ codec = new ImageFlowCodec<FlowImage>(image);
+ start_pos = -10;
+ end_pos = 10;
+ step = 1;
+ get_double_param(".start", &start_pos);
+ get_double_param(".end", &end_pos);
+ get_double_param(".step", &step);
+ }
+ virtual ~Sharks() { }
+
+ bool move_motor(double target, double *actual)
+ {
+ setpos_request->data = target;
+ setpos_pair->publish_and_block(30.0);
+ if (!setpos_ok)
+ {
+ printf("setpos not OK\n");
+ return false;
+ }
+ if (actual)
+ {
+ getpos_pair->publish_and_block(5.0);
+ *actual = last_pos;
+ }
+ return true;
+ }
+
+ void scan()
+ {
+ if (step == 0)
+ step = 1;
+ if (start_pos < end_pos && step < 0)
+ step *= -1;
+ else if (start_pos > end_pos && step > 0)
+ step *= -1;
+ for (double pos = start_pos; pos < end_pos; pos += step)
+ {
+ double actual;
+ if (!move_motor(pos, &actual))
+ {
+ printf("error moving to %f\n", pos);
+ break;
+ }
+ mvprintw(1,0,"commanded %f actual %f\n", pos, actual);
+ image_ok = false;
+ cam_pair->publish_and_block(5.0);
+ if (image_ok)
+ {
+ char fnamebuf[500];
+ image_count++;
+ snprintf(fnamebuf, sizeof(fnamebuf),
+ "shark_%05d_%010.5f_.jpg", image_count, actual);
+ codec->write_file(string(fnamebuf), 95);
+ }
+ }
+ }
+ void setpos_result_callback()
+ {
+ setpos_ok = (setpos_result->data == 1);
+ }
+ void getpos_result_callback()
+ {
+ last_pos = getpos_result->data;
+ }
+ void image_callback()
+ {
+ mvprintw(2,0,"received a %d by %d image\n", image->width, image->height);
+ image_ok = true;
+ }
+};
+
+void restore_terminal()
+{
+ echo();
+ noraw();
+ endwin();
+}
+
+int main(int argc, char **argv)
+{
+ Sharks s;
+ atexit(restore_terminal);
+ initscr();
+ noecho();
+ nodelay(stdscr, FALSE);
+ mvprintw(0, 0, "Press s to scan\n");
+ while (s.happy())
+ {
+ raw();
+ int c = getch();
+ noraw();
+ if (c == 0x03 || c == 0x04)
+ break;
+ else if (c == 's')
+ s.scan();
+ }
+ printf("sharks exiting\n");
+ return 0;
+}
+
Added: pkg/trunk/sharks/src/sharks2/Makefile
===================================================================
--- pkg/trunk/sharks/src/sharks2/Makefile (rev 0)
+++ pkg/trunk/sharks/src/sharks2/Makefile 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,4 @@
+SRC = sharks2.cpp
+OUT = ../../nodes/sharks2
+PKG = sharks
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Added: pkg/trunk/sharks/src/sharks2/sharks2.cpp
===================================================================
--- pkg/trunk/sharks/src/sharks2/sharks2.cpp (rev 0)
+++ pkg/trunk/sharks/src/sharks2/sharks2.cpp 2008-03-27 22:43:59 UTC (rev 47)
@@ -0,0 +1,140 @@
+// You must have ncurses installed on your system.
+// on Ubuntu: sudo apt-get install libncurses-dev
+#include <ncurses.h>
+#include "ros/ros_slave.h"
+#include "ros/ros_flowpair.h"
+#include "common_flows/FlowInt32.h"
+#include "common_flows/FlowFloat64.h"
+#include "common_flows/FlowEmpty.h"
+#include "image_flows/FlowImage.h"
+#include "image_flows/image_flow_codec.h"
+#include "ipdcmot/FlowPatrol.h"
+
+class Sharks : public ROS_Slave
+{
+public:
+ FlowEmpty *shutter;
+ FlowFloat64 *setpos_request, *getpos_result;
+ FlowEmpty *getpos_request;
+ FlowInt32 *setpos_result;
+ FlowImage *image;
+ ImageFlowCodec<FlowImage> *codec;
+
+ double start_pos, end_pos, step;
+ ROS_FlowPair *setpos_pair, *getpos_pair, *cam_pair;
+ bool setpos_ok, image_ok;
+ double last_pos;
+ int image_count;
+
+ Sharks() : ROS_Slave(), image_count(0)
+ {
+ register_source(shutter = new FlowEmpty("shutter"));
+ register_source(setpos_request = new FlowFloat64("setpos_request"));
+ register_source(getpos_request = new FlowEmpty("getpos_request"));
+ register_sink(image = new FlowImage("image"), ROS_CALLBACK(Sharks, image_callback));
+ register_sink(setpos_result = new FlowInt32("setpos_result"), ROS_CALLBACK(Sharks, setpos_result_callback));
+ register_sink(getpos_result = new FlowFloat64("getpos_result"), ROS_CALLBACK(Sharks, getpos_result_callback));
+ setpos_pair = new ROS_FlowPair(setpos_request, setpos_result);
+ getpos_pair = new ROS_FlowPair(getpos_request, getpos_result);
+ cam_pair = new ROS_FlowPair(shutter, image);
+ register_with_master();
+ codec = new ImageFlowCodec<FlowImage>(image);
+ start_pos = -10;
+ end_pos = 10;
+ step = 1;
+ get_double_param(".start", &start_pos);
+ get_double_param(".end", &end_pos);
+ get_double_param(".step", &step);
+ }
+ virtual ~Sharks() { }
+
+ bool move_motor(double target, double *actual)
+ {
+ setpos_request->data = target;
+ setpos_pair->publish_and_block(30.0);
+ if (!setpos_ok)
+ {
+ printf("setpos not OK\n");
+ return false;
+ }
+ if (actual)
+ {
+ getpos_pair->publish_and_block(5.0);
+ *actual = last_pos;
+ }
+ return true;
+ }
+
+ void scan()
+ {
+ if (step == 0)
+ step = 1;
+ if (start_pos < end_pos && step < 0)
+ step *= -1;
+ else if (start_pos > end_pos && step > 0)
+ step *= -1;
+ for (double pos = start_pos; pos < end_pos; pos += step)
+ {
+ double actual;
+ if (!move_motor(pos, &actual))
+ {
+ printf("error moving to %f\n", pos);
+ break;
+ }
+ mvprintw(1,0,"commanded %f actual %f\n", pos, actual);
+ image_ok = false;
+ cam_pair->publish_and_block(5.0);
+ if (image_ok)
+ {
+ char fnamebuf[500];
+ image_count++;
+ snprintf(fnamebuf, sizeof(fnamebuf),
+ "shark_%05d_%010.5f_.jpg", image_count, actual);
+ codec->write_file(string(fnamebuf), 95);
+ }
+ }
+ }
+ void setpos_result_callback()
+ {
+ setpos_ok = (setpos_result->data == 1);
+ }
+ void getpos_result_callback()
+ {
+ last_pos = getpos_result->data;
+ }
+ void image_callback()
+ {
+ mvprintw(2,0,"received a %d by %d image\n", image->width, image->height);
+ image_ok = true;
+ }
+};
+
+void restore_terminal()
+{
+ echo();
+ noraw();
+ endwin();
+}
+
+int main(int argc, char **argv)
+{
+ Sharks s;
+ atexit(restore_terminal);
+ initscr();
+ noecho();
+ nodelay(stdscr, FALSE);
+ mvprintw(0, 0, "Press s to scan\n");
+ while (s.happy())
+ {
+ raw();
+ int c = getch();
+ noraw();
+ if (c == 0x03 || c == 0x04)
+ break;
+ else if (c == 's')
+ s.scan();
+ }
+ printf("sharks exiting\n");
+ return 0;
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tf...@us...> - 2008-03-27 01:51:32
|
Revision: 46
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=46&view=rev
Author: tfoote
Date: 2008-03-26 18:51:37 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
adding back nodes to roslogger
Added Paths:
-----------
pkg/trunk/roslogger/nodes/
pkg/trunk/roslogger/nodes/loggingUI
pkg/trunk/roslogger/nodes/logging_node
Added: pkg/trunk/roslogger/nodes/loggingUI
===================================================================
--- pkg/trunk/roslogger/nodes/loggingUI (rev 0)
+++ pkg/trunk/roslogger/nodes/loggingUI 2008-03-27 01:51:37 UTC (rev 46)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+PKG = 'loggingUI'
+MODULE = 'loggingUI.loggingUI' #this is the module that will be invoked by python
+
+######################################################
+# BOILERPLATE: Should not have to modify anything
+# below except for very last line
+######################################################
+# Bootstrap ourselves into latest rospy install
+import sys, os, subprocess
+BOOTSTRAP_VERSION = "0.1"
+
+# Read in ROS_ROOT
+if not os.environ.has_key('ROS_ROOT'):
+ print """\nCannot run ROS: ROS_ROOT is not set.\nPlease set the ROS_ROOT environment variable to the
+location of your ROS install.\n"""
+ sys.exit(-1)
+rosRoot = os.environ['ROS_ROOT']
+
+# Read in the rospy directory location from the 'rospack latest rospy' command
+rospyDir = subprocess.Popen([os.path.join(rosRoot,'rospack'), 'latest', 'rospy'], stdout=subprocess.PIPE).communicate()[0]
+if rospyDir is None or not os.path.isdir(rospyDir.strip()):
+ print "\nERROR: Cannot locate rospy installation.\n"
+ sys.exit(-1)
+
+# Run launcher bootstrapper
+sys.path.append(os.path.join(rospyDir.strip(),'scripts'))
+import launcher
+
+manifestFile = launcher.getManifestFile(sys.argv[0], PKG)
+launcher.init(BOOTSTRAP_VERSION)
+launchCommand, launchArgs, launchEnv = \
+ launcher.getLaunchCommands(manifestFile, MODULE)
+launcher.ready(launchCommand, launchArgs, launchEnv, BOOTSTRAP_VERSION)
+
+######################################################
+# END BOILERPLATE:
+# You may wish to modify the exec command below to
+# customize the behavior of your node, e.g.:
+# * env['FOO'] = bar
+# * launchArgs.append('--test')
+######################################################
+
+os.execvpe(launchCommand, launchArgs, launchEnv)
Property changes on: pkg/trunk/roslogger/nodes/loggingUI
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/script
Added: pkg/trunk/roslogger/nodes/logging_node
===================================================================
--- pkg/trunk/roslogger/nodes/logging_node (rev 0)
+++ pkg/trunk/roslogger/nodes/logging_node 2008-03-27 01:51:37 UTC (rev 46)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+PKG = 'logging_node'
+MODULE = 'logging_node.logging_node' #this is the module that will be invoked by python
+
+######################################################
+# BOILERPLATE: Should not have to modify anything
+# below except for very last line
+######################################################
+# Bootstrap ourselves into latest rospy install
+import sys, os, subprocess
+BOOTSTRAP_VERSION = "0.1"
+
+# Read in ROS_ROOT
+if not os.environ.has_key('ROS_ROOT'):
+ print """\nCannot run ROS: ROS_ROOT is not set.\nPlease set the ROS_ROOT environment variable to the
+location of your ROS install.\n"""
+ sys.exit(-1)
+rosRoot = os.environ['ROS_ROOT']
+
+# Read in the rospy directory location from the 'rospack latest rospy' command
+rospyDir = subprocess.Popen([os.path.join(rosRoot,'rospack'), 'latest', 'rospy'], stdout=subprocess.PIPE).communicate()[0]
+if rospyDir is None or not os.path.isdir(rospyDir.strip()):
+ print "\nERROR: Cannot locate rospy installation.\n"
+ sys.exit(-1)
+
+# Run launcher bootstrapper
+sys.path.append(os.path.join(rospyDir.strip(),'scripts'))
+import launcher
+
+manifestFile = launcher.getManifestFile(sys.argv[0], PKG)
+launcher.init(BOOTSTRAP_VERSION)
+launchCommand, launchArgs, launchEnv = \
+ launcher.getLaunchCommands(manifestFile, MODULE)
+launcher.ready(launchCommand, launchArgs, launchEnv, BOOTSTRAP_VERSION)
+
+######################################################
+# END BOILERPLATE:
+# You may wish to modify the exec command below to
+# customize the behavior of your node, e.g.:
+# * env['FOO'] = bar
+# * launchArgs.append('--test')
+######################################################
+
+os.execvpe(launchCommand, launchArgs, launchEnv)
Property changes on: pkg/trunk/roslogger/nodes/logging_node
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/script
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-27 00:40:12
|
Revision: 45
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=45&view=rev
Author: morgan_quigley
Date: 2008-03-26 17:40:19 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
axis_cam is pretty much cleaned of all the wget detritus now
Modified Paths:
--------------
pkg/trunk/axis_cam/build.yaml
pkg/trunk/axis_cam/manifest.xml
pkg/trunk/axis_cam/test/test_ptz/Makefile
Modified: pkg/trunk/axis_cam/build.yaml
===================================================================
--- pkg/trunk/axis_cam/build.yaml 2008-03-27 00:39:17 UTC (rev 44)
+++ pkg/trunk/axis_cam/build.yaml 2008-03-27 00:40:19 UTC (rev 45)
@@ -1,7 +1,7 @@
cpp:
make:
- src/libaxis_cam
- - src/axis_cam_wget
- - src/axis_cam_wget_polled
- - test/test_wget
+ - src/axis_cam
+ - src/axis_cam_polled
+ - test/test_get
- test/test_ptz
Modified: pkg/trunk/axis_cam/manifest.xml
===================================================================
--- pkg/trunk/axis_cam/manifest.xml 2008-03-27 00:39:17 UTC (rev 44)
+++ pkg/trunk/axis_cam/manifest.xml 2008-03-27 00:40:19 UTC (rev 45)
@@ -11,7 +11,6 @@
<author>Morgan Quigley (email: mqu...@cs...)</author>
<license>BSD</license>
<url>http://stair.stanford.edu</url>
-<depend package="image_flows"/>
<depend package="common_flows"/>
<depend package="image_viewer"/>
</package>
Modified: pkg/trunk/axis_cam/test/test_ptz/Makefile
===================================================================
--- pkg/trunk/axis_cam/test/test_ptz/Makefile 2008-03-27 00:39:17 UTC (rev 44)
+++ pkg/trunk/axis_cam/test/test_ptz/Makefile 2008-03-27 00:40:19 UTC (rev 45)
@@ -1,5 +1,5 @@
SRC = test_ptz.cpp
OUT = test_ptz
-LFLAGS = -L../../lib -laxis_cam
+LFLAGS = -L../../lib -laxis_cam -lcurl
PKG = axis_cam
include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node_just_libros.mk
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-27 00:39:13
|
Revision: 44
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=44&view=rev
Author: morgan_quigley
Date: 2008-03-26 17:39:17 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
more cleanup of axis_cam test programs
Added Paths:
-----------
pkg/trunk/axis_cam/test/test_get/
pkg/trunk/axis_cam/test/test_get/Makefile
pkg/trunk/axis_cam/test/test_get/test_get.cpp
Removed Paths:
-------------
pkg/trunk/axis_cam/test/test_get/Makefile
pkg/trunk/axis_cam/test/test_get/test_wget.cpp
pkg/trunk/axis_cam/test/test_wget/
Copied: pkg/trunk/axis_cam/test/test_get (from rev 38, pkg/trunk/axis_cam/test/test_wget)
Deleted: pkg/trunk/axis_cam/test/test_get/Makefile
===================================================================
--- pkg/trunk/axis_cam/test/test_wget/Makefile 2008-03-27 00:27:14 UTC (rev 38)
+++ pkg/trunk/axis_cam/test/test_get/Makefile 2008-03-27 00:39:17 UTC (rev 44)
@@ -1,5 +0,0 @@
-SRC = test_wget.cpp
-OUT = test_wget
-LFLAGS = -L../../lib -laxis_cam
-PKG = axis_cam
-include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node_just_libros.mk
Copied: pkg/trunk/axis_cam/test/test_get/Makefile (from rev 43, pkg/trunk/axis_cam/test/test_wget/Makefile)
===================================================================
--- pkg/trunk/axis_cam/test/test_get/Makefile (rev 0)
+++ pkg/trunk/axis_cam/test/test_get/Makefile 2008-03-27 00:39:17 UTC (rev 44)
@@ -0,0 +1,5 @@
+SRC = test_get.cpp
+OUT = test_get
+LFLAGS = -L../../lib -laxis_cam -lcurl
+PKG = axis_cam
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node_just_libros.mk
Copied: pkg/trunk/axis_cam/test/test_get/test_get.cpp (from rev 43, pkg/trunk/axis_cam/test/test_wget/test_get.cpp)
===================================================================
--- pkg/trunk/axis_cam/test/test_get/test_get.cpp (rev 0)
+++ pkg/trunk/axis_cam/test/test_get/test_get.cpp 2008-03-27 00:39:17 UTC (rev 44)
@@ -0,0 +1,66 @@
+///////////////////////////////////////////////////////////////////////////////
+// The axis_cam package provides a library that talks to Axis IP-based cameras
+// as well as ROS nodes which use these libraries
+//
+// Copyright (C) 2008, Morgan Quigley
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#include <cstdio>
+#include "axis_cam/axis_cam.h"
+
+AxisCam *axis;
+
+bool tryit()
+{
+ uint8_t *jpeg;
+ uint32_t jpeg_size;
+ bool ok = axis->get_jpeg(&jpeg, &jpeg_size);
+ if (ok)
+ {
+ printf("caller jpeg size = %d\n", jpeg_size);
+ FILE *f = fopen("saved.jpg", "wb");
+ fwrite(jpeg, 1, jpeg_size, f);
+ fclose(f);
+ return true;
+ }
+ else
+ {
+ printf("not ok\n");
+ return false;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ printf("construct AxisCam object...\n");
+ axis = new AxisCam("192.168.1.90");
+
+ tryit();
+
+ printf("delete AxisCam...\n");
+ delete axis;
+ return 0;
+}
+
Deleted: pkg/trunk/axis_cam/test/test_get/test_wget.cpp
===================================================================
--- pkg/trunk/axis_cam/test/test_wget/test_wget.cpp 2008-03-27 00:27:14 UTC (rev 38)
+++ pkg/trunk/axis_cam/test/test_get/test_wget.cpp 2008-03-27 00:39:17 UTC (rev 44)
@@ -1,66 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// The axis_cam package provides a library that talks to Axis IP-based cameras
-// as well as ROS nodes which use these libraries
-//
-// Copyright (C) 2008, Morgan Quigley
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-// * Neither the name of Stanford University nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-
-#include <cstdio>
-#include "axis_cam/axis_cam.h"
-
-AxisCam *axis;
-
-bool tryit()
-{
- uint8_t *jpeg;
- uint32_t jpeg_size;
- bool ok = axis->wget_jpeg(&jpeg, &jpeg_size);
- if (ok)
- {
- printf("caller jpeg size = %d\n", jpeg_size);
- FILE *f = fopen("resaved.jpg", "wb");
- fwrite(jpeg, 1, jpeg_size, f);
- fclose(f);
- return true;
- }
- else
- {
- printf("not ok\n");
- return false;
- }
-}
-
-int main(int argc, char **argv)
-{
- printf("construct AxisCam object...\n");
- axis = new AxisCam("192.168.1.90");
-
- tryit();
-
- printf("delete AxisCam...\n");
- delete axis;
- return 0;
-}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-27 00:38:49
|
Revision: 43
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=43&view=rev
Author: morgan_quigley
Date: 2008-03-26 17:38:55 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
cleaning up test programs in axis_cam
Modified Paths:
--------------
pkg/trunk/axis_cam/test/test_wget/Makefile
Added Paths:
-----------
pkg/trunk/axis_cam/test/test_wget/test_get.cpp
Removed Paths:
-------------
pkg/trunk/axis_cam/test/test_wget/test_wget.cpp
Modified: pkg/trunk/axis_cam/test/test_wget/Makefile
===================================================================
--- pkg/trunk/axis_cam/test/test_wget/Makefile 2008-03-27 00:35:00 UTC (rev 42)
+++ pkg/trunk/axis_cam/test/test_wget/Makefile 2008-03-27 00:38:55 UTC (rev 43)
@@ -1,5 +1,5 @@
-SRC = test_wget.cpp
-OUT = test_wget
-LFLAGS = -L../../lib -laxis_cam
+SRC = test_get.cpp
+OUT = test_get
+LFLAGS = -L../../lib -laxis_cam -lcurl
PKG = axis_cam
include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node_just_libros.mk
Copied: pkg/trunk/axis_cam/test/test_wget/test_get.cpp (from rev 38, pkg/trunk/axis_cam/test/test_wget/test_wget.cpp)
===================================================================
--- pkg/trunk/axis_cam/test/test_wget/test_get.cpp (rev 0)
+++ pkg/trunk/axis_cam/test/test_wget/test_get.cpp 2008-03-27 00:38:55 UTC (rev 43)
@@ -0,0 +1,66 @@
+///////////////////////////////////////////////////////////////////////////////
+// The axis_cam package provides a library that talks to Axis IP-based cameras
+// as well as ROS nodes which use these libraries
+//
+// Copyright (C) 2008, Morgan Quigley
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#include <cstdio>
+#include "axis_cam/axis_cam.h"
+
+AxisCam *axis;
+
+bool tryit()
+{
+ uint8_t *jpeg;
+ uint32_t jpeg_size;
+ bool ok = axis->get_jpeg(&jpeg, &jpeg_size);
+ if (ok)
+ {
+ printf("caller jpeg size = %d\n", jpeg_size);
+ FILE *f = fopen("saved.jpg", "wb");
+ fwrite(jpeg, 1, jpeg_size, f);
+ fclose(f);
+ return true;
+ }
+ else
+ {
+ printf("not ok\n");
+ return false;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ printf("construct AxisCam object...\n");
+ axis = new AxisCam("192.168.1.90");
+
+ tryit();
+
+ printf("delete AxisCam...\n");
+ delete axis;
+ return 0;
+}
+
Deleted: pkg/trunk/axis_cam/test/test_wget/test_wget.cpp
===================================================================
--- pkg/trunk/axis_cam/test/test_wget/test_wget.cpp 2008-03-27 00:35:00 UTC (rev 42)
+++ pkg/trunk/axis_cam/test/test_wget/test_wget.cpp 2008-03-27 00:38:55 UTC (rev 43)
@@ -1,66 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// The axis_cam package provides a library that talks to Axis IP-based cameras
-// as well as ROS nodes which use these libraries
-//
-// Copyright (C) 2008, Morgan Quigley
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-// * Neither the name of Stanford University nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-
-#include <cstdio>
-#include "axis_cam/axis_cam.h"
-
-AxisCam *axis;
-
-bool tryit()
-{
- uint8_t *jpeg;
- uint32_t jpeg_size;
- bool ok = axis->wget_jpeg(&jpeg, &jpeg_size);
- if (ok)
- {
- printf("caller jpeg size = %d\n", jpeg_size);
- FILE *f = fopen("resaved.jpg", "wb");
- fwrite(jpeg, 1, jpeg_size, f);
- fclose(f);
- return true;
- }
- else
- {
- printf("not ok\n");
- return false;
- }
-}
-
-int main(int argc, char **argv)
-{
- printf("construct AxisCam object...\n");
- axis = new AxisCam("192.168.1.90");
-
- tryit();
-
- printf("delete AxisCam...\n");
- delete axis;
- return 0;
-}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mor...@us...> - 2008-03-27 00:34:56
|
Revision: 42
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=42&view=rev
Author: morgan_quigley
Date: 2008-03-26 17:35:00 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
bye bye wget in axis_cam
Added Paths:
-----------
pkg/trunk/axis_cam/src/axis_cam_polled/
pkg/trunk/axis_cam/src/axis_cam_polled/Makefile
pkg/trunk/axis_cam/src/axis_cam_polled/axis_cam_polled.cpp
Removed Paths:
-------------
pkg/trunk/axis_cam/src/axis_cam_polled/Makefile
pkg/trunk/axis_cam/src/axis_cam_polled/axis_cam_wget_polled.cpp
pkg/trunk/axis_cam/src/axis_cam_wget_polled/
Copied: pkg/trunk/axis_cam/src/axis_cam_polled (from rev 38, pkg/trunk/axis_cam/src/axis_cam_wget_polled)
Deleted: pkg/trunk/axis_cam/src/axis_cam_polled/Makefile
===================================================================
--- pkg/trunk/axis_cam/src/axis_cam_wget_polled/Makefile 2008-03-27 00:27:14 UTC (rev 38)
+++ pkg/trunk/axis_cam/src/axis_cam_polled/Makefile 2008-03-27 00:35:00 UTC (rev 42)
@@ -1,4 +0,0 @@
-SRC = axis_cam_wget_polled.cpp
-OUT = ../../nodes/axis_cam_wget_polled
-PKG = axis_cam
-include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Copied: pkg/trunk/axis_cam/src/axis_cam_polled/Makefile (from rev 41, pkg/trunk/axis_cam/src/axis_cam_wget_polled/Makefile)
===================================================================
--- pkg/trunk/axis_cam/src/axis_cam_polled/Makefile (rev 0)
+++ pkg/trunk/axis_cam/src/axis_cam_polled/Makefile 2008-03-27 00:35:00 UTC (rev 42)
@@ -0,0 +1,4 @@
+SRC = axis_cam_polled.cpp
+OUT = ../../nodes/axis_cam_polled
+PKG = axis_cam
+include $(shell $(ROS_ROOT)/rospack find roscpp)/make_include/node.mk
Copied: pkg/trunk/axis_cam/src/axis_cam_polled/axis_cam_polled.cpp (from rev 41, pkg/trunk/axis_cam/src/axis_cam_wget_polled/axis_cam_polled.cpp)
===================================================================
--- pkg/trunk/axis_cam/src/axis_cam_polled/axis_cam_polled.cpp (rev 0)
+++ pkg/trunk/axis_cam/src/axis_cam_polled/axis_cam_polled.cpp 2008-03-27 00:35:00 UTC (rev 42)
@@ -0,0 +1,92 @@
+///////////////////////////////////////////////////////////////////////////////
+// The axis_cam package provides a library that talks to Axis IP-based cameras
+// as well as ROS nodes which use these libraries
+//
+// Copyright (C) 2008, Morgan Quigley
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Stanford University nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#include "ros/ros_slave.h"
+#include "SDL/SDL.h"
+#include "image_flows/FlowImage.h"
+#include "common_flows/FlowEmpty.h"
+#include "axis_cam/axis_cam.h"
+
+class AxisCamPolled : public ROS_Slave
+{
+public:
+ FlowImage *image;
+ FlowEmpty *shutter;
+ string axis_host;
+ AxisCam *cam;
+ int frame_id;
+
+ AxisCamPolled() : ROS_Slave(), cam(NULL), frame_id(0)
+ {
+ register_source(image = new FlowImage("image"));
+ register_sink(shutter = new FlowEmpty("shutter"),
+ ROS_CALLBACK(AxisCamPolled, shutter_cb));
+ if (!get_string_param(".host", axis_host))
+ {
+ printf("axis_host parameter not specified; defaulting to 192.168.0.90\n");
+ axis_host = "192.168.0.90";
+ }
+ printf("axis host set to [%s]\n", axis_host.c_str());
+ get_int_param(".frame_id", &frame_id);
+ cam = new AxisCam(axis_host);
+ }
+ virtual ~AxisCamPolled()
+ {
+ if (cam)
+ delete cam;
+ }
+ bool take_and_send_image()
+ {
+ uint8_t *jpeg;
+ uint32_t jpeg_size;
+ if (!cam->get_jpeg(&jpeg, &jpeg_size))
+ return false;
+ image->set_data_size(jpeg_size);
+ memcpy(image->data, jpeg, jpeg_size);
+ image->width = 704;
+ image->height = 480;
+ image->compression = "jpeg";
+ image->colorspace = "rgb24";
+ image->frame_id = frame_id;
+ image->publish();
+ return true;
+ }
+ void shutter_cb()
+ {
+ take_and_send_image();
+ }
+};
+
+int main(int argc, char **argv)
+{
+ AxisCamPolled a;
+ a.spin();
+ return 0;
+}
+
Deleted: pkg/trunk/axis_cam/src/axis_cam_polled/axis_cam_wget_polled.cpp
===================================================================
--- pkg/trunk/axis_cam/src/axis_cam_wget_polled/axis_cam_wget_polled.cpp 2008-03-27 00:27:14 UTC (rev 38)
+++ pkg/trunk/axis_cam/src/axis_cam_polled/axis_cam_wget_polled.cpp 2008-03-27 00:35:00 UTC (rev 42)
@@ -1,91 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// The axis_cam package provides a library that talks to Axis IP-based cameras
-// as well as ROS nodes which use these libraries
-//
-// Copyright (C) 2008, Morgan Quigley
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-// * Neither the name of Stanford University nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-
-#include "ros/ros_slave.h"
-#include "SDL/SDL.h"
-#include "image_flows/FlowImage.h"
-#include "common_flows/FlowEmpty.h"
-#include "axis_cam/axis_cam.h"
-
-class AxisCamWgetPolled : public ROS_Slave
-{
-public:
- FlowImage *image;
- FlowEmpty *shutter;
- string axis_host;
- AxisCam *cam;
- int frame_id;
-
- AxisCamWgetPolled() : ROS_Slave(), cam(NULL), frame_id(0)
- {
- register_source(image = new FlowImage("image"));
- register_sink(shutter = new FlowEmpty("shutter"), ROS_CALLBACK(AxisCamWgetPolled, shutter_callback));
- if (!get_string_param(".host", axis_host))
- {
- printf("axis_host parameter not specified; defaulting to 192.168.0.90\n");
- axis_host = "192.168.0.90";
- }
- printf("axis host set to [%s]\n", axis_host.c_str());
- get_int_param(".frame_id", &frame_id);
- cam = new AxisCam(axis_host);
- }
- virtual ~AxisCamWgetPolled()
- {
- if (cam)
- delete cam;
- }
- bool take_and_send_image()
- {
- uint8_t *jpeg;
- uint32_t jpeg_size;
- if (!cam->wget_jpeg(&jpeg, &jpeg_size))
- return false;
- image->set_data_size(jpeg_size);
- memcpy(image->data, jpeg, jpeg_size);
- image->width = 704;
- image->height = 480;
- image->compression = "jpeg";
- image->colorspace = "rgb24";
- image->frame_id = frame_id;
- image->publish();
- return true;
- }
- void shutter_callback()
- {
- take_and_send_image();
- }
-};
-
-int main(int argc, char **argv)
-{
- AxisCamWgetPolled a;
- a.spin();
- return 0;
-}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|