Internal:SOGP Instructions

From Brown University Robotics

Jump to: navigation, search




  • ros_cpp
  • std_msgs


 rosmake sogp

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


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

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


 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


  • Vector input
  • Vector output


  • Matrix input
  • Matrix output

where Vector and Matrix are defined as


  • float32[] data


  • 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


  • Vector input


  • Vector output
  • string error_msg


  • Matrix input


  • Matrix output
  • string error_msg


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


sogp also provides a few utilities for working directly with text files outside of the ros framework. trainSOGP allows the user to save a learned regressor from data provided in text files, and predictSOGP provides to create a file of predictions given a saved SOGP and a text file of input values.

This page was last modified on 22 June 2010, at 21:05. This page has been accessed 253 times.