moving a simple object
Hi All, I want to move an object, for example a box in 3D space, using ROS and visualize its movements in RVIZ. for this reason I wrote this node,
#include <ros/ros.h>
#include "geometry_msgs/PoseStamped.h"
#include "geometry_msgs/Pose.h"
// publisher handles
ros::Publisher goal_pub;
void publish_goal()
{
geometry_msgs::PoseStamped msg;
msg.header.frame_id = "base_link";
msg.pose.position.x += 2;
msg.pose.position.y = 20;
msg.pose.position.z = 50;
msg.pose.orientation.w = 0;
msg.pose.orientation.x = -2.0;
msg.pose.orientation.y = 0;
msg.pose.orientation.z = 0;
goal_pub.publish(msg);
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "move_sphere");
ros::NodeHandle nh;
ros::Rate loop_rate(100);
goal_pub = nh.advertise<geometry_msgs::PoseStamped>("pose", 1);
while (ros::ok())
{
publish_goal();
ros::spinOnce();
loop_rate.sleep();
}
}
but the object don't move. anyone can tell me what is the mistake in code.