March 2018
Intermediate to advanced
1396 pages
42h 14m
English
Now, we are going to show you how you can move the motor using a node. Create a new file, c8_dynamixel.cpp, in your /c_tutorials/src directory with the following code snippet:
#include<ros/ros.h>
#include<std_msgs/Float64.h>
#include<stdio.h>
using namespace std;
class Dynamixel{
private:
ros::NodeHandle n;
ros::Publisher pub_n;
public:
Dynamixel();
int moveMotor(double position);
};
Dynamixel::Dynamixel(){
pub_n = n.advertise<std_msgs::Float64> ("/tilt_controller/command",1); } int Dynamixel::moveMotor(double position) { std_msgs::Float64 aux; aux.data = position; pub_n.publish(aux); return 1; } int main(int argc,char** argv) { ros::init(argc, argv, "c8_dynamixel"); Dynamixel motors; float counter ...