void check_accelerations(const double amin_[N_MOTORS], const double amax_[N_MOTORS], const Eigen::Matrix <double, N_SEGMENTS, N_MOTORS> & m3w_, const Eigen::Matrix <double, N_SEGMENTS, N_MOTORS> & m2w_, const Eigen::Matrix < double, N_SEGMENTS, 1> taus_) { #if 0 cout << "amin:\n"; for (int mtr = 0; mtr < N_MOTORS; ++mtr) { cout << amin_[mtr] << " "; } cout << endl; cout << "amax:\n"; for (int mtr = 0; mtr < N_MOTORS; ++mtr) { cout << amax_[mtr] << " "; } cout << endl; #endif // Compute acceleration values at segment beginning. Eigen::Matrix <double, N_SEGMENTS, N_MOTORS> a_start = 2.0 * m2w_; #if 0 cout << "a_start:\n" << a_start << endl; #endif // Compute acceleration values at the segment end. Eigen::Matrix <double, N_SEGMENTS, N_MOTORS> a_final; for (int mtr = 0; mtr < N_MOTORS; ++mtr) { a_final.col(mtr) = 6.0 * (m3w_.col(mtr).cwise() * taus_) + 2.0 * m2w_.col(mtr); } #if 0 cout << "a_final:\n" << a_final << endl; #endif // Check conditions for all segments and motors. for (int sgt = 0; sgt < N_SEGMENTS; ++sgt) for (int mtr = 0; mtr < N_MOTORS; ++mtr) { if (a_start(sgt, mtr) > amax_[mtr]) BOOST_THROW_EXCEPTION(nfe_motor_acceleration_constraint_exceeded() << constraint_type(MAXIMUM_CONSTRAINT) << motor_number(mtr) << segment_number(sgt) << constraint_value(amax_[mtr]) << desired_value(a_start(sgt, mtr))); else if (a_final(sgt, mtr) > amax_[mtr]) BOOST_THROW_EXCEPTION(nfe_motor_acceleration_constraint_exceeded() << constraint_type(MAXIMUM_CONSTRAINT) << motor_number(mtr) << segment_number(sgt) << constraint_value(amax_[mtr]) << desired_value(a_final(sgt, mtr))); else if (a_start(sgt, mtr) < amin_[mtr]) BOOST_THROW_EXCEPTION(nfe_motor_acceleration_constraint_exceeded() << constraint_type(MINIMUM_CONSTRAINT) << motor_number(mtr) << segment_number(sgt) << constraint_value(amin_[mtr]) << desired_value(a_start(sgt, mtr))); else if (a_final(sgt, mtr) < amin_[mtr]) BOOST_THROW_EXCEPTION(nfe_motor_acceleration_constraint_exceeded() << constraint_type(MINIMUM_CONSTRAINT) << motor_number(mtr) << segment_number(sgt) << constraint_value(amin_[mtr]) << desired_value(a_final(sgt, mtr))); } }
void link_check::inspect( const string & library_name, const path & full_path, // example: c:/foo/boost/filesystem/path.hpp const string & contents ) // contents of file to be inspected { if (contents.find( "boostinspect:" "nounlinked" ) != string::npos) m_paths[ relative_to( full_path, search_root_path() ) ] |= m_nounlinked_errors; bool no_link_errors = (contents.find( "boostinspect:" "nolink" ) != string::npos); // build bookmarks databases bookmarks.clear(); bookmarks_lowercase.clear(); string::const_iterator a_start( contents.begin() ); string::const_iterator a_end( contents.end() ); boost::match_results< string::const_iterator > a_what; boost::match_flag_type a_flags = boost::match_default; if(!is_css(full_path)) { string previous_id; while( boost::regex_search( a_start, a_end, a_what, html_bookmark_regex, a_flags) ) { // a_what[0] contains the whole string iterators. // a_what[1] contains the tag iterators. // a_what[2] contains the attribute name. // a_what[4] contains the bookmark iterators. if (a_what[4].matched) { string tag( a_what[1].first, a_what[1].second ); boost::algorithm::to_lower(tag); string attribute( a_what[2].first, a_what[2].second ); boost::algorithm::to_lower(attribute); string bookmark( a_what[4].first, a_what[4].second ); bool name_following_id = ( attribute == "name" && previous_id == bookmark ); if ( tag != "meta" && attribute == "id" ) previous_id = bookmark; else previous_id.clear(); if ( tag != "meta" && !name_following_id ) { bookmarks.insert( bookmark ); // std::cout << "******************* " << bookmark << '\n'; // w3.org recommends case-insensitive checking for duplicate bookmarks // since some browsers do a case-insensitive match. string bookmark_lowercase( bookmark ); boost::algorithm::to_lower(bookmark_lowercase); std::pair<bookmark_set::iterator, bool> result = bookmarks_lowercase.insert( bookmark_lowercase ); if (!result.second) { ++m_duplicate_bookmark_errors; int ln = std::count( contents.begin(), a_what[3].first, '\n' ) + 1; error( library_name, full_path, "Duplicate bookmark: " + bookmark, ln ); } } } a_start = a_what[0].second; // update search position a_flags |= boost::match_prev_avail; // update flags a_flags |= boost::match_not_bob; } } // process urls string::const_iterator start( contents.begin() ); string::const_iterator end( contents.end() ); boost::match_results< string::const_iterator > what; boost::match_flag_type flags = boost::match_default; if(!is_css(full_path)) { while( boost::regex_search( start, end, what, html_url_regex, flags) ) { // what[0] contains the whole string iterators. // what[1] contains the element type iterators. // what[3] contains the URL iterators. if(what[3].matched) { string type( what[1].first, what[1].second ); boost::algorithm::to_lower(type); // TODO: Complain if 'link' tags use external stylesheets. do_url( string( what[3].first, what[3].second ), library_name, full_path, no_link_errors, type == "a" || type == "link", contents.begin(), what[3].first ); } start = what[0].second; // update search position flags |= boost::match_prev_avail; // update flags flags |= boost::match_not_bob; } } while( boost::regex_search( start, end, what, css_url_regex, flags) ) { // what[0] contains the whole string iterators. // what[2] contains the URL iterators. if(what[2].matched) { do_url( string( what[2].first, what[2].second ), library_name, full_path, no_link_errors, false, contents.begin(), what[3].first ); } start = what[0].second; // update search position flags |= boost::match_prev_avail; // update flags flags |= boost::match_not_bob; } }