Created
July 17, 2015 12:45
-
-
Save prrraveen/d73024d54987178f4033 to your computer and use it in GitHub Desktop.
‘MyRobot::MyRobot’ names the constructor, not the type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
#include "fcm.h" | |
#include <controller_manager/controller_manager.h> | |
int main(int argc , char **argv) | |
{ | |
//setup | |
ros::init(argc , argv , "my_robot"); | |
MyRobot::MyRobot robot; | |
controller_manager::ControllerManager cm(&robot); | |
ros::AsyncSpinner spinner(1); | |
spinner.start(); | |
//control loop | |
ros::Time prev_time = ros::Time::now(); | |
ros::Rate rate(10.0); | |
while(ros::ok()) | |
{ | |
const ros::Time time = ros::Time::now(); | |
const ros::Duration period = time - prev_time; | |
robot.read(); | |
cm.update(time , period); | |
robot.write(); | |
rate.sleep(); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <hardware_interface/joint_command_interface.h> | |
#include <hardware_interface/joint_state_interface.h> | |
#include <hardware_interface/robot_hw.h> | |
class MyRobot : public hardware_interface::RobotHW | |
{ | |
public: | |
MyRobot() | |
{ | |
// connect and register the joint state interface | |
hardware_interface::JointStateHandle state_handle_a("A", &pos[0], &vel[0], &eff[0]); | |
jnt_state_interface.registerHandle(state_handle_a); | |
hardware_interface::JointStateHandle state_handle_b("B", &pos[1], &vel[1], &eff[1]); | |
jnt_state_interface.registerHandle(state_handle_b); | |
registerInterface(&jnt_state_interface); | |
// connect and register the joint position interface | |
hardware_interface::JointHandle pos_handle_a(jnt_state_interface.getHandle("A"), &cmd[0]); | |
jnt_pos_interface.registerHandle(pos_handle_a); | |
hardware_interface::JointHandle pos_handle_b(jnt_state_interface.getHandle("B"), &cmd[1]); | |
jnt_pos_interface.registerHandle(pos_handle_b); | |
registerInterface(&jnt_pos_interface); | |
} | |
private: | |
hardware_interface::JointStateInterface jnt_state_interface; | |
hardware_interface::PositionJointInterface jnt_pos_interface; | |
double cmd[2]; | |
double pos[2]; | |
double vel[2]; | |
double eff[2]; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get this error
/home/ubuntu14/ind_src/src/fcm_control/src/control_manager.cpp: In function ‘int main(int, char**)’:
/home/ubuntu14/ind_src/src/fcm_control/src/control_manager.cpp:10:5: error: ‘MyRobot::MyRobot’ names the constructor, not the type
MyRobot::MyRobot robot;