Skip to content

Commit

Permalink
change jointdata to suspedata
Browse files Browse the repository at this point in the history
  • Loading branch information
qiayuanl committed Mar 7, 2020
1 parent 1f1818d commit 66756f3
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ find_package(catkin REQUIRED COMPONENTS
)
add_message_files(
FILES
JointData.msg
SuspeData.msg
)

generate_messages(
Expand Down
7 changes: 0 additions & 7 deletions config/sim_param.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
################################SimParams###########################
dynamics_dt: 0.00001
control_dt: 0.001
home_kp_lin: 2500
home_kd_lin: 300
home_kp_ang: 250
home_kd_ang: 60
use_spring_damper: false
go_home: false

#floating point value in table should define with decimal point
home_pos: [0.,0.,.5]
home_rpy: [0.,0.,0.]

###############################SuspeParams##########################
#Note: all params should be defined at frame on suspension/wheel 0
Expand Down
6 changes: 3 additions & 3 deletions include/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
#include <tf/transform_broadcaster.h>
#include <rosbag/bag.h>
#include <geometry_msgs/Twist.h>
#include <rm_suspension/JointData.h>
#include <rm_suspension/SuspeData.h>

struct VisData {
Quat<double> tfQuat[9];
Vec3<double> tfPos[9];
vector<Vec3<double >> cpPos;
vector<Vec3<double>> cpForce;
geometry_msgs::Twist baseMsg;
rm_suspension::JointData jointData;
rm_suspension::SuspeData suspeData;
};

/*!
Expand Down Expand Up @@ -74,7 +74,7 @@ class Simulation {
ros::NodeHandle nh_;
ros::Publisher markerPub_;
ros::Publisher twistPub_;
ros::Publisher jointPub_;
ros::Publisher suspePub_;
visualization_msgs::Marker marker_;
tf::TransformBroadcaster br_;

Expand Down
2 changes: 1 addition & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SimParameters {

nh->param<double>("dynamics_dt", dynamics_dt_, 0.00001);
nh->param<double>("control_dt", control_dt_, 0.001);
nh->param<double>("vis_fps", vis_fps_, 250);
nh->param<double>("vis_fps", vis_fps_, 1000);
nh->param<double>("floor_kp", floor_kp_, 5000);
nh->param<double>("floor_kd", floor_kd_, 500000);
nh->param<double>("home_kp_lin", home_kp_lin_, 2500);
Expand Down
5 changes: 0 additions & 5 deletions msg/JointData.msg

This file was deleted.

4 changes: 4 additions & 0 deletions msg/SuspeData.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
float64[4] spring_length
float64[4] qd_wheel
float64[4] tau_suspe
float64[4] cp_force
2 changes: 1 addition & 1 deletion src/Dynamics/Chassis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ FloatingBaseModel<T> Chassis<T>::buildModel() {
model.addGroundContactPoint
(bodyID,
Vec3<T>(_params._wheelRadius * sin(angle), 0, _params._wheelRadius * cos(angle)),
true);
false);
}
//TODO add rfid contact point
}
Expand Down
28 changes: 16 additions & 12 deletions src/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Simulation::Simulation()
sleep(1);
}
twistPub_ = nh_.advertise<geometry_msgs::Twist>("base_twist", 100);
jointPub_ = nh_.advertise<rm_suspension::JointData>("joint_data", 100);
suspePub_ = nh_.advertise<rm_suspension::SuspeData>("suspe_data", 100);

// init parameters
printf("[Simulation] Load parameters...\n");
Expand Down Expand Up @@ -224,14 +224,18 @@ void Simulation::record() {
//////////////////////////record contact force data///////////////////////////////
int _nTotalGC = simulator_->getTotalNumGC();
int count = 0;
for (size_t i(0); i < _nTotalGC; ++i) {
for (int i = 0; i < _nTotalGC; ++i) {
Vec3<double> f = simulator_->getContactForce(i);
vis_data.cpForce.push_back(f);
vis_data.cpPos.push_back(simulator_->getModel()._pGC[i]);
count++;
if (f.norm() > .0001 && f.norm() < 1000.) {
vis_data.cpForce.push_back(f);
vis_data.cpPos.push_back(simulator_->getModel()._pGC[i]);
count++;
if (count < 4) {
vis_data.suspeData.cp_force[count] = f.norm();
}
}
}
vis_data.jointData.cp_count = count;
///////////////////////////////record base twist and joint data for plot//////////////////////////
///////////////////////////////record base twist and suspe data for plot//////////////////////////
vis_data.baseMsg.linear.x = vis_data.tfPos[0].x();
vis_data.baseMsg.linear.y = vis_data.tfPos[0].y();
vis_data.baseMsg.linear.z = vis_data.tfPos[0].z();
Expand All @@ -240,10 +244,9 @@ void Simulation::record() {
vis_data.baseMsg.angular.y = rpy.y();
vis_data.baseMsg.angular.z = rpy.z();
for (int wheelID = 0; wheelID < 4; ++wheelID) {
vis_data.jointData.q_suspe[wheelID] = fakeSuspe_.getSpringLength(wheelID);
vis_data.jointData.qd_suspe[wheelID] = simulator_->getState().qd[wheelID * 2];
vis_data.jointData.tau_suspe[wheelID] = tau_[wheelID * 2];
vis_data.jointData.qd_wheel[wheelID] = simulator_->getState().qd[wheelID * 2 + 1];
vis_data.suspeData.spring_length[wheelID] = fakeSuspe_.getSpringLength(wheelID);
vis_data.suspeData.tau_suspe[wheelID] = tau_[wheelID * 2];
vis_data.suspeData.qd_wheel[wheelID] = simulator_->getState().qd[wheelID * 2 + 1];
}

visData_.push_back(vis_data);
Expand Down Expand Up @@ -310,6 +313,7 @@ void Simulation::sendCP(const vector<VisData>::iterator &iter, double scale) {
marker.color.a = 1.0; // Don't forget to set the alpha!
marker.color.g = 1.0;
marker.scale.x = .01;

marker.pose.orientation.w = 1;
marker.id = 5; //large enough to avoid cover marker create at set up
marker.type = visualization_msgs::Marker::LINE_LIST;
Expand Down Expand Up @@ -339,7 +343,7 @@ void Simulation::sendCP(const vector<VisData>::iterator &iter, double scale) {

void Simulation::sendMsg(const vector<VisData>::iterator &iter) {
twistPub_.publish(iter->baseMsg);
jointPub_.publish(iter->jointData);
suspePub_.publish(iter->suspeData);
}
void Simulation::clearCollision() {
visualization_msgs::Marker marker;
Expand Down

0 comments on commit 66756f3

Please sign in to comment.