Internal:SOGP Instructions

From Brown University Robotics

(Difference between revisions)
Jump to: navigation, search
Line 21: Line 21:
  rosrun sogp sogp_regress
  rosrun sogp sogp_regress
 +
However, before you can run sogp_regress you must set several parameter values. Here's a set of parameter values and the roslaunch code for setting them to example values.
However, before you can run sogp_regress you must set several parameter values. Here's a set of parameter values and the roslaunch code for setting them to example values.
Line 34: Line 35:
   <param name="sogp/saveFile" type="string" value="$(find naoInvKinematics)/SOGP.txt" />
   <param name="sogp/saveFile" type="string" value="$(find naoInvKinematics)/SOGP.txt" />
 +
For a simple demo, try
 +
  roslaunch sogp_test.launch
 +
 +
Check out the source in sogp_ros/sogp_test.cpp to see an example of how to use the node.
==Messages and Services==
==Messages and Services==
-
*sogp* listens to for training the function regressor, accepting single datapoints or matrices of data points respectively.
+
sogp listens to messages on the topics 'AddVector' and 'AddMatrix' for training the function regressor, accepting single datapoints or matrices of data points respectively. The messages for each topic are AddVector and AddMatrix which are defined as follows
-
 
+
-
ar/image contains the image with the tags outlined in the image
+
-
 
+
-
If the camera image is a rectified one with appropriate camera parameters, *ar_recog* will use them to determine the mapping between image space and physical space. However, the rectification pipeline is slow and camera calibration brittle, so the package also provides distance mapping with uncalibrated images. To use this feature, it must know your camera's horizontal angle of view. This can be provided as a ROS parameter ("aov"), or determined using the CalibrateDistance service.
+
-
 
+
-
*ar_recog* defines two message types:
+
-
 
+
-
Tags:
+
-
 
+
-
 
+
-
and
+
-
 
+
-
Tag:
+
-
 
+
-
 
+
-
 
+
-
==Calibrating Distance==
+
AddVector:
 +
*Vector input
 +
*Vector output
-
*This is only necessary when _not_ using a calibrated camera.*
+
AddMatrix:
 +
*Matrix input
 +
*Matrix output
-
  # Set up a clear, recognized AR tag at a known distance from the camera.
+
where Vector and Matrix are defined as
-
  # Start the *ar_recog* node and monitor the /tags message
+
-
  # Arrange the AR tag and camera so that the tag coordinates are as close as possible to the center of the image, and the xRot, yRot and zRot are as close as possible to zero. This will minimize distortion.
+
-
  # Call the CalibrateDistance service, where _dist_ is the distance between the AR tag and the camera in millimeters:
+
 +
Vector:
 +
*float32[] data
-
===Tips===
+
Matrix:
 +
*Vector[] matrix_rows
-
  # The more accurately the distance is known, the better *ar_recog* is able to undistort the image. Thus you may have to repeat the service call a few times until the reported distance converges on the value you are providing.
+
sogp offers the services 'PredictVector' and 'PredictMatrix' for predicting from the current regressor at a single datapoint or a matrix of datapoints. These services are defined as follows
-
  # Save this aov value to provide as a ROS parameter next time you use *ar_recog* with this camera.
+
 +
PredictVector:
 +
*Vector input
 +
----
 +
*Vector output
 +
*string error_msg
 +
PredictMatrix
 +
*Matrix input
 +
----
 +
*Matrix output
 +
*string error_msg
-
==ARToolKit Compatibility/Interoperability==
 
-
*ar_recog* is compatible with standard ARToolKit pattern and object_data files. When not used with ROS's image_proc, *ar_recog* utilizes an ARToolkit camera_para.dat file. See the files within the `bin` directory and the [http://www.hitl.washington.edu/artoolkit/documentation ARToolKit documentation].
+
==Tips==
 +
Parameter selection is important. Increasing the width will smooth the regressor, while having too small a width will not generalize predicting zero almost everywhere. We frequently scale our data to between -1 and 1 for easier parameter selection (frequently allows us to reuse the same parameters).

Revision as of 15:40, 3 June 2010

Contents

sogp

Dependencies

  • ros_cpp
  • std_msgs


Making

 rosmake sogp

The *sogp* package contains the newmat and sogp libraries. It builds these libraries locally in the sogp directory.


Running

To run code that does the regression and predicts new values

rosrun sogp sogp_regress


However, before you can run sogp_regress you must set several parameter values. Here's a set of parameter values and the roslaunch code for setting them to example values.

 <param name="sogp/width" type="double" value=".2"/>
 <param name="sogp/capacity" type="int" value="300"/>
 <param name="sogp/noise" type="double" value=".1"/>
 <param name="sogp/inputDimension" type="int" value="6"/>
 <param name="sogp/outputDimension" type="int" value="5"/>

Additional parameters which you can set specify file names for saving a trained sogp or loading an existing sogp save file, for example

 <param name="sogp/saveFile" type="string" value="$(find naoInvKinematics)/SOGP.txt" />

or

 <param name="sogp/saveFile" type="string" value="$(find naoInvKinematics)/SOGP.txt" />

For a simple demo, try

 roslaunch sogp_test.launch

Check out the source in sogp_ros/sogp_test.cpp to see an example of how to use the node.

Messages and Services

sogp listens to messages on the topics 'AddVector' and 'AddMatrix' for training the function regressor, accepting single datapoints or matrices of data points respectively. The messages for each topic are AddVector and AddMatrix which are defined as follows

AddVector:

  • Vector input
  • Vector output

AddMatrix:

  • Matrix input
  • Matrix output

where Vector and Matrix are defined as

Vector:

  • float32[] data

Matrix:

  • Vector[] matrix_rows

sogp offers the services 'PredictVector' and 'PredictMatrix' for predicting from the current regressor at a single datapoint or a matrix of datapoints. These services are defined as follows

PredictVector:

  • Vector input

  • Vector output
  • string error_msg

PredictMatrix

  • Matrix input

  • Matrix output
  • string error_msg


Tips

Parameter selection is important. Increasing the width will smooth the regressor, while having too small a width will not generalize predicting zero almost everywhere. We frequently scale our data to between -1 and 1 for easier parameter selection (frequently allows us to reuse the same parameters).