-
Notifications
You must be signed in to change notification settings - Fork 4
Helpful ROS Code
xiaozhengxu edited this page Dec 17, 2016
·
4 revisions
Publish to a topic to change a parameter in your code. Probably works the same with most other singular data types. It's a good idea to make one topic per parameter, so all of them are individually changeable.
#include "std_msgs/Float32.h"
float D = 0.5; //at initialized value
void setD(const std_msgs::Float32::ConstPtr& msg){ //callback
D = msg->data;
ROS_INFO("D CHANGED.");
}
int main(int argc, char **argv)
{
//node initialization stuff goes here
ros::Subscriber Dsub = n.subscribe("wall_follow/D", 1, setD);
ros::spin();
return 0;
}
###To set ROS_IP:
$export ROS_IP='your IP address'