Using the True License ObfuscatedString class

本文介绍了一种用于Java许可文件的字符串混淆方法,通过该方法可以提高软件许可证的安全性,防止未授权使用。具体实现细节可参考提供的外部链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一种字符串混淆的方法,可以借鉴

http://alvinalexander.com/java/true-license-obfuscatedstring-class-java-obfuscate


#!/usr/bin/env python # Copyright (c) 2016 The UUV Simulator Authors. # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Import the ROS Python library from __future__ import print_function import rospy # Import the NumPy package for numerical computations import numpy as np # Import the dynamic positioning controller base class to inherit methods such as error computation update, # publishing from some important ROS topics (e.g. trajectory, pose and velocity reference) and access to # the vehicle model class, that is necessary to explicitly use the vehicle model from uuv_control_interfaces import DPControllerBase class TutorialDPController(DPControllerBase): # A new controller that is based on the DPControllerBase must at least provide the implementation of # the method update_controller. # The _reset_controller method can also be overridden and it will be called every time there is a service call # <vehicle namespace>/reset_controller. The default implementation sets the reference and error vectors to # zero. # The update_controller method must contain the implementation of the control algorithm and will be called # by every update of the vehicle's odometry message. It is therefore not necessary to explicitly call this update # function in this controller implementation. # For the controller to send the control torques to the vehicle's thruster manager, at the end of the # update_controller function the 6 x 1 control vector (type numpy.ndarray) sent using the function # publish_control_wrench from the super class, which will generate a Wrench ROS message and publish it to the # correspondent thruster manager node. # For this tutorial, a simple PID controller will be implemented. The controller's control torque output is # "tau" therefore computed as: # # tau = Kp * e + Kd * de/dt + Ki int_e # # where e is the pose error vector, in this case defined as e = (x, y, z, roll, pitch, yaw)^T def __init__(self): # Calling the constructor of the super-class DPControllerBase, which has the implementation of the error # computation update and to publish the resulting torque control vector. super(TutorialDPController, self).__init__(self) # The controller should read its parameters from the ROS parameter server for initial setup # One way to do this is to read the parameters from the node's private parameter namespace, which is done by # reading the parameter tag with an "~" at the beginning. If this method is used, the parameters should be # initialized accordingly in the controller startup launch file, such as # # <launch> # <node pkg="example_package" type="example_node.py" name="example_node" output="screen"> # <rosparam> # param_1: 0.0 # param_2: 0.0 # </rosparam> # </node> # </launch> # # For more information, see http://wiki.ros.org/roscpp_tutorials/Tutorials/AccessingPrivateNamesWithNodeHandle # Let's initialize the controller gain matrices Kp, Kd and Ki self._Kp = np.zeros(shape=(6, 6)) self._Kd = np.zeros(shape=(6, 6)) self._Ki = np.zeros(shape=(6, 6)) # Initialize the integrator component self._int = np.zeros(shape=(6,)) # Initialize variable that will store the vehicle pose error self._error_pose = np.zeros(shape=(6,)) # Now the gain matrices need to be set according to the variables stored in the parameter server # For simplicity, the gain matrices are defined as diagonal matrices, so only 6 coefficients are # needed if rospy.get_param('~Kp'): Kp_diag = rospy.get_param('~Kp') if len(Kp_diag) == 6: self._Kp = np.diag(Kp_diag) else: # If the vector provided has the wrong dimension, raise an exception raise rospy.ROSException('For the Kp diagonal matrix, 6 coefficients are needed') # Do the same for the other two matrices if rospy.get_param('~Kd'): diag = rospy.get_param('~Kd') if len(diag) == 6: self._Kd = np.diag(diag) print('Kd=\n', self._Kd) else: # If the vector provided has the wrong dimension, raise an exception raise rospy.ROSException('For the Kd diagonal matrix, 6 coefficients are needed') if rospy.get_param('~Ki'): diag = rospy.get_param('~Ki') if len(diag) == 6: self._Ki = np.diag(diag) print('Ki=\n', self._Ki) else: # If the vector provided has the wrong dimension, raise an exception raise rospy.ROSException('For the Ki diagonal matrix, 6 coefficients are needed') self._is_init = True def _reset_controller(self): # The _reset_controller method from the super class DPControllerBase already sets the error # and reference vectors to zero, but this class has additional attributes that should also # be taken care of. # This implementation will, therefore, first call the super class reset method super(TutorialDPController, self)._reset_controller() # And then proceed to set the internal variables back to zero self._error_pose = np.zeros(shape=(6,)) self._int = np.zeros(shape=(6,)) def update_controller(self): if not self._is_init: return False # The controller algorithm must be implemented here, the super class will connect this method # to the odometry update as a callback function # First test whether or not the odometry topic subscriber has already been initialized if not self.odom_is_init: return # Update the integrator, read the super class vector for the pose error (orientation is represented # with Euler angles in RPY convention) and integrate to the stored pose error from the last # iteration self._int = self._int + 0.5 * (self.error_pose_euler + self._error_pose) * self._dt # Store the current pose error for the next iteration self._error_pose = self.error_pose_euler # Compute the control forces and torques using the current error vectors available tau = np.dot(self._Kp, self.error_pose_euler) + np.dot(self._Kd, self._errors['vel']) + \ np.dot(self._Ki, self._int) # Use the super class method to convert the control force vector into a ROS message # and publish it as an input to the vehicle's thruster manager. The thruster manager module # will then distribute the efforts amongst the thrusters using the thruster allocation matrix self.publish_control_wrench(tau) if __name__ == '__main__': # Since this is an ROS node, this Python script has to be treated as an executable # Remember to convert this Python file into an executable. This can be done with # # cd <path_to_ros_package>/scripts # chmod 777 tutorial_dp_controller.py # # This file has also to be included in this package's CMakeLists.txt # After the line catkin_package() in the CMakeLists.txt, include the following # # catkin_install_python(PROGRAMS scripts/tutorial_dp_controller.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) print('Tutorial - DP Controller') rospy.init_node('tutorial_dp_controller') try: node = TutorialDPController() rospy.spin() except rospy.ROSInterruptException: print('caught exception') print('exiting')学习这个代码,编写一个lqr控制器
05-14
/* Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 Copyright (c) 2009 Michael Margolis. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method. The servos are pulsed in the background using the value most recently written using the write() method. Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached. Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four. The sequence used to sieze timers is defined in timers.h The methods are: Servo - Class for manipulating servo motors connected to Arduino pins. attach(pin ) - Attaches a servo motor to an i/o pin. attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds default min is 544, max is 2400 write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) writeMicroseconds() - Sets the servo pulse width in microseconds read() - Gets the last written servo pulse width as an angle between 0 and 180. readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) attached() - Returns true if there is a servo attached. detach() - Stops an attached servos from pulsing its i/o pin. */ #ifndef Servo_h #define Servo_h #include <inttypes.h> /* * Defines for 16 bit timers used with Servo library * * If _useTimerX is defined then TimerX is a 16 bit timer on the current board * timer16_Sequence_t enumerates the sequence that the timers should be allocated * _Nbr_16timers indicates how many 16 bit timers are available. */ // Architecture specific include #if defined(ARDUINO_ARCH_AVR) #include "avr/ServoTimers.h" #elif defined(ARDUINO_ARCH_SAM) #include "sam/ServoTimers.h" #elif defined(ARDUINO_ARCH_SAMD) #include "samd/ServoTimers.h" #elif defined(ARDUINO_ARCH_STM32F4) #include "stm32f4/ServoTimers.h" #elif defined(ARDUINO_ARCH_NRF52) #include "nrf52/ServoTimers.h" #else #error "This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor." #endif #define Servo_VERSION 2 // software version of this library #define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo #define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached #define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds #define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer #define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) #define INVALID_SERVO 255 // flag indicating an invalid servo index #if !defined(ARDUINO_ARCH_STM32F4) typedef struct { uint8_t nbr :6 ; // a pin number from 0 to 63 uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false } ServoPin_t ; typedef struct { ServoPin_t Pin; volatile unsigned int ticks; } servo_t; class Servo { public: Servo(); uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes. void detach(); void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds void writeMicroseconds(int value); // Write pulse width in microseconds int read(); // returns current pulse width as an angle between 0 and 180 degrees int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) bool attached(); // return true if this servo is attached, otherwise false private: uint8_t servoIndex; // index into the channel data for this servo int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH }; #endif #endif Servo.h文件中是这样的该怎么修改
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值