Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
grotius-cnc committed Dec 22, 2021
1 parent cf524a2 commit 752e2f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
14 changes: 9 additions & 5 deletions gui_project/mainwindow.cpp
Expand Up @@ -71,7 +71,9 @@ void MainWindow::on_pushButton_create_motion_block_pressed(){
r+=motion_block(vs, am, vo, acs, ltot, ve, ace, t,sr,vr,ar,ct);
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
std::cout << "Time taken by function nanoseconds: " << duration.count() << " milliseconds" << duration.count()*0.000001 <<std::endl;
std::cout << "Time taken by function nanoseconds: " << duration.count() << " milliseconds:" << duration.count()*0.000001 <<std::endl;

std::cout<<std::fixed<<"at_time:"<<t<<" sr:"<<sr<<" vr:"<<vr<<" ar:"<<ar<<" ct:"<<ct<<std::endl;

//! The avarage function time = 1500 us.
//! ns*0.000001=ms 0.0015 ms. This is ok for 1ms servo thread.
Expand Down Expand Up @@ -206,19 +208,19 @@ int MainWindow::motion_block(double vs, double am, double vo, double acs, double

void MainWindow::on_pushButton_show_lin_curve_pressed()
{
std::cout.precision(3);
double vs=ui->doubleSpinBox_lin_velocity->value();
double s=ui->doubleSpinBox_lin_displacment->value();

double at_time=0;
double ct=0;
double sr=0;
double vr=0;
double ar=0;
int r=0;

r+=scurve_lineair(at_time,vs,s,ct,sr);
if(!r){
std::cout<<"Curve time[ct]:"<<ct<<std::endl;
std::cout<<"Dispalcement[st] at [at_time]:"<<sr<<std::endl;

//! Draw the full traject.
Handle(AIS_Shape) aLine;
aLine=draw_primitives().draw_3d_line({0,vs,0},{ct,vs,0});
Expand All @@ -227,7 +229,9 @@ void MainWindow::on_pushButton_show_lin_curve_pressed()

for(double i=0; i<ct; i+=0.1){
r+=scurve_lineair(i,vs,s,sr,ct);
std::cout<<"Dispalcement[st]:"<<sr<<" at_time[i]"<<i<<std::endl;
ar=0; //! Zero acceleration during steady stage.
vr=vs; //! Velocity = Max velocity.
std::cout<<std::fixed<<"at_time:"<<i<<" sr:"<<sr<<" vr:"<<vr<<" ar:"<<ar<<" ct:"<<ct<<std::endl;
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions scurve.cpp
Expand Up @@ -89,6 +89,9 @@ void Scurve::example_scurve(){
if(ct<0){
std::cout<<"curve time<0"<<std::endl;
}
if(!r){
std::cout<<"at_time:"<<at_time<<" sr:"<<sr<<" vr:"<<vr<<" ar:"<<ar<<" ct:"<<ct<<" cs:"<<cs<<std::endl;
}
}

//! Inputs:
Expand All @@ -105,6 +108,7 @@ void Scurve::example_scurve(){
//! vr=current velocity.
//! ar=current acceleration.
//! ct=total curve time.
//! cs=total curve displacment.
int Scurve::scurve_acc_dcc(int sct, double vo, double ve, double am, double acs, double ace, double at_time, double &sr, double &vr, double &ar, double &ct, double &cs){

std::cout.precision(3);
Expand Down Expand Up @@ -312,14 +316,11 @@ void Scurve::example_motion(){
auto start = std::chrono::high_resolution_clock::now();
r+=motion_block(vs, am, vo, acs, ltot, ve, ace, t,sr,vr,ar,ct);
if(!r){
std::cout<<std::fixed<<"sr:"<<sr<<std::endl;
std::cout<<std::fixed<<"vr:"<<vr<<std::endl;
std::cout<<std::fixed<<"ar:"<<ar<<std::endl;
std::cout<<std::fixed<<"ct:"<<ct<<std::endl;
std::cout<<"at_time:"<<at_time<<" sr:"<<sr<<" vr:"<<vr<<" ar:"<<ar<<" ct:"<<ct<<std::endl;
}
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
std::cout << "Time taken by function nanoseconds: " << duration.count() << " milliseconds" << duration.count()*0.000001 <<std::endl;
std::cout << "Time taken by function nanoseconds: " << duration.count() << " milliseconds:" << duration.count()*0.000001 <<std::endl;

//! The avarage function time = 1500 us.
//! ns*0.000001=ms 0.0015 ms. This is ok for 1ms servo thread.
Expand Down
6 changes: 2 additions & 4 deletions scurve.h
Expand Up @@ -35,10 +35,8 @@ class SCURVE_EXPORT Scurve
//! at_time=request curve at [t]
//! vr=current_velocity at [t]
//! ar=current acceleration at [t]
//!
//! ct=netto curve time [t] excluding acc start time, acc end time.
//! cs=netto curve displacement.
//!
//! ct=total curve time [t] excluding acc start time, acc end time.
//! cs=total curve displacement.
int scurve_acc_dcc(int sct, double vo, double ve, double am, double acs, double ace, double at_time, double &sr, double &vr, double &ar, double &ct, double &cs);
void example_scurve();

Expand Down

0 comments on commit 752e2f9

Please sign in to comment.