Added sensors to the robot. Correct exit on sigint.
This commit is contained in:
19
robot.cpp
19
robot.cpp
@@ -2,11 +2,16 @@
|
||||
|
||||
Robot::Robot(std::string hostname, uint32_t port) {
|
||||
_p_client = new PlayerCc::PlayerClient(hostname, port);
|
||||
_p_proxy = new PlayerCc::Position2dProxy(_p_client, 0);
|
||||
_p_proxy = new PlayerCc::Position2dProxy(_p_client, 0);
|
||||
_r_proxy = new PlayerCc::RangerProxy(_p_client, 0);
|
||||
_p_proxy->RequestGeom();
|
||||
_r_proxy->RequestGeom();
|
||||
}
|
||||
|
||||
Robot::~Robot() {
|
||||
std::cout << "Destroying robot" << std::endl;
|
||||
delete _p_proxy;
|
||||
delete _r_proxy;
|
||||
delete _p_client;
|
||||
}
|
||||
|
||||
@@ -19,5 +24,15 @@ IASSS_Robot::~IASSS_Robot() {
|
||||
}
|
||||
|
||||
void IASSS_Robot::run() {
|
||||
sleep(10);
|
||||
_p_client->Read();
|
||||
|
||||
if(_r_proxy->GetRange(0) < 0.2) {
|
||||
_p_proxy->SetSpeed(0.0f, PlayerCc::dtor(-45));
|
||||
sleep(1);
|
||||
} else if(_r_proxy->GetRange(_r_proxy->GetRangeCount()) < 0.2) {
|
||||
_p_proxy->SetSpeed(0.0f, PlayerCc::dtor(45));
|
||||
sleep(1);
|
||||
} else {
|
||||
_p_proxy->SetSpeed(0.3f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user