int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::ISet<std::string> s = hz.getSet<std::string>("set"); hazelcast::client::adaptor::RawPointerSet<std::string> set(s); set.add("Tokyo"); set.add("Paris"); set.add("New York"); std::cout << "Finished loading set" << std::endl; std::auto_ptr<hazelcast::client::DataArray<std::string> > vals = set.toArray(); std::cout << "There are " << set.size() << " values in the set" << std::endl; for (size_t i = 0; i < vals->size(); ++i) { const std::string *val = (*vals)[i]; if (NULL == val) { std::cout << "Value " << i << " is NULL" << std::endl; } else { std::cout << "Value: " << *val << std::endl; } } bool exists = set.remove("Tokyo"); if (exists) { std::cout << "Removed Tokyo from set" << std::endl; } else { std::cout << "Could not remove Tokyo from set. It did not exist." << std::endl; } std::cout << "Finished" << std::endl; return 0; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::IMap<std::string, Person> map = hz.getMap<std::string, Person>("personsWithIndex"); map.addIndex("name", true); const int mapSize = 200000; char buf[30]; char name[30]; time_t start = time(NULL); for (int i = 0; i < mapSize; ++i) { hazelcast::util::snprintf(buf, 30, "person-%d", i); hazelcast::util::snprintf(name, 50, "myname-%d", i % 1000); Person p(name, (i % 2 == 0), (i % 100)); map.put(buf, p); } time_t end = time(NULL); std::cout << "Put " << mapSize << " entries into the map in " << end - start << " seconds" << std::endl; start = time(NULL); hazelcast::client::query::SqlPredicate predicate("name == 'myname-30'"); std::vector<std::pair<std::string, Person> > entries = map.entrySet(predicate); end = time(NULL); std::cout << "The query resulted in " << entries.size() << " entries in " << end - start << " seconds" << std::endl; std::cout << "Finished" << std::endl; return 0; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::IMap<std::string, Value> map = hz.getMap<std::string, Value>("map"); std::string key("1"); Value v; map.put(key, v); std::cout << "Starting" << std::endl; for (int k = 0; k < 1000; k++) { map.lock(key); try { map.get(key); hazelcast::util::sleepmillis(10); v.amount++; map.put(key, v); map.unlock(key); } catch (hazelcast::client::exception::IException &e) { map.unlock(key); throw; } } std::cout << "Finished! Result = " << map.get(key)->amount << std::endl; std::cout << "Finished" << std::endl; return 0; }
void SingleNeuronTests::test() { // assemble a tiny 2-cell network // verify that spike delays are arriving at the appropriate time. // also ensure that spike is disabled after using it! SpikingNet *net = new SpikingNet(); SpikingLayer* P_L = create_layer<SpikingNeuron>(net, "Pre",1); SpikingLayer* LGN_L = create_layer<HodgkinHuxley>(net,"Post",1); float w = 1.0; // huge weight -> this causes spiking in HH neuron synapse_vec synapses = p_2_lgn(P_L->n, LGN_L->n, EXC, w); assert(synapses.size() == 1); connect(net, P_L,LGN_L,synapses,false); stim_vec stims; stims.resize(2); fvec hz(1,40); // single neuron, 40 hz stimulus fvec noise(1,0); float T = 300; int nstart = int(50/dt); int nstop = int(250/dt); stims[0] = new FixedRateSpikeStim(hz,noise,nstart,nstop); stims[1] = new EmptyStim(1); RunSettings* rs = new RunSettings(T,dt,stims,true); // true = show progress neuralnets::SimulationResults results = run(net, rs, true); delete rs; delete net; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::IAtomicLong number1 = hz.getIAtomicLong("number1"); hazelcast::client::IAtomicLong number2 = hz.getIAtomicLong("number2"); std::cout << "Started" << std::endl; for (int k = 0; k < 1000000; k++) { if (k % 10000 == 0) { std::cout << "at:" << k << std::endl; } if (k % 2 == 0) { int64_t n1 = number1.get(); hazelcast::util::sleepmillis(100); int64_t n2 = number2.get(); if (n1 - n2 != 0) { std::cout << "Difference detected at" << k << " !" << std::endl; } } else { number1.incrementAndGet(); number2.incrementAndGet(); } } std::cout << "Finished" << std::endl; return 0; }
int set_interval(int is_virtual) { int usec = 1000000/hz(); int timer_type = is_virtual ? ITIMER_VIRTUAL : ITIMER_REAL; struct itimerval interval = ((struct itimerval) { { 0, usec }, { 0, usec } });
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::MultiMap<std::string, std::string> map = hz.getMultiMap<std::string, std::string>("map"); std::vector<std::string> keys = map.keySet(); for (std::vector<std::string>::const_iterator it = keys.begin(); it != keys.end(); ++it) { std::vector<std::string> values = map.get(*it); std::cout << *it << " -> ("; for (std::vector<std::string>::const_iterator valIt = values.begin(); valIt != values.end();) { std::cout << *valIt << std::endl; ++valIt; if (valIt != values.end()) { std::cout << ", "; } } std::cout << ")" << std::endl; } std::cout << "Finished" << std::endl; return 0; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::IQueue<std::string> map = hz.getDistributedObject<hazelcast::client::IQueue<std::string> >( "queue distributed object"); std::cout << "Finished" << std::endl; return 0; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::SerializationConfig serializationConfig; serializationConfig.registerSerializer(boost::shared_ptr<hazelcast::client::serialization::SerializerBase>(new CustomSerializer())); config.setSerializationConfig(serializationConfig); hazelcast::client::HazelcastClient hz(config); hazelcast::client::IMap<std::string, Person> map = hz.getMap<std::string, Person>("map"); Person testPerson("bar"); map.put("foo", testPerson); std::cout << *(map.get("foo")) << std::endl; std::cout << "Finished" << std::endl; return 0; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::IMap<std::string, Person> map = hz.getMap<std::string, Person>("map"); Person testPerson("foo"); map.put("foo", testPerson); std::cout << "Finished writing" << std::endl; std::cout << map.get("foo"); std::cout << "Finished reading" << std::endl; std::cout << "Finished" << std::endl; return 0; }
/** spin, triggering the device twice a second. */ bool spin(void) { bool retval = true; ros::Rate hz(2.0); while (node_.ok()) { ros::spinOnce(); if (!trigger()) { retval = false; break; } hz.sleep(); } shutdown(); return retval; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::IList<std::string> list = hz.getList<std::string>("list"); list.add("Tokyo"); list.add("Paris"); list.add("London"); list.add("New York"); std::cout << "Putting finished!" << std::endl; std::cout << "Finished" << std::endl; return 0; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::IList<std::string> list = hz.getList<std::string>("list"); std::vector<std::string> listValues = list.toArray(); for (std::vector<std::string>::const_iterator it = listValues.begin(); it != listValues.end(); ++it) { std::cout << *it << std::endl; } std::cout << "Reading finished!" << std::endl; std::cout << "Finished" << std::endl; return 0; }
void TestStelSphericalGeometry::testPlaneIntersect2() { Vec3d p1,p2; Vec3d vx(1,0,0); Vec3d vz(0,0,1); SphericalCap hx(vx, 0); SphericalCap hz(vz, 0); QVERIFY2(SphericalCap::intersectionPoints(hx, hz, p1, p2)==true, "Plane intersect failed"); QVERIFY(p1==Vec3d(0,-1,0)); QVERIFY(p2==Vec3d(0,1,0)); QVERIFY2(SphericalCap::intersectionPoints(hx, hx, p1, p2)==false, "Plane non-intersecting failure"); hx.d = std::sqrt(2.)/2.; QVERIFY2(SphericalCap::intersectionPoints(hx, hz, p1, p2)==true, "Plane/convex intersect failed"); Vec3d res(p1-Vec3d(hx.d,-hx.d,0)); QVERIFY2(res.length()<0.0000001, QString("p1 wrong: %1").arg(p1.toString()).toUtf8()); res = p2-Vec3d(hx.d,hx.d,0); QVERIFY2(res.length()<0.0000001, QString("p2 wrong: %1").arg(p2.toString()).toUtf8()); }
uint8_t ADMVideoMosaic::configure(AVDMGenericVideoStream * instream) { UNUSED_ARG(instream); #define PX(x) &(_param->x) diaElemUInteger hz(PX(hz),QT_TR_NOOP("_Horizontal stacking:"),0,10); diaElemUInteger vz(PX(vz),QT_TR_NOOP("_Vertical stacking:"),0,10); diaElemUInteger shrink(PX(shrink),QT_TR_NOOP("_Shrink factor:"),0,10); diaElemToggle show(PX(show),QT_TR_NOOP("Show _frame")); diaElem *elems[]={&hz,&vz,&shrink,&show}; if( diaFactoryRun(QT_TR_NOOP("Mosaic"),sizeof(elems)/sizeof(diaElem *),elems)) { reset(); return 1; } return 0; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::TransactionContext txCtxt = hz.newTransactionContext(); txCtxt.beginTransaction(); hazelcast::client::TransactionalMultiMap<std::string, std::string> transactionalMultiMap = txCtxt.getMultiMap<std::string, std::string>("txMultiMap"); hazelcast::client::adaptor::RawPointerTransactionalMultiMap<std::string, std::string> map(transactionalMultiMap); map.put("1", "Tokyo"); map.put("1", "Istanbul"); map.put("2", "Paris"); map.put("3", "New York"); txCtxt.commitTransaction(); std::cout << "Finished loading transactional multimap" << std::endl; return 0; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::IMap<int, Car> map = hz.getMap<int, Car>("cars"); map.put(1, Car("Audi Q7", 250, 22000)); map.put(2, Car("BMW X5", 312, 34000)); map.put(3, Car("Porsche Cayenne", 408, 57000)); // we're using a custom attribute called 'attribute' which is provided by the 'CarAttributeExtractor' // we are also passing an argument 'mileage' to the extractor hazelcast::client::query::SqlPredicate criteria("attribute[mileage] < 30000"); std::vector<Car> cars = map.values(criteria); for (std::vector<Car>::const_iterator it = cars.begin(); it != cars.end(); ++it) { std::cout << (*it) << std::endl; } std::cout << "Finished" << std::endl; return 0; }
int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::ISemaphore semaphore = hz.getISemaphore("semaphore"); hazelcast::client::IAtomicLong resource = hz.getIAtomicLong("resource"); for (int k = 0; k < 1000; k++) { std::cout << "At iteration: " << k << ", Active Threads: " << resource.get() << std::endl; semaphore.acquire(); try { resource.incrementAndGet(); hazelcast::util::sleep(1); resource.decrementAndGet(); } catch (hazelcast::client::exception::IException &e) { semaphore.release(); throw e; } } std::cout << "Finished" << std::endl; return 0; }
static void set_interval(int timer_type) { int usec = 1000000/hz(); struct itimerval interval = ((struct itimerval) { { 0, usec }, { 0, usec } });
int main(int argc, char** argv) { //Chi square distribution std::map<double, double> chi_map; ros::init(argc, argv, "tracker"); ros::NodeHandle nh("~"); // Subscribers/Publishers: ros::Subscriber input_sub = nh.subscribe("input", 5, detection_cb); marker_pub_tmp = nh.advertise<visualization_msgs::Marker>("/tracker/markers", 1); marker_pub = nh.advertise<visualization_msgs::MarkerArray>("/tracker/markers_array", 1); pointcloud_pub = nh.advertise<pcl::PointCloud<pcl::PointXYZRGBA> >("/tracker/history", 1); results_pub = nh.advertise<opt_msgs::TrackArray>("/tracker/tracks", 1); tf_listener = new tf::TransformListener(); // Read tracking parameters: nh.param("world_frame_id", world_frame_id, std::string("/odom")); nh.param("orientation/vertical", vertical, false); nh.param("extrinsic_calibration", extrinsic_calibration, false); double voxel_size; nh.param("voxel_size", voxel_size, 0.075); double rate; nh.param("rate", rate, 30.0); int num_cameras; nh.param("num_cameras", num_cameras, 1); // double min_confidence; nh.param("min_confidence_initialization", min_confidence, -2.5); //0.0); double chi_value; nh.param("kalman/gate_distance_probability", chi_value, 0.9); double acceleration_variance; nh.param("kalman/acceleration_variance", acceleration_variance, 1.0); bool detector_likelihood; nh.param("jointLikelihood/detector_likelihood", detector_likelihood, false); bool velocity_in_motion_term; nh.param("jointLikelihood/velocity_in_motion_term", velocity_in_motion_term, false); double detector_weight; nh.param("jointLikelihood/detector_weight", detector_weight, -1.0); double motion_weight; nh.param("jointLikelihood/motion_weight", motion_weight, 0.5); double sec_before_old; nh.param("target/sec_before_old", sec_before_old, 3.6); double sec_before_fake; nh.param("target/sec_before_fake", sec_before_fake, 2.4); double sec_remain_new; nh.param("target/sec_remain_new", sec_remain_new, 1.2); int detections_to_validate; nh.param("target/detections_to_validate", detections_to_validate, 5); double haar_disp_ada_min_confidence, ground_based_people_detection_min_confidence; nh.param("haar_disp_ada_min_confidence", haar_disp_ada_min_confidence, -2.5); //0.0); nh.param("ground_based_people_detection_min_confidence", ground_based_people_detection_min_confidence, -2.5); //0.0); nh.param("swissranger", swissranger, false); nh.param("ground_based_people_detection_min_confidence_sr", min_confidence_detections_sr, -1.5); nh.param("min_confidence_initialization_sr", min_confidence_sr, -1.1); nh.param("output/history_pointcloud", output_history_pointcloud, false); nh.param("output/history_size", output_history_size, 0); nh.param("output/markers", output_markers, true); nh.param("output/image_rgb", output_image_rgb, true); nh.param("output/tracking_results", output_tracking_results, true); bool debug_mode; nh.param("debug/active", debug_mode, false); // Set min_confidence_detections variable based on sensor type: if (swissranger) min_confidence_detections = ground_based_people_detection_min_confidence; else min_confidence_detections = haar_disp_ada_min_confidence; // Take chi square values with regards to the state dimension: fillChiMap(chi_map, velocity_in_motion_term); // Compute additional parameters: period = 1.0 / rate; double gate_distance; gate_distance = chi_map.find(chi_value) != chi_map.end() ? chi_map[chi_value] : chi_map[0.999]; double position_variance; // position_variance = 3*std::pow(2 * voxel_size, 2) / 12.0; // DEFAULT position_variance = 30*std::pow(2 * voxel_size, 2) / 12.0; std::vector<double> likelihood_weights; likelihood_weights.push_back(detector_weight*chi_map[0.999]/18.467); likelihood_weights.push_back(motion_weight); ros::Rate hz(num_cameras*rate); // cv::namedWindow("TRACKER ", CV_WINDOW_NORMAL); // Initialize an instance of the Tracker object: tracker = new open_ptrack::tracking::Tracker( gate_distance, detector_likelihood, likelihood_weights, velocity_in_motion_term, min_confidence, min_confidence_detections, sec_before_old, sec_before_fake, sec_remain_new, detections_to_validate, period, position_variance, acceleration_variance, world_frame_id, debug_mode, vertical); starting_index = 0; // If extrinsic calibration is not available: if (!extrinsic_calibration) { // Set fixed transformation from rgb frame and base_link tf::Vector3 fixed_translation(0, 0, 0); // camera_rgb_optical_frame -> world tf::Quaternion fixed_rotation(-0.5, 0.5, -0.5, -0.5); // camera_rgb_optical_frame -> world tf::Vector3 inv_fixed_translation(0.0, 0.0, 0); // world -> camera_rgb_optical_frame tf::Quaternion inv_fixed_rotation(-0.5, 0.5, -0.5, 0.5); // world -> camera_rgb_optical_frame world_to_camera_frame_transform = tf::Transform(fixed_rotation, fixed_translation); camera_frame_to_world_transform = tf::Transform(inv_fixed_rotation, inv_fixed_translation); } // Spin and execute callbacks: ros::spin(); return 0; }
//--- defining a callback function--- void trajectoryCallback(const moveit_msgs::DisplayTrajectory::ConstPtr& msg) { ROS_INFO("Recibida trayectoria"); moveit_msgs::RobotTrajectory _robot_trajectory = msg->trajectory[0]; //ROS_INFO("Robot trajectory"); trajectory_msgs::JointTrajectory _joint_trajectory = _robot_trajectory.joint_trajectory; //ROS_INFO("Joint trajectory"); std::vector<trajectory_msgs::JointTrajectoryPoint> _points = _joint_trajectory.points; //ROS_INFO("Points vector"); PA10Wrapper pa10; ros::Rate hz (20); //angulos[0]<< 0,0,0,0,0,0,0; Eigen::VectorXf angulos [] = {Eigen::VectorXf (7)}; angulos[0]<< 0,0,0,0,0,0,0; pa10.goTo(angulos[0]); sleep(1.0); pa10.modAxs(); //sleep(1.0); Eigen::VectorXf joint_positions = Eigen::VectorXf (7); //std::vector<std_msgs::Float64> joint_positions; std_msgs::Float64 value_1, value_2, value_3, value_4, value_5, value_6, value_7; value_1.data=0; value_2.data=0; value_3.data=0; value_4.data=0; value_5.data=0; value_6.data=0; value_7.data=0; /**for(int i=0; i<200;i++){ value_1.data+=0.0025; value_4.data-=0.0025; joint_positions << (float) value_1.data, (float) value_2.data, (float) value_3.data, (float) value_4.data, (float) value_5.data,(float) value_6.data, (float) value_7.data; //joint_positions << 0.003962332959198028, 0.0515037272636724, 0.07705049507275152, -0.13779913773443253, 0.04189187387812674, 0.10722692157583646, -0.08539089352257592; //pa10.odrAxs(joint_positions); pa10.odrAxs(joint_positions); ROS_INFO("Valor articular %f", joint_positions[0]); hz.sleep(); }*/ int num_pos_intermedias = 500; for(int i=0; i < _points.size() - 1; i++){ //publish data -> controles Gazebo for(int paso = 0; paso < num_pos_intermedias; paso++){ value_1.data = _points.at(i).positions[0] + (paso * ((_points.at(i+1).positions[0] - _points.at(i).positions[0] )/ num_pos_intermedias)); //ROS_INFO("Valor articular 0 %f", value_1.data); //base_pub.publish(value_1); value_2.data = _points.at(i).positions[1] + (paso * ((_points.at(i+1).positions[1] - _points.at(i).positions[1] )/ num_pos_intermedias)); //ROS_INFO("Valor articular 1 %f", value_2.data); //s2_pub.publish(value_2); value_3.data = _points.at(i).positions[2] + (paso * ((_points.at(i+1).positions[2] - _points.at(i).positions[2] )/ num_pos_intermedias)); //ROS_INFO("Valor articular 2 %f", value_3.data); //s3_pub.publish(value_3); value_4.data = _points.at(i).positions[3] + (paso * ((_points.at(i+1).positions[3] - _points.at(i).positions[3] )/ num_pos_intermedias)); //ROS_INFO("Valor articular 3 %f", value_4.data); //e1_pub.publish(value_4); value_5.data = _points.at(i).positions[4] + (paso * ((_points.at(i+1).positions[4] - _points.at(i).positions[4] )/ num_pos_intermedias)); //ROS_INFO("Valor articular 4 %f", value_5.data); //e2_pub.publish(value_5); value_6.data = _points.at(i).positions[5] + (paso * ((_points.at(i+1).positions[5] - _points.at(i).positions[5] )/ num_pos_intermedias)); //ROS_INFO("Valor articular 5 %f", value_6.data); //w1_pub.publish(value_6); value_7.data = _points.at(i).positions[6] + (paso * ((_points.at(i+1).positions[6] - _points.at(i).positions[6] )/ num_pos_intermedias)); //ROS_INFO("Valor articular 6 %f", value_7.data); //w2_pub.publish(value_7); joint_positions << (float) value_1.data, (float) value_2.data, (float) value_3.data, (float) value_4.data, (float) value_5.data,(float) value_6.data, (float) value_7.data; //joint_positions << 0.003962332959198028, 0.0515037272636724, 0.07705049507275152, -0.13779913773443253, 0.04189187387812674, 0.10722692157583646, -0.08539089352257592; pa10.odrAxs(joint_positions); //hz.sleep(); //ros::spinOnce; sleep(0.010); } ROS_INFO("Punto de trayectoria %d", i); // IF CONECTAR CON PA10 real = 1 //pa10.odrAxs(joint_positions); //hz.sleep(); } }