-
Notifications
You must be signed in to change notification settings - Fork 39
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
SRC-4962 Add command type to JointState & ActuatorCommand #114
Conversation
Hi @mykolasjuraitis , I might be wrong, but I thought ros_ethercat was a robot agnostic package. Making it depend on Shadow messages for a Shadow specific setting (PWM or TORQUE) is a bit strange and not generic anymore. Just to be a bit more helpful, what about introducing this new variable to the sr_hardware_interface like the valve is introduced in the muscle command here |
@@ -167,6 +168,9 @@ class JointState | |||
/// The effort the joint should apply in Nm or N (write-to variable) | |||
double commanded_effort_; | |||
|
|||
/// Indicates if commanded_effort_ is torque or PWM | |||
sr_robot_msgs::ControlType::_control_type_type actuator_command_type_; |
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.
I kind of dislike making the field a ROS msg when none of the others are...
I can't give a good reason for it though.
I guess storing the type could be done with an int enum, while a ROS msg class actually involves a much bigger object, with serialization methods and so on.
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.
@toliver so you concur with introducing a enum for PWM/TORQUE within the generic ros_ethercat ? What if some other systems want CURRENT (in case they control their efforts in current or so) ?
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.
_control_type_type
is actually an alias for int enum. But I agree ideally we should get rid of existing dependency to sr_robot_msgs
not add more usages.
Which one would you prefer locally declared enum with values: unspecified, torque, pwm or std::string with suggested values: "", "torque", "pwm" but allowing anything controller wants to pass to the driver?
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.
@guihomework thanks for suggestion at top level comment. We should be able to add desired field in child classes at sr_core
repository instead of here.
@guihomework what we are currently trying to modify is the mechanism to let the driver know if it should send a PWM or torque command to the hand. But in order to avoid issues with the running controllers (that are tuned either to produce PWM or torque cmds) we reload the controller parameters and then call the service "reset_gains" for all running controllers. That's why we want to remove the need for it. The controller will set the type in the jointState structure (or a specialised child of that, as @mykolasjuraitis is proposing), then the transmissions will propagate that to the actuator structure and the driver will read it from there. How does that sound? Do you see any conflicts with the way you work or with your custom controllers? |
We have considered doing it in a more "proper" ros_control way, by defining a new hardware_interface for the RosEthercat class (additionally to having Then the prepareSwitch and doSwitch methods would take care of switching the command type variable in the hand driver, based on the interfaces used by the running controllers. The reason why we haven't taken this route that is probably the right way to do it in ros_control is that we think it will involve a lot more changes. This is something we plan to address when we migrate the driver to ROS2. |
@toliver I completely understand your goal, find it a good idea, and the chosen solution seems ok (I did not think of all corner cases), but my early intuition made me believe it can all be done in the child class defined in sr_hardware_interface not in the parent hardware_interface in ros_ethercat. This way ros_ethercat remains agnostic to the particularity of the hand having 2 effort commands. most controllers used for the hand are in sr_mechanism_controllers and you will necessarily handle the existing controllers there (we still use mixed-position-velocity controllers, no other special one) so that they work with your new plan. I was mainly "complaining" about changing ros_ethercat in general when fixing internal problems of a particular robot, but we would not be affected by the change as we do not use ros_ethercat out of the Shadow hand. I wonder if the pr2 (if still updated) switched to ros_ethercat instead of pr2_ethercat... They might be affected with this PR. Regarding "breaking" compatibility, up to now, if one loaded a controller tuned for TORQUE (a 100-unit command would make the joint start to move) on a driver loaded for PWM control this could have consequences. I don't remember which PWM value starts to make the joint move, do you ?. The opposite (driver loaded for TORQUE control and PWM controller) could also happen, but was less frequent, since PWM control was default on hand shipped to customers I believe. With the plan to use the command_type in the parameters of the controller, a default behaviour (in case this parameter was omitted due to not updated yet) should be chosen that is conservative. Which default you will choose could result in potentially high torques. It all depends what is safer, typical TORQUE tuning output or typical PWM tuning output. |
That's a good point. We were thinking that the driver would throw an error to the user and send PWM=0 to the hand if it detects that the controllers are not setting a valid command_type. |
@guihomework I have created similar PR without referencing any Shadow specific data structures: #115 Could you please have a look? |
Hi, @mykolasjuraitis I have been looking for several minutes already and what you seem to have fixed is the non-usage of a sr_robot_msg, which is good, but the PR still changes the ros_ethercat_model. I had pointed to sr_hardware_interface, as a potential place to add this field but did not look in detail yesterday. Should I still look deeper and maybe suggest a more prepared alternative ? |
@guihomework problem is that we can add new fields in actuator data structures in |
@mykolasjuraitis while you were typing you answer I was looking and EXACTLY found the same line you refer to @mykolasjuraitis and @toliver I see the problem is on the propagation, not on the internal usage/storage of the type variable which could be in the derived Actuator something like SrMotorActuatorCommand motor_command_ the same as SrMotorActuatorState motor_state_ In summary, the controller loads and reads parameters, and this way knows its effort type and should transmit it to driver. However, this happens only at switch of controllers, you do not expect a controller to live update its type on the fly, do you ? I see there is no existing mechanism to synchronize the driver and the controller, even at start, except nullifying the command. The joint_state is shared between the controller being stopped and the one starting, and the value effort could change type and the driver needs to know.
If you still want to go on changing the joint_state I suggest then to make it generic.
currently the hand does not use Newtons and new Shadow hand users are confused. Maybe a joint_state_publisher or the transmission could even read a calibration yaml in the future and publish real newtons from the read TORQUE (divide by 10 roughly). Shadow packages could then augmented the 2 generic types with PWM, GAUGE_DIFF (because this is actually what the TORQUE is), VALVE_CMD |
Proposed changes
Add command type to JointState & ActuatorCommand so that controllers can indicate what commanded effort means.
Checklist
If the task is applicable to this pull request (see applicability criteria in brackets), make sure it is completed before checking the corresponding box. Otherwise, tick the box right away. Make sure that ALL boxes are checked BEFORE the PR is merged.