本文整理汇总了C++中PIDController::setTime方法的典型用法代码示例。如果您正苦于以下问题:C++ PIDController::setTime方法的具体用法?C++ PIDController::setTime怎么用?C++ PIDController::setTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PIDController
的用法示例。
在下文中一共展示了PIDController::setTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
ros::init(argc,argv,"mk_behaviors");
ros::NodeHandle nh;
ros::Subscriber vispose_sub = nh.subscribe<mk_msgs::ARMarker>("/mikrokopter/vision/ar_pose_marker", 1000, &getVisualPos);
ros::Subscriber sensororient = nh.subscribe<mk_msgs::sensorData>("/mikrokopter/sensor/data",1000,&getSensorOrient);
ros::Subscriber ugvposition = nh.subscribe<geometry_msgs::Point>("/mikrokopter/desired",1000,&getUGVPose);
ros::Publisher motorcomout = nh.advertise<mk_msgs::motorCommands>("/mikrokopter/commands/motor", 5);
double desiredZ = atof(argv[3]);
vispose.position.x = 0;
vispose.position.y = 0;
vispose.position.z = 0;
vispose.orientation.x = 1;
vispose.orientation.y = 0;
vispose.orientation.z = 0;
vispose.orientation.w = 0;
PIDController pidcontroller;
pidcontroller.setDesiredRPY(-1.57);
pidcontroller.setPIDParameters(atof(argv[4]),atof(argv[5]),atof(argv[6]));
pidcontroller.setForces(2.2, atof(argv[7]), atof(argv[8]));
while(ros::ok()){
pidcontroller.setCurrentPosition(vispose.position.x,
vispose.position.y,
vispose.position.z,
roll,
pitch,
tf::getYaw(vispose.orientation));
pidcontroller.setTime(ros::Time::now().toNSec());
double DesiredPosModRadius = 4;
double DesiredPosModFreq = 0.1;
double DesiredPosModStartTime = 0;
desiredX += 0.1; -DesiredPosModRadius*cos(2*M_PI*DesiredPosModFreq*(DesiredPosModStartTime - ros::Time::now().toSec())) + DesiredPosModRadius;
desiredY = 1;-DesiredPosModRadius*sin(2*M_PI*DesiredPosModFreq*(DesiredPosModStartTime - ros::Time::now().toSec()));
desiredZ = - 10;
pidcontroller.setDesiredPosition(desiredX, desiredY, desiredZ);
motorcomout.publish(pidcontroller.pid());
ros::Duration(0.05).sleep();
ros::spinOnce();
}
return 0;
}