void Experiment::timer_cb(const ros::TimerEvent& event) { switch(mode_) { case MODE_REP_START: actions_->Start(); last_time_ = ros::Time::now().toSec(); state_ = states_->GetState(); action_ = qobj_->GetAction(state_); actions_->Move(action_); ROS_INFO("Starting rep: %d", cnt_rep_); mode_ = MODE_REP; cnt_timesteps_++; break; case MODE_REP: state_p_ = (int)states_->GetState(); if (learn_) { reward_ = states_->GetReward(); qobj_->Update(reward_, state_, state_p_, action_); ROS_INFO("Action: %d, produced state: %d with reward: %f", action_, state_p_, reward_); ROS_INFO("Table: \n%s", qobj_->PrintTable().c_str()); } state_ = state_p_; action_ = qobj_->GetAction(state_); actions_->Move(action_); cnt_timesteps_++; if (getDistance() < goal_radius_ || outOfBounds()) { stopAndMoveToStart(); } break; case MODE_RETURN: if (move_stopped_ == true) { move_stopped_ = false; mode_ = MODE_REP_START; qobj_->DecreaseTemp(); cnt_rep_++; } if (cnt_rep_ > num_reps_) mode_ = MODE_DONE; break; case MODE_DONE: //lc_->ShowImage(); exit(1); break; } }