ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

IncredibleHWH's profile - activity

2022-06-24 16:42:46 -0500 received badge  Taxonomist
2019-05-12 20:56:55 -0500 received badge  Famous Question (source)
2019-05-12 20:56:55 -0500 received badge  Notable Question (source)
2017-04-06 07:49:04 -0500 received badge  Popular Question (source)
2016-06-23 00:49:31 -0500 received badge  Enthusiast
2016-06-14 01:14:00 -0500 asked a question Problem of Baxter Bobot (Joint movement,Position Control)

I am a new beginner of C++ and ROS. I am going to write a program in C++ to control the joints to move continuously in a periodic motion. I have type a program for it, but it seems nothing is running after I run the program. The program skeleton:

#include "ros/ros.h"
#include "baxter_core_msgs/JointCommand.h"
#include <sstream>
#include <iostream>
#include "math.h"
int main(int argc, char **argv){

    ros::init(argc, argv, "joint_position_command");
    ros::NodeHandle n;
    ros::Publisher jc_pub = n.advertise<baxter_core_msgs::JointCommand>("/robot/limb/right/joint_command", 1);  
    ros::Rate loop_rate(10);
    baxter_core_msgs::JointCommand jc_msg;
    jc_msg.mode = jc_msg.POSITION_MODE;
    for(int i=0;i<91;i++){
    jc_msg.command.push_back(sin(i));
    jc_msg.names.push_back("right_s0");
    }
    while (ros::ok())
    {
        jc_pub.publish(jc_msg);
        ros::spinOnce();
        loop_rate.sleep();
    }
  return 0;
}

Can anyone help me? Or give some suggestion/work flow on how to do a continuous periodic motion on Baxter's arm in C++ language?