-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update external wrench plugin with mutiple wrenches and improve rpc responses #418
Changes from 4 commits
fb4b0e2
36e2801
22c7f0c
f796908
7366f2f
9b70f79
74f8c32
2f5dcac
64199f6
ada8291
b7d1d38
c4da8fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,83 @@ | ||||
#ifndef EXTERNALWRENCH_H | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use a less ambiguous header guard (something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Furthermore, please add a copyright notice, something like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||
#define EXTERNALWRENCH_H | ||||
|
||||
#include <iostream> | ||||
#include <stdlib.h> | ||||
#include <ctime> | ||||
#include <stdio.h> | ||||
#include <string> | ||||
#include <memory> | ||||
|
||||
#include "gazebo/gazebo.hh" | ||||
#include <gazebo/physics/PhysicsEngine.hh> | ||||
#include <gazebo/common/Events.hh> | ||||
#include <gazebo/common/Plugin.hh> | ||||
#include <gazebo/transport/Node.hh> | ||||
#include <gazebo/physics/Link.hh> | ||||
#include <gazebo/physics/World.hh> | ||||
#include <gazebo/physics/Model.hh> | ||||
#include <GazeboYarpPlugins/common.h> | ||||
|
||||
#include <yarp/os/Network.h> | ||||
#include <yarp/os/RpcServer.h> | ||||
#include <yarp/os/Bottle.h> | ||||
#include <yarp/sig/Vector.h> | ||||
#include <yarp/os/Thread.h> | ||||
#include <yarp/os/Time.h> | ||||
#include <yarp/os/Vocab.h> | ||||
#include <yarp/os/Log.h> | ||||
#include <yarp/os/LogStream.h> | ||||
#include <yarp/math/Math.h> | ||||
|
||||
#include <boost/lexical_cast.hpp> | ||||
|
||||
using namespace gazebo; | ||||
|
||||
class ExternalWrench | ||||
{ | ||||
private: | ||||
|
||||
static int count; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everything seems to be ok from what I understand, but static variables are always a bit tricky do deal with. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @traversaro I am not following you exactly. The
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but what happens if there are two different externalwrench plugins in the same model? As far as I was able to see, everything should work fine, but keeping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
At the moment this is not possible to do by a user as there will be port address conflict while trying to open the rpc port with the model name. So, I believe the usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And what about two different externalwrench plugins in two different model that are spawned together? The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While writing https://github.com/robotology/gazebo-yarp-plugins/pull/418/files#r273692453 , I am a bit confused by the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The conflict will happen for the visuals. So, it is better to not decrease the count of the wrenches after the duration is done. It is better to keep an increasing |
||||
float color[4]; | ||||
struct wrenchCommand | ||||
{ | ||||
std::string link_name; | ||||
yarp::sig::Vector force; | ||||
yarp::sig::Vector torque; | ||||
double duration; | ||||
}; | ||||
|
||||
std::unique_ptr<wrenchCommand> wrenchPtr{new wrenchCommand()}; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am a bit confused. Why are you using wrenchCommand wrench; or even better, given that the structure struct
{
std::string link_name;
yarp::sig::Vector force;
yarp::sig::Vector torque;
double duration;
} wrench; or given that the structure is never used standalone, why not simply including the attributes of the structure as attributes of the class? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @traversaro I remember back in time starting out with simple data structures without pointers but then I quickly ran into some problems while handling dynamic wrench addition and removal in multiple wrench operation mode. That is why I belive I migrated to using pointer to handle them correctly. Now, I tested to change back to simple data structures again and in the multiple wrench case the visuals are funny looking But with the pointers usage it is stable At the moment I prefer not to investigate it further and I would like to stick to the pointers usage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You obtain this behavior just by changing If instead you obtain this because you changed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This behavior is after changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||
|
||||
double tick; | ||||
double tock; | ||||
|
||||
bool model_has_link; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variables does not seem to be ever read, but just write too. Can it be removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||
physics::ModelPtr model; | ||||
physics::LinkPtr link; | ||||
physics::Link_V links; | ||||
|
||||
transport::NodePtr m_node; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you are using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, removed |
||||
transport::PublisherPtr m_visPub; | ||||
msgs::Visual m_visualMsg; | ||||
|
||||
event::ConnectionPtr updateConnection; | ||||
|
||||
void setVisual(); | ||||
|
||||
public: | ||||
|
||||
bool duration_done; | ||||
|
||||
ExternalWrench(); | ||||
~ExternalWrench(); | ||||
|
||||
bool setWrench(physics::ModelPtr&, yarp::os::Bottle&); | ||||
bool getLink(); | ||||
|
||||
void applyWrench(); | ||||
void deleteWrench(); | ||||
void setModel(); | ||||
}; | ||||
|
||||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we use a good old
std::vector<ExternalWrench>
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to #418 (comment)