#include "ros/ros.h"
#include "std_msgs/UInt8.h"
#include "Robot.h"
#include <iostream>
int main(int argc, char **argv)
{
ros::init(argc, argv, "Robot_Silver");
Robot silver(100);
silver.run();
return 0;
}
#ifndef ROBOT_H
#define ROBOT_H
class Robot
{
public:
Robot(int hp);
virtual ~Robot();
void run();
bool moves(dotbot_msgs::Getmoves::Request &req, dotbot_msgs::Getmoves::Response &res);
protected:
private:
ros::NodeHandle _nh;
ros::Publisher _pub;
ros::Publisher _colpo_pub;
ros::Subscriber _sub;
int _hp;
};
#endif // ROBOT_H
#include "Robot.hpp"
Robot::Robot(int hp){
_hp=hp;
std_msgs::UInt8 hp_msg;
hp_msg.data = _hp;
this -> _pub = this -> _nh.advertise<std_msgs::UInt8>("hp", 1000);
this -> _pub.publish(hp_msg);
ros::spinOnce();
ros::ServiceServer service = _nh.advertiseService("services/get_moves", Robot::moves);
ros::spin();
}
Robot::~Robot(){
//dtor
}
bool Robot::moves(dotbot_msgs::Getmoves::Request &req, dotbot_msgs::Getmoves::Response &res){
res.move1 = "mossa1"
res.move2 = "mossa2"
res.move3 = "mossa3"
res.move4 = "mossa4"
std::cout << "setting moves" << std::endl;
return true;
}
#ifndef MOVE_H
#define MOVE_H
class Move
{
public:
Move();
virtual ~Move();
}
protected:
private:
};
#endif // MOVE_H