Skip to content
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

[SPIDAR][WIP] the latest version of real platform #607

Open
wants to merge 169 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
64d4f50
Add tiger v1 model
chibi314 Nov 12, 2019
c60540c
[tiger] add tiger v1 config files
chibi314 Nov 13, 2019
46aa78d
[tiger] fix urdf and param
chibi314 Nov 21, 2019
3a72f21
[tiger] improve urdf
chibi314 Nov 28, 2019
276be74
[tiger] modify mesh and urdf
chibi314 Dec 5, 2019
a75d12f
[tiger] fixed wrong robot name of urdf
chibi314 Dec 19, 2019
35d1882
[tiger] fix servo config
chibi314 Dec 24, 2019
119f149
[tiger] modify motor info
chibi314 Dec 24, 2019
3ac53a8
[tiger] fix launch file
chibi314 Dec 24, 2019
320fe1d
[tiger] fix motor info
chibi314 Dec 24, 2019
ed237ad
[WIP] [tiger] fix launch and param for aerial_robot v1.2.0
chibi314 Jul 1, 2020
2c1973f
[tiger] modify leg collision model
Jul 3, 2020
02358b2
[tiger] fix motor info max_thrust
Jul 7, 2020
43de47f
[tiger] add navigator in NavigationConfig
Jul 7, 2020
e926ff2
[tiger] add alias in bringup.launch
Jul 7, 2020
1f4ec8b
[tiger] fix wrong fc position
Jul 7, 2020
0092f49
[tiger] modify rviz config
Jul 7, 2020
e3560cd
[Dragon] correct the IMU sensor plugin name for HydrusLike model
tongtybj Jul 3, 2022
5117e0b
[Dragon] refactor the rotor interfere estimate & compensate process
tongtybj Jul 3, 2022
ccdb197
[Tiger] refactor the configuartion and bringup files to be compatile …
tongtybj Jul 3, 2022
be01f54
[Tiger] refactor the urdf model to be compatible for dragon full_vect…
tongtybj Jul 3, 2022
ee09e9d
[Tiger] update the transform demo script for tiger and add the transf…
tongtybj Jul 3, 2022
5f356f7
[Tiger] add alias process for configurating the neuron servos.
tongtybj Jul 5, 2022
523c18d
[tiger] fix the sensor launch file
tongtybj Jul 7, 2022
52b082f
Implement joint torque calculation for full vectoring model of dragon
tongtybj Dec 8, 2021
75d3548
[Workaround] add robot model for tiger derived from dragon
tongtybj Jul 11, 2022
6e5de32
[Tiger] implement thrust force allocation with consideration of joint…
tongtybj Jul 14, 2022
b110275
[Tiger] implement thrust force allocation with consideration of joint…
tongtybj Jul 17, 2022
76e58e4
[Tiger] fix the wrong size initialization for Eigen Matrix
tongtybj Jul 20, 2022
57a7bdb
[Tiger] fix the wrong position of edf in urdf
tongtybj Jul 23, 2022
3161f8a
[Estimation] use ros time now for world->root tf broadcast if no imu …
tongtybj Jul 23, 2022
935a5ee
[Tiger] update the rviz config
tongtybj Jul 24, 2022
4b4add6
[Tiger] update the robot model for tiger v1
tongtybj Jul 24, 2022
1f4ece7
[Tiger] update the inerital parameters and the dynamics config for ga…
tongtybj Jul 24, 2022
f4ac05f
[Tiger] update the visual model
tongtybj Jul 25, 2022
848c06b
[Tiger] further update the robot model
tongtybj Jul 30, 2022
d4a5929
[Tiger][Walk] add urdf model for tiger walk mode
tongtybj Aug 9, 2022
36318ad
[Tiger][Walk] enable quick initial posing
tongtybj Aug 9, 2022
0c27ff9
[Tiger][Walk][WIP] calcuate the thrust force, joint torque, contact f…
tongtybj Aug 9, 2022
94467b2
[WIP] modify the init pose of tiger in rviz mode
tongtybj Aug 9, 2022
3d6f2dd
[Tiger][WIP] implement the static balance between joint torque, thrus…
tongtybj Aug 11, 2022
ac1f341
[Tiger] refactor the URDF model for walk mode
tongtybj Aug 11, 2022
0c0e23c
[Tiger] move the QP based thrust force calcualation for walking to Ti…
tongtybj Aug 11, 2022
0ff0fac
[WIP] enable no contact force for single link
tongtybj Aug 11, 2022
f0c688b
[Tiger][WIP] implement walk control based on the static blance
tongtybj Aug 14, 2022
64115cb
[Tiger][Walk][Model] no gimbal roll lock
tongtybj Dec 6, 2022
8cd2d63
[Tiger] add option c++14 for CMakeLists
tongtybj Dec 6, 2022
2239f29
[Tiger] update the motor ESC configuration
tongtybj Dec 6, 2022
0d658c5
[Tiger] update joint servo torque scale (Dynamixel XH430-V350R)
tongtybj Dec 6, 2022
1611eee
[Tiger] update the neuron servo configuration
tongtybj Dec 6, 2022
567379b
[Tiger][Stand] first trial of standing using thrust force
tongtybj Dec 6, 2022
b645d1f
[Tiger][Walk] update the static balance process. 1) fix bug about the…
tongtybj Aug 16, 2022
bf4b37a
[Tiger][Walk] implement static joint torque compensation in a complia…
tongtybj Aug 16, 2022
3444b4e
[Tiger][WIP] use QP4 instead of QP3
tongtybj Aug 16, 2022
a163ff2
[Tiger][WIP] improve the stand performance
tongtybj Aug 16, 2022
e49b2b8
[Tiger] update the torque_scale wich has better performance
tongtybj Aug 18, 2022
5642ebb
[Tiger][Stand] modify the QP parameter for better static balance calc…
tongtybj Aug 18, 2022
8dcdb76
[Tiger][Walk] implement baselink z position PID control
tongtybj Aug 19, 2022
37dad74
[Tiger][Stand] add D control term for baselink position feedback control
tongtybj Aug 19, 2022
acba3f4
[Tiger][WIP] force to use position control for joint yaw
tongtybj Aug 19, 2022
f8a17d2
[Tiger][WIP] implement walk navigator
tongtybj Aug 20, 2022
98b4d00
[Tiger][Stand] refactor the joint control, introducing a torque thres…
tongtybj Aug 21, 2022
bf97602
[Tiger][Walk] add XY position control for baselink
tongtybj Aug 21, 2022
5e9f19d
[Tiger][Walk] implement analytical solution to solve the IK for the j…
tongtybj Aug 25, 2022
43bab49
[Tiger][Walk] implement special joint position control strategy for s…
tongtybj Aug 27, 2022
f38aae7
[Tiger][Walk] add logging
tongtybj Aug 27, 2022
070efcc
[Tiger][Walk] refactor the joint navigation and control for moving ba…
tongtybj Aug 27, 2022
1cf5cd5
[Tiger][Walk] modify parameter to enable the baselink ascending/desce…
tongtybj Aug 28, 2022
00f7bcf
[Tiger][Walk] implement link-wise rotation control by vectoring thrus…
tongtybj Sep 2, 2022
3327743
[Tiger][WIP] add several verbose for debug
tongtybj Sep 23, 2022
f9001b7
[Navigation] refactor the unhealthy sensor status in pre-flight phase
tongtybj Sep 25, 2022
f6238cb
[Tiger][Walk][Navigator] do not arming if sensor is unhealdth
tongtybj Sep 25, 2022
7202d46
[Tiger][Walk] implement free leg raise/lower navigation process
tongtybj Sep 25, 2022
3066e31
[Tiger][Walk] fix the bug about link-wise rotation thrust control for…
tongtybj Oct 6, 2022
9343bc0
[Neuron][Dynamixel] remove uncessary codes
tongtybj Sep 25, 2022
3ea097d
[Neuron][Dynamixel] enable to get model number in init phase
tongtybj Sep 25, 2022
5e6099a
[Neuron][Dynamixel][WIP] enable sending goal current (torque) in the …
tongtybj Sep 25, 2022
5cac395
[Neuron][Dynamixel][WIP] use sync write for goal position regardless …
tongtybj Sep 25, 2022
718efcd
[Neuron][Dynamixel] enable polling the operating mode
tongtybj Oct 6, 2022
cbea7ff
[Neuron][Dynamixel] refactor the current assignment
tongtybj Oct 7, 2022
59b7240
[Neuron][Dynamixel] enable to send goal current every iteration after…
tongtybj Oct 7, 2022
2efeb72
[Spinal][Servo][WIP] enable send goal current from rosserial to spina…
tongtybj Oct 7, 2022
5a700d0
[Spinal][Neuron] modify the CAN initialize message protocol to suppor…
tongtybj Oct 7, 2022
07e5f11
[Servo Bridge] enable to pub/sub target torque via servo bridge
tongtybj Oct 10, 2022
53db997
[Servo Config] refactor Servo.yaml for all robots: removing unnecessa…
tongtybj Oct 10, 2022
53882aa
[Tiger][Servo Config] refactor Servo.yaml. removing unnecessary topic…
tongtybj Oct 10, 2022
e7840bf
[Tiger][Walk] refactor the joint torque control based on the improved…
tongtybj Oct 10, 2022
822fc20
[WIP][Spinal] do not switch off servo for overload flag
tongtybj Oct 12, 2022
8180a9a
[Spinal][RQT] fix the import bug for python3
tongtybj Oct 12, 2022
76d56c2
[Servo][Spinal][Neuron] refactor the force servo off rule, which is d…
tongtybj Oct 12, 2022
a4f695c
[Neuron][Dynamixel] implement setup of pre-defined configuration
tongtybj Oct 12, 2022
64a19c3
[Spinal][RQT] fix the wrong list assignment
tongtybj Oct 12, 2022
b0f82d9
[Neuron][Dynamixel] add original rule to force switching off servo ac…
tongtybj Oct 12, 2022
562d2f5
[Servo Bridge] fix bug about the servo target torque subscriber
tongtybj Oct 13, 2022
7d81a04
[Spinal][CAN] set 1[ms] internal between motor pwn and servo target c…
tongtybj Oct 14, 2022
012e811
[Neuron][STM32F4] ignore Debug.launch
tongtybj Oct 14, 2022
a9cc173
[Tiger][Walk] refactor the link-wise rotation control wit folloing ru…
tongtybj Oct 14, 2022
aa2a100
[Tiger][Walk] refactor the joint control related to extra joint error
tongtybj Oct 15, 2022
b469714
[Tiger][Walk] set max torque for joint servo in lower leg case
tongtybj Oct 19, 2022
8750baa
[Spinal][Walk] no negative (downward) thrust force by center link fee…
tongtybj Oct 20, 2022
f6e0c3e
[Nagivation] make the callback functin about joystick message over-wr…
tongtybj Oct 24, 2022
99e85a0
[Tiger][Walk] no joint torque control in non-arming state
tongtybj Oct 24, 2022
d123f69
[Tiger][Walk][Navigation] add joystick navigation to operate joints
tongtybj Oct 24, 2022
fa0867e
[Tiger][Walk] make the threshold that checks lower leg touchdown reco…
tongtybj Oct 24, 2022
50bba5d
[Tiger][Walk][Navigation] refactor the joystick command for quick land
tongtybj Oct 26, 2022
0b9f5f8
[Tiger][Walk] refactor the joint control for the opposite of raised l…
tongtybj Oct 26, 2022
7441f8c
[Tiger][Model] make quiet
tongtybj Oct 26, 2022
5950180
[Tiger][Walk][Navigation] fix bug in the joystick command
tongtybj Nov 4, 2022
ec7df0b
[Tiger][Walk] move the calculation of static balance for walking from…
tongtybj Nov 5, 2022
cddf80e
[Tiger][Walk][Model] refactor the logging process
tongtybj Nov 6, 2022
12c3d87
[Tiger][Walk] fix the bug about the jacobian for statics
tongtybj Nov 6, 2022
0f92c7b
[Tiger][Walk] consider the baselink rotation when calcualte the stati…
tongtybj Nov 6, 2022
673aa17
[Tiger][Walk] force to use joint torque control for raise/lower leg
tongtybj Nov 7, 2022
9d43e9b
[Tiger][Walk] refactor raise/lower leg process. Enable mutal referenc…
tongtybj Nov 7, 2022
846f4b7
[Tiger][Walk] further improve raise/lower leg process
tongtybj Nov 9, 2022
27315ef
[Tiger][Walk] use large torque for pitch joint in opposite of raise l…
tongtybj Nov 11, 2022
e321838
[Tiger][Walk][Pattern] implement forward move walk pattern
tongtybj Nov 13, 2022
ae56f85
[Tiger][Walk][Pattern] implement simulation mode to check the pattern…
tongtybj Nov 14, 2022
b3121ac
[Tiger][Walk][Pattern] enable to start walk pattern from joy
tongtybj Nov 16, 2022
8134ebe
[Tiger][Walk] update the joint limit for IK
tongtybj Nov 19, 2022
d5ec47f
[Tiger][Walk] update the rate of raise transition for instant transit…
tongtybj Nov 19, 2022
7871d26
[Tiger][Walk] use large servo torque for all joint pitchs (except for…
tongtybj Nov 19, 2022
4c8f2f3
[Tiger][Walk] use large servo torque to lower the free leg if the I g…
tongtybj Nov 19, 2022
14562a3
[Tiger][Walk] enable to enable/disable all servo torque from joy
tongtybj Nov 21, 2022
30789d3
[Tiger][Walk] use position control for internal pitch joint in free l…
tongtybj Nov 21, 2022
85e43ff
[Tiger][Walk] use position control for external pitch joint in free l…
tongtybj Nov 21, 2022
e540643
[Tiger][Walk] implement position control based joint motion mode for …
tongtybj Nov 22, 2022
34dc55b
[Tiger][Walk] set joint position control model as default
tongtybj Nov 22, 2022
af5d075
[Tiger][Walk][WIP] set larger raise angle for front legs in walk pattern
tongtybj Nov 25, 2022
53adc21
[Tiger][Walk] refactor the baselink and leg ends reset process for wa…
tongtybj Nov 25, 2022
de84ec9
[Tiger][Walk][WIP] success walk pattern configuration
tongtybj Nov 26, 2022
0248c4d
[Tiger][Walk] set the front leg raise angle ratio as rosparam
tongtybj Nov 28, 2022
be6f15e
[Tiger][Walk] introduce two threshold about free_leg_force_ratio_ in …
tongtybj Nov 28, 2022
2f41419
[Tiger][Walk] very large raise_leg_force_i_gain for immediate raise t…
tongtybj Nov 28, 2022
ae86d13
[Tiger][Walk] use torque control for free leg during raise, and thus …
tongtybj Nov 28, 2022
3845b75
[Tiger][Walk] refator and fix bug about the modify process in raise leg
tongtybj Nov 28, 2022
03b3a4f
[Tiger][Walk] further modify the i gains for modify and lower leg phases
tongtybj Nov 28, 2022
7174772
[Tiger][Walk] fix the bug about the target joint angle bias due to th…
tongtybj Nov 29, 2022
a3bc353
[Tiger][Walk] implement the joint torque feedback control by using th…
tongtybj Nov 29, 2022
cdfea01
[Tiger][Walk] set the front_leg_raise_ratio to 2.0, which means doubl…
tongtybj Nov 30, 2022
9373bec
[Tiger][Walk] refactor the joint torque control in the begining of th…
tongtybj Nov 30, 2022
0c85fd3
[Tiger][Walk][Control] abolish the parametic resist torque for joint …
tongtybj Dec 2, 2022
f46647a
[Tiger][Walk][Control] enable the pure joint position control for the…
tongtybj Dec 2, 2022
a09efc0
[Tiger][Walk] improve the raise performance by two points: 1. refacto…
tongtybj Dec 2, 2022
612debc
[Tiger] add rosbag play script for debuging walk motion
tongtybj Dec 3, 2022
13eff57
[Tiger][Walk] change the pose of free leg after the leg is raised
tongtybj Dec 3, 2022
089f4af
[Spider][Walk] configuration and modification for successful stand an…
tongtybj Dec 3, 2022
4bb52d7
[Spider][Model] correct the battery position configuration for differ…
tongtybj Dec 4, 2022
26ed3b9
[Spider][Navigator][Model] refactor the method to check the initiliza…
tongtybj Dec 5, 2022
d0c2717
[Spider][Walk][Control] use another joint static torque for raise leg…
tongtybj Dec 5, 2022
a4bf94e
[Spider][Walk] configuration for successful stand-walk with battery
tongtybj Dec 5, 2022
d49f36a
[Spider] move the calcualtion of tiger model (e.g., contact force) fr…
tongtybj Dec 4, 2022
02d628f
[Spider] rename the robot model class for ground locomotion
tongtybj Dec 4, 2022
c65fb99
[Spider] revert the full vectoring robot model for flight
tongtybj Dec 4, 2022
0fad5cb
[Spider][Naviator] refactor the systme to support both flight and wal…
tongtybj Dec 5, 2022
56ea5bd
[Spider][Flight][Navigate] implement special landing process for spider
tongtybj Dec 6, 2022
aafcc60
[Tiger] slient, no verbose
tongtybj Jul 30, 2022
279db96
[Dragon] assign the joint name to change the joint angles in landing …
tongtybj Aug 1, 2022
03bd7c0
[Tiger] use gimbal nominal angles in early takeoff phase
tongtybj Aug 2, 2022
9b47717
[Control] avoid the increase of I term in landing process
tongtybj Aug 2, 2022
87b99c6
[Tiger] improve the process of gimbal nominal angles in early takeoff…
tongtybj Aug 5, 2022
61a11f6
[Tiger] select the control term for joint torque restraint. Only sele…
tongtybj Aug 6, 2022
d529b37
[Spider][Flight] configuration for good hovering and transform
tongtybj Aug 5, 2022
2188c0d
[Servo Bridge] fix bug: remove a hard-coding debug line
tongtybj Dec 6, 2022
fb61c00
[Spider] rename and update the script to replay rosbag
tongtybj Dec 7, 2022
4747cc4
[Spider] final configuration for walk and flight
tongtybj Dec 9, 2022
73e7340
[Spider][Navigate][Joy] add joy cmd for stand and sit
tongtybj Dec 16, 2022
e41978f
[Spider] rename all directories and files from "tiger" to "spider"
tongtybj Dec 25, 2022
fdcb9c3
[Spidar] rename all directories and files from "spider" to "spidar"
tongtybj Apr 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace aerial_robot_control
virtual void sendCmd();


void cfgPidCallback(aerial_robot_control::PidControlConfig &config, uint32_t level, std::vector<int> controller_indices);
virtual void cfgPidCallback(aerial_robot_control::PidControlConfig &config, uint32_t level, std::vector<int> controller_indices);
};

};
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ namespace aerial_robot_navigation

virtual void rosParamInit();
void naviCallback(const aerial_robot_msgs::FlightNavConstPtr & msg);
void joyStickControl(const sensor_msgs::JoyConstPtr & joy_msg);
virtual void joyStickControl(const sensor_msgs::JoyConstPtr & joy_msg);
void batteryCheckCallback(const std_msgs::Float32ConstPtr &msg);

virtual void halt() {}
Expand Down Expand Up @@ -326,7 +326,7 @@ namespace aerial_robot_navigation
if(!estimator_->getStateStatus(State::Z_BASE, estimate_mode_))
{
ROS_ERROR("Flight Navigation: No correct sensor fusion for z(altitude), can not fly");
return;
// return;
}

for(const auto& handler: estimator_->getGpsHandlers())
Expand Down Expand Up @@ -403,6 +403,15 @@ namespace aerial_robot_navigation

if(!teleop_flag_) return;

if(getNaviState() < ARM_ON_STATE) return;

if(getNaviState() == ARM_ON_STATE)
{
setNaviState(STOP_STATE);
ROS_ERROR("not land, but disarm motors directly");
return;
}

setNaviState(LAND_STATE);

setTargetXyFromCurrentState();
Expand Down
2 changes: 2 additions & 0 deletions aerial_robot_control/src/control/pose_linear_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ namespace aerial_robot_control
pid_controllers_.at(Z).setLimitP(0); // no p control in final safe landing phase
final_landing_phase = true;
}

if(err_z > 0) err_z = 0; // avoid unexpected ascending because of increase in I term
}

if(navigator_->getForceLandingFlag())
Expand Down
42 changes: 22 additions & 20 deletions aerial_robot_control/src/flight_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ void BaseNavigator::joyStickControl(const sensor_msgs::JoyConstPtr & joy_msg)
if(getNaviState() == LAND_STATE) return;
if(!teleop_flag_) return; /* can not do the process if other processs are running */

if(getNaviState() == ARM_ON_STATE)
{
setNaviState(STOP_STATE);
ROS_ERROR("Joy Conrol: not land, but disarm motors directly");
return;
}

setNaviState(LAND_STATE);
//update
setTargetXyFromCurrentState();
Expand Down Expand Up @@ -607,11 +614,13 @@ void BaseNavigator::update()
if(estimator_->getUnhealthLevel() == Sensor::UNHEALTH_LEVEL3 && !force_landing_flag_)
{
if(getNaviState() == TAKEOFF_STATE || getNaviState() == HOVER_STATE || getNaviState() == LAND_STATE)
ROS_WARN("Sensor Unhealth Level%d: force landing state", estimator_->getUnhealthLevel());
spinal::FlightConfigCmd flight_config_cmd;
flight_config_cmd.cmd = spinal::FlightConfigCmd::FORCE_LANDING_CMD;
flight_config_pub_.publish(flight_config_cmd);
force_landing_flag_ = true;
{
ROS_WARN("Sensor Unhealth Level%d: force landing state", estimator_->getUnhealthLevel());
spinal::FlightConfigCmd flight_config_cmd;
flight_config_cmd.cmd = spinal::FlightConfigCmd::FORCE_LANDING_CMD;
flight_config_pub_.publish(flight_config_cmd);
force_landing_flag_ = true;
}
}

if(getNaviState() == TAKEOFF_STATE || getNaviState() == HOVER_STATE)
Expand Down Expand Up @@ -705,24 +714,17 @@ void BaseNavigator::update()
//for estimator landing mode
estimator_->setLandingMode(true);

if (getNaviState() > START_STATE)
{
if (fabs(delta.z()) > z_convergent_thresh_) convergent_start_time_ = ros::Time::now().toSec();
if (fabs(delta.z()) > z_convergent_thresh_) convergent_start_time_ = ros::Time::now().toSec();

if (ros::Time::now().toSec() - convergent_start_time_ > convergent_duration_)
{
convergent_start_time_ = ros::Time::now().toSec();
if (ros::Time::now().toSec() - convergent_start_time_ > convergent_duration_)
{
convergent_start_time_ = ros::Time::now().toSec();

ROS_ERROR("disarm motors");
setNaviState(STOP_STATE);
ROS_ERROR("disarm motors");
setNaviState(STOP_STATE);

setTargetXyFromCurrentState();
setTargetYawFromCurrentState();
}
}
else
{
setNaviState(ARM_OFF_STATE);
setTargetXyFromCurrentState();
setTargetYawFromCurrentState();
}
break;
}
Expand Down
8 changes: 8 additions & 0 deletions aerial_robot_estimation/src/state_estimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ void StateEstimator::initialize(ros::NodeHandle nh, ros::NodeHandle nh_private,
void StateEstimator::statePublish(const ros::TimerEvent & e)
{
ros::Time imu_stamp = boost::dynamic_pointer_cast<sensor_plugin::Imu>(imu_handlers_.at(0))->getStamp();

if (imu_stamp.toSec() == 0)
{
// use the ros time now
imu_stamp = ros::Time::now();
}


aerial_robot_msgs::States full_state;
full_state.header.stamp = imu_stamp;

Expand Down
36 changes: 30 additions & 6 deletions aerial_robot_model/include/aerial_robot_model/servo_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,15 @@ class SingleServoHandle

inline void setCurrTorqueVal(const double& val)
{
curr_torque_val_ = torque_scale_ * angle_sgn_ * val;
curr_torque_val_ = torque_scale_ * angle_sgn_ * val;
}

inline void setTargetTorqueVal(const double& val)
{
target_torque_val_ = val;
}


inline void setName(const string& name){ name_ = name; }
inline void setId(const int& id){ id_ = id; }
inline void setAngleSgn(const int& sgn){ angle_sgn_ = sgn; }
Expand Down Expand Up @@ -162,6 +168,19 @@ class SingleServoHandle
return curr_torque_val_;
}

inline const double getTargetTorqueVal(int value_type) const
{
if(value_type == ValueType::BIT)
{
return target_torque_val_ * angle_sgn_ / torque_scale_;
}
else // Nm
{
return target_torque_val_;
}
}


inline const string& getName(){return name_; }
inline const int& getId() const {return id_; }
inline const int& getAngleSgn() const {return angle_sgn_; }
Expand All @@ -175,6 +194,7 @@ class SingleServoHandle
double curr_angle_val_; // radian
double target_angle_val_; // radian
double curr_torque_val_; // Nm
double target_torque_val_; // Nm
int angle_sgn_;
int zero_point_offset_;
double angle_scale_;
Expand All @@ -201,11 +221,14 @@ class ServoBridge
ros::Publisher servo_states_pub_;
map<string, ros::Subscriber> servo_states_subs_;
map<string, ros::Subscriber> servo_ctrl_subs_;
map<string, ros::Subscriber> servo_torque_ctrl_subs_;
map<string, ros::Subscriber> servo_torque_subs_;
map<string, bool> no_real_state_flags_;
map<string, ros::Publisher> servo_ctrl_pubs_;
map<string, ros::ServiceServer> servo_torque_ctrl_srvs_;
map<string, ros::Publisher> servo_torque_ctrl_pubs_;
map<string, vector<ros::Publisher> > servo_ctrl_sim_pubs_; // TODO: should be actionlib, trajectory controller
map<string, ros::Publisher> servo_target_pos_pubs_;
map<string, ros::Publisher> servo_target_torque_pubs_;
map<string, ros::ServiceServer> servo_enable_srvs_;
map<string, ros::Publisher> servo_enable_pubs_;
map<string, vector<ros::Publisher> > servo_target_pos_sim_pubs_; // TODO: should be actionlib, trajectory controller

map<string, ServoGroupHandler> servos_handler_;
double moving_check_rate_;
Expand All @@ -216,7 +239,8 @@ class ServoBridge

void servoStatesCallback(const spinal::ServoStatesConstPtr& state_msg, const std::string& servo_group_name);
void servoCtrlCallback(const sensor_msgs::JointStateConstPtr& joints_ctrl_msg, const std::string& servo_group_name);
bool servoTorqueCtrlCallback(std_srvs::SetBool::Request &req, std_srvs::SetBool::Response &res, const std::string& servo_group_name);
void servoTorqueCtrlCallback(const sensor_msgs::JointStateConstPtr& joints_ctrl_msg, const std::string& servo_group_name);
bool servoEnableCallback(std_srvs::SetBool::Request &req, std_srvs::SetBool::Response &res, const std::string& servo_group_name);

public:
ServoBridge(ros::NodeHandle nh, ros::NodeHandle nhp);
Expand Down
Loading