本文整理汇总了C++中States::GetReward方法的典型用法代码示例。如果您正苦于以下问题:C++ States::GetReward方法的具体用法?C++ States::GetReward怎么用?C++ States::GetReward使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类States
的用法示例。
在下文中一共展示了States::GetReward方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timer_cb
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;
}
}
示例2: timer_cb
void Experiment::timer_cb(const ros::TimerEvent& event)
{
switch(mode_)
{
case MODE_REP_START:
state_ = (int)states_->GetState();
ROS_INFO("Starting rep: %d", cnt_rep_);
mode_ = MODE_REP;
break;
case MODE_REP:
action_ = qobj_->GetAction(state_);
actions_->Move((Actions::moveType)action_);
state_p_ = (int)states_->GetState();
ROS_INFO("Action: %d, produced state: %d", action_, state_p_);
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_;
if (states_->GetDistance() < radius_)
{
mode_ = MODE_RETURN;
ROS_INFO("Completed rep: %d, returning to start location", cnt_rep_);
// Move to starting spot
srv_.request.pose.position.x = start_x_;
srv_.request.pose.position.y = start_y_;
client_.call(srv_);
}
break;
case MODE_RETURN:
if (move_stopped_ == true)
{
move_stopped_ = false;
mode_ = MODE_REP_START;
cnt_rep_++;
}
if (cnt_rep_ > num_reps_)
mode_ = MODE_DONE;
break;
case MODE_DONE:
break;
}
}