@@ -453,7 +453,11 @@ def lspbfunc(t):
453
453
if isscalar (t ):
454
454
t = [t ]
455
455
for tk in t :
456
- if tk <= tb :
456
+ if tk < 0 :
457
+ pk = q0
458
+ pdk = 0
459
+ pddk = 0
460
+ elif tk <= tb :
457
461
# initial blend
458
462
pk = q0 + a / 2 * tk ** 2
459
463
pdk = a * tk
@@ -463,11 +467,15 @@ def lspbfunc(t):
463
467
pk = (qf + q0 - V * tf ) / 2 + V * tk
464
468
pdk = V
465
469
pddk = 0
466
- else :
470
+ elif tk <= tf :
467
471
# final blend
468
472
pk = qf - a / 2 * tf ** 2 + a * tf * tk - a / 2 * tk ** 2
469
473
pdk = a * tf - a * tk
470
474
pddk = - a
475
+ else :
476
+ pk = qf
477
+ pdk = 0
478
+ pddk = 0
471
479
p .append (pk )
472
480
pd .append (pdk )
473
481
pdd .append (pddk )
@@ -638,107 +646,6 @@ def mtraj(tfunc, q0, qf, t):
638
646
return Trajectory ("mtraj" , x , y , yd , ydd , istime )
639
647
640
648
641
- def qplot (
642
- x ,
643
- y = None ,
644
- wrist = False ,
645
- unwrap = False ,
646
- block = False ,
647
- labels = None ,
648
- loc = None ,
649
- grid = True ,
650
- stack = False ,
651
- ** kwargs ,
652
- ):
653
- """
654
- Plot trajectory data
655
-
656
- :param q: trajectory, one row per timestep
657
- :type q: ndarray(m,n)
658
- :param t: time vector, optional
659
- :type t: numpy ndarray, shape=(M,)
660
- :param wrist: distinguish arm and wrist joints with line styles
661
- :type wrist: bool
662
- :param unwrap: unwrap joint angles so that they smoothly increase or
663
- decrease when they pass through :math:`\pm \pi`
664
- :type unwrap: bool
665
- :param block: block until the plot is closed
666
- :type block: bool
667
- :param labels: legend labels
668
- :type labels: list of str, or single string with space separated labels
669
- :param kwargs: options passed to pyplot.plot
670
- :param loc: legend location as per pyplot.legend
671
- :type loc: str
672
-
673
- This is a convenience function to plot trajectories, where each row represents one time step.
674
-
675
- - ``qplot(q)`` plots the joint angles versus row number. If N==6 a
676
- conventional 6-axis robot is assumed, and the first three joints are
677
- shown as solid lines, the last three joints (wrist) are shown as dashed
678
- lines. A legend is also displayed.
679
-
680
- - ``qplot(t, q)`` as above but displays the joint angle trajectory versus
681
- time given the time vector T (Mx1).
682
-
683
- Example::
684
-
685
- >>> qplot(q, x, labels='x y z')
686
-
687
- :seealso: :func:`jtraj`, :func:`numpy.unwrap`
688
- """
689
- if y is None :
690
- q = x
691
- t = np .arange (0 , q .shape [0 ])
692
- else :
693
- t = x
694
- q = y
695
-
696
- if t .ndim != 1 or q .shape [0 ] != t .shape [0 ]:
697
- raise ValueError ("dimensions of arguments are not consistent" )
698
-
699
- if unwrap :
700
- q = np .unwrap (q , axis = 0 )
701
-
702
- n = q .shape [1 ]
703
-
704
- if labels is None :
705
- labels = [f"q{ i } " for i in range (n )]
706
- elif isinstance (labels , str ):
707
- labels = labels .split (" " )
708
- elif not isinstance (labels , (tuple , list )):
709
- raise TypeError ("wrong type for labels" )
710
-
711
- fig , ax = plt .subplots ()
712
-
713
- if stack :
714
- for i in range (n ):
715
- ax = plt .subplot (n , 1 , i + 1 )
716
-
717
- plt .plot (t , q [:, i ], ** kwargs )
718
-
719
- plt .grid (grid )
720
- ax .set_ylabel (labels [i ])
721
- ax .set_xlim (t [0 ], t [- 1 ])
722
-
723
- ax .set_xlabel ("Time (s)" )
724
-
725
- else :
726
- if n == 6 and wrist :
727
- plt .plot (t , q [:, 0 :3 ], ** kwargs )
728
- plt .plot (t , q [:, 3 :6 ], "--" , ** kwargs )
729
- else :
730
- plt .plot (t , q , ** kwargs )
731
-
732
- ax .legend (labels , loc = loc )
733
-
734
- plt .grid (grid )
735
- ax .set_xlabel ("Time (s)" )
736
- ax .set_ylabel ("Joint coordinates (rad,m)" )
737
- ax .set_xlim (t [0 ], t [- 1 ])
738
-
739
- plt .show (block = block )
740
-
741
- return fig .get_axes ()
742
649
743
650
744
651
# -------------------------------------------------------------------------- #
0 commit comments