Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stop start sync mode #361

Merged
merged 2 commits into from
Oct 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions rtc/AutoBalancer/AutoBalancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,17 @@ RTC::ReturnCode_t AutoBalancer::onActivated(RTC::UniqueId ec_id)
return RTC::RTC_OK;
}

/*
RTC::ReturnCode_t AutoBalancer::onDeactivated(RTC::UniqueId ec_id)
{
return RTC::RTC_OK;
RTC::ReturnCode_t AutoBalancer::onDeactivated(RTC::UniqueId ec_id)
{
std::cout << "AutoBalancer::onDeactivated(" << ec_id << ")" << std::endl;
Guard guard(m_mutex);
if (control_mode == MODE_ABC) {
stopABCparam();
control_mode = MODE_IDLE;
transition_count = 1; // sync in one controller loop
}
*/
return RTC::RTC_OK;
}

#define DEBUGP ((m_debugLevel==1 && loop%200==0) || m_debugLevel > 1 )
//#define DEBUGP2 ((loop%200==0))
Expand Down
2 changes: 1 addition & 1 deletion rtc/AutoBalancer/AutoBalancer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AutoBalancer

// The deactivated action (Active state exit action)
// former rtc_active_exit()
// virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);

// The execution action that is invoked periodically
// former rtc_active_do()
Expand Down
14 changes: 9 additions & 5 deletions rtc/ImpedanceController/ImpedanceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,16 @@ RTC::ReturnCode_t ImpedanceController::onActivated(RTC::UniqueId ec_id)
return RTC::RTC_OK;
}

/*
RTC::ReturnCode_t ImpedanceController::onDeactivated(RTC::UniqueId ec_id)
{
return RTC::RTC_OK;
RTC::ReturnCode_t ImpedanceController::onDeactivated(RTC::UniqueId ec_id)
{
std::cout << "ImpedanceController::onDeactivated(" << ec_id << ")" << std::endl;
Guard guard(m_mutex);
for ( std::map<std::string, ImpedanceParam>::iterator it = m_impedance_param.begin(); it != m_impedance_param.end(); it++ ) {
deleteImpedanceController(it->first);
m_impedance_param[it->first].transition_count = 1;
}
*/
return RTC::RTC_OK;
}

#define DEBUGP ((m_debugLevel==1 && loop%200==0) || m_debugLevel > 1 )
RTC::ReturnCode_t ImpedanceController::onExecute(RTC::UniqueId ec_id)
Expand Down
2 changes: 1 addition & 1 deletion rtc/ImpedanceController/ImpedanceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ImpedanceController

// The deactivated action (Active state exit action)
// former rtc_active_exit()
// virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);

// The execution action that is invoked periodically
// former rtc_active_do()
Expand Down
7 changes: 7 additions & 0 deletions rtc/Stabilizer/Stabilizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ RTC::ReturnCode_t Stabilizer::onActivated(RTC::UniqueId ec_id)
RTC::ReturnCode_t Stabilizer::onDeactivated(RTC::UniqueId ec_id)
{
std::cout << m_profile.instance_name<< ": onDeactivated(" << ec_id << ")" << std::endl;
if ( (control_mode == MODE_ST || control_mode == MODE_AIR) ) {
sync_2_idle ();
control_mode = MODE_IDLE;
transition_count = 1; // sync in one controller loop
}
return RTC::RTC_OK;
}

Expand Down Expand Up @@ -1275,6 +1280,7 @@ RTC::ReturnCode_t Stabilizer::onRateChanged(RTC::UniqueId ec_id)

void Stabilizer::sync_2_st ()
{
std::cerr << "Sync IDLE => ST" << std::endl;
pangx_ref = pangy_ref = pangx = pangy = 0;
rdx = rdy = rx = ry = 0;
d_rpy[0] = d_rpy[1] = 0;
Expand All @@ -1292,6 +1298,7 @@ void Stabilizer::sync_2_st ()

void Stabilizer::sync_2_idle ()
{
std::cerr << "Sync ST => IDLE" << std::endl;
transition_count = MAX_TRANSITION_COUNT;
for (int i = 0; i < m_robot->numJoints(); i++ ) {
transition_joint_q[i] = m_robot->joint(i)->q;
Expand Down