publish from gazebo
hi guys, i want to publish from a gazebo plugin. How can i do that? In the same way as i publish from a common node? so do i have to write a main() and while{} and so on? I want to publish torque in order to plot it with rxplot. this is the part of the plugin:
torque.x = inertia.x * controllers_.roll.update(roll_command, euler.x, angular_velocity.x, dt);
torque.y = inertia.y * controllers_.pitch.update(pitch_command, euler.y, angular_velocity.y, dt);
body_->SetTorque(torque);
i try following, is this the right way?
ros::Publisher wrench_publisher;
geometry_msgs::Wrench moment;
int main(int argc, char **argv)
{
ros::init(argc, argv, "hector_quadrotor_gazebo_plugins");
ros::NodeHandle node_handle;
ros::Rate loop_rate(100);
wrench_publisher_ = node_handle.advertise<geometry_msgs::Wrench>("force", 1);
while(ros::ok())
{
ros::spinOnce();
moment.torque.x = torque.x ;
moment.torque.y = torque.y;
wrench_publisher.publish(moment);
}
return 0;
}