![]() ![]() For those wishing to test the code, a simple client can be launched to actuate the joint: Depending on how far from the target we are, it will decide wether to set the state to "success" or to "abort". The "distance" to the target is sent to the server. ![]() After 2.5 seconds the actuator is fixed to the current achieved position, which may not correspond to the target (due to the presence of an obstructing object). As soon as a target is received, the target position of the joint is updated. The "quick 'n' dirty" code inside the child script is associates the joint to the server, and then polls for new goals. In the included scene, I use the server to lift a platform. At simulation end, I de-associate the object from the server, so that new goals won't be accepted until a new simulation (to be honest, this is not 100% true, since my implementation is a little weak right now). Finally, the object will notify the server that the action is completed (succesfully, if possible). It will then execute the action while doing so, it can transfer some data to the server in order to publish feedback messages. The object has to poll the server for new goal values (I don't know yet how to implement a callback-based mechanism, I will figure it out in the future). After this "acknowledgement", the server will accept new goals (before, he had to reject them somehow). The idea behind my plugin is not very complex: I want actions to be performed only if an object explicitly notifies the server that he's going to execute the job. I added some simple Lua functions, that allows the serving object to interface with the action server. I use this action to specify a joint position, asking the actuator to reach it. It asks "something" to reach a target value (whatever this means), allowing to specify a "tolerance". In this example, I use a very basic action called "ReachTarget". sp=sharing (I discourage to use it as a reference for new projects :P I am a novice and I don't want your PC to explode due to my inexperience!) In addition, I post here the link to another example I created. As you suggest, I will try to have a deeper look at the available ROS plugins, so as to understand how to create something more functional. This was obvioulsy a very simple example. Return(PLUGIN_VERSION) // initialization went fine, we return the version number of this plugin (can be queried with simGetModuleName)Īs I explained, I am calling mysrv.init() after having checked that ROS core is properly running using ROS_server::initialize() from the original ROS plugin (it's a lazy solution, I am planning to do something better in the future!). Return (0) //If the master is not running then the plugin is not loaded. Std::cout << "Sorry, your V-REP copy is somewhat old. If (vrepVer<30102) // if V-REP version is smaller than 3.01.02 SimGetIntegerParameter(sim_intparam_program_version,&vrepVer) Std::cout << "Error, could not find all required functions in the V-REP library. Return(0) // Means error, V-REP will unload this plugin Std::cout << "Error, could not find or correctly load the V-REP library. Std::string currentDirAndPath(curDirAndFile) Getcwd(curDirAndFile, sizeof(curDirAndFile)) Dynamically load and bind V-REP functions: VREP_DLLEXPORT unsigned char v_repStart(void* reservedPointer,int reservedInt) serving! However, does anyone know if this is a wrong/discouraged way of working? If so, could you give me some references?Ĭode: Select all // This is the plugin start routine (called just once, just after the plugin was loaded): I was able to compile and load the plugin, and in addition the server is. I then added to vrep_plugin_skeleton.cpp the declaration of an instance of MyAveragingAction, and within the method v_repStart() I simply call myActionServer::init(). (The "big" difference with the original is that the SimpleActionServer is created within the init() method.) Ros::NodeHandle *nh_ // Now it is a pointerĪctionlib::SimpleActionServer *as_ // now it is a pointer MyAveragingAction(std::string name) : action_name_(name) // unchanged ![]()
0 Comments
Leave a Reply. |