Internal:SOGP Instructions

From Brown University Robotics

(Difference between revisions)
Jump to: navigation, search
(Running)
Line 17: Line 17:
==Running==
==Running==
 +
Before you can run an sogp_node, you need to set a few parameters. You can do this from the command line
 +
  rosparam set sogp/width .2
 +
  rosparam set sogp/capacity 300
 +
  rosparam set sogp/noise .1
 +
  rosparam set sogp/inputDimension 6
 +
  rosparam set sogp/outputDimension 5
 +
You can also set these values in a launch file (see sogp_test.launch)
To run code that does the regression and predicts new values
To run code that does the regression and predicts new values
Line 23: Line 30:
-
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
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" />
+
   rosparam set sogp/saveFile ~/test.txt
or
or
-
   <param name="sogp/saveFile" type="string" value="$(find naoInvKinematics)/SOGP.txt" />
+
   rosparam set sogp/loadFile ~/test.txt
 +
Note the parameters sogp/saveFile and sogp/loadFile are cleared every time you shutdown the sogp_regress node. The other parameters persist across multiple runs.
For a simple demo, try  
For a simple demo, try  
   roslaunch sogp_test.launch
   roslaunch sogp_test.launch
-
Check out the source in sogp_ros/sogp_test.cpp to see an example of how to use the node.
+
Check out the source in sogp_ros/sogp_test.cpp to see an example the sogp node in use.
==Messages and Services==
==Messages and Services==

Revision as of 20:37, 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

Before you can run an sogp_node, you need to set a few parameters. You can do this from the command line

 rosparam set sogp/width .2
 rosparam set sogp/capacity 300
 rosparam set sogp/noise .1
 rosparam set sogp/inputDimension 6
 rosparam set sogp/outputDimension 5

You can also set these values in a launch file (see sogp_test.launch)

To run code that does the regression and predicts new values

rosrun sogp sogp_regress


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

 rosparam set sogp/saveFile ~/test.txt

or

 rosparam set sogp/loadFile ~/test.txt

Note the parameters sogp/saveFile and sogp/loadFile are cleared every time you shutdown the sogp_regress node. The other parameters persist across multiple runs.

For a simple demo, try

 roslaunch sogp_test.launch

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

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).