
Python
gophae
这个作者很懒,什么都没留下…
展开
-
Python-cvxopt库的使用(2)(解决QP问题)
对于python cvxopt 库,这个库用于求解线性和二次规划。本节介绍如何求解线性规划问题。形如以下的问题:我们将其写成标准形式:注意,约束条件需要化为:对应写出P,q,G,h,A,b矩阵。P=2 * matrix([[2., 0.5],[0.5,1.]])q=matrix([1.,1.])G=matrix([[-1.,0.],[0.,-1.]])h=matrix([0....原创 2020-03-17 15:02:06 · 3642 阅读 · 3 评论 -
Python-cvxopt库的使用(1)(解决LP问题)
对于python cvxopt 库,这个库用于求解线性和二次规划。本节介绍如何求解线性规划问题。形如以下的问题:我们将其写成标准形式:min cxs.t. Ax < b对应写出A,b,c矩阵。A = matrix([ [-1.0, -1.0, 0.0, 1.0], [1.0, -1.0, -1.0, -2.0] ])b = matrix([ 1.0, -2.0, 0.0, 4...原创 2020-03-17 14:13:46 · 2084 阅读 · 2 评论 -
Python实现共轭梯度法
import numpy as npdef CG(A,b): n = b.shape[0] xs = [] rs = [] ps = [] alphas = [] x0 = np.array([2,1]) # x0 = np.random.rand(n) xs.append(x0) r0 = b - np.dot(A,x0...原创 2020-03-16 22:21:19 · 3872 阅读 · 0 评论 -
Python中的random库
random.seed(10) #生成随机种子,如果设定种子,则第一个随机数固定为0.57print(random.random()) #随机生成任意0-1的随机数print(random.randint(10,100))#生成a-b之间的随机整数print(random.randrange(10,100,15))#生成a-b之间,以c为步长的数字print(random.getrandb...原创 2020-03-14 09:37:39 · 431 阅读 · 0 评论 -
LQR轨迹跟踪算法Python算法实现3
根据LQR轨迹跟踪算法Python/Matlab算法实现2的代码,我们转化成Python,后续上车使用。代码仅开源到这,可以进行仿真,函数都可以直接使用。工程代码就不开源了。from numpy import *from math import *import matplotlib.pyplot as pltimport scipy.linalg as laimport timeKp ...原创 2020-02-21 17:05:48 · 5418 阅读 · 2 评论 -
Python的类示例
#!/usr/bin/python3class MyClass: """一个简单的类实例""" def __init__(self,i): self.input = i def f(self): return 'hello world'# 实例化类x = MyClass(123)# 访问类的属性和方法print("MyCl...原创 2020-02-10 14:00:17 · 390 阅读 · 0 评论 -
曲率多项式转换为直角坐标系
对于形如 k(s) = a + bs + cs2+ds3的曲率多项式,我们将它转换为直角坐标系表示的多项式。推导如图:在每一步delta_s上面进行积分就可以获得直角坐标系下的曲线。举个例子,我们已经获得了关于s的曲率表达式,如图:在横轴上对s进行微分,并对每一步在直角坐标系下做积分即可获得直角坐标系下的曲线关于s的表达式:如图测试使用的代码如下:clcclear all...原创 2020-01-09 15:26:26 · 1241 阅读 · 1 评论 -
Python中的全局变量与局部变量2
from route_design1217 import *from math import *import pandas as pdimport numpy as npimport matplotlib.pyplot as pltv_front = 0d = 12def frenet_to_global(current_x, current_y, heading, theta, ...原创 2020-01-09 12:14:31 · 218 阅读 · 0 评论 -
Python中的全局变量与局部变量
from math import *from numpy import *# 嵌套函数,fun2 中有 fun3def fun2(): num2 = 3 def fun3(): nonlocal num2 num2 *= 2 print("num2=", num2) return fun3()fun2()#...原创 2020-01-09 00:13:56 · 283 阅读 · 0 评论 -
NumPy for Matlab users¶
Numpy for Matlab user原创 2019-12-19 09:30:27 · 491 阅读 · 1 评论 -
LQR轨迹跟踪算法Python/Matlab算法实现
Python:"""Path tracking simulation with LQR steering control and PID speed control.author Atsushi Sakai (@Atsushi_twi)"""import syssys.path.append("H:\Project\TrajectoryPlanningModelDesign\Codes...原创 2019-11-22 14:07:43 · 10366 阅读 · 6 评论 -
三次样条曲线拟合及Matlab/Python实现
对于形如y = a + bx + c * x^2 + d * x^3 的三次spline曲线拟合的数学原理,我就不多说了。我接了一个图给大家看看:数值计算的伪代码如下:书名是:numerical_methods_for_engineers_for_engineers_chapra_canale_6th_editionspline interpolation 在18.6章,想了解如...原创 2019-10-29 20:45:05 · 14108 阅读 · 9 评论 -
Stanley轨迹跟踪算法Python/Matlab算法实现
本文针对Python/Matlab实现Stanley进行介绍:Stanley 的数学几何原理来自:https://blog.youkuaiyun.com/gophae/article/details/100012763Python代码来自:https://github.com/gameinskysky/PythonRobotics/blob/master/PathTracking/stanley_co...原创 2019-10-27 11:40:07 · 9584 阅读 · 5 评论 -
Pure Pursuit纯跟踪算法Python/Matlab算法实现
本文的python源代码来自:https://github.com/gameinskysky/PythonRobotics/blob/master/PathTracking/pure_pursuit/pure_pursuit.py我们对纯跟踪算法进行一次仿真,python 我已经改过,如下:import numpy as npimport mathimport matplotlib.py...原创 2019-10-26 21:05:57 · 11585 阅读 · 22 评论