10 #include <boost/bind.hpp> 11 #include <hrpModel/Sensor.h> 12 #include "hrpsys/util/GLcamera.h" 13 #include "hrpsys/util/GLlink.h" 14 #include "hrpsys/util/GLbody.h" 15 #include "hrpsys/util/LogManager.h" 52 for (
unsigned int i=0;
i<strlen(str);
i++){
53 glutBitmapCharacter(GLUT_BITMAP_8_BY_13, str[
i]);
68 const std::vector<CollisionInfo> &cs = state.
collisions;
69 for (
unsigned int i=0;
i<cs.size();
i++){
70 for (
int k=0; k<3; k++){
71 e[k] = cs[
i].position[k] + cs[
i].normal[k]*(cs[
i].idepth*10+0.1);
98 #define HEIGHT_STEP 12 112 glRasterPos2f(width, height);
117 if (bstate->
acc.size()){
118 glRasterPos2f(width, height);
121 for (
unsigned int i=0;
i<bstate->
acc.size();
i++){
122 sprintf(buf,
" %8.4f %8.4f %8.4f",
123 bstate->
acc[
i][0], bstate->
acc[
i][1], bstate->
acc[
i][2]);
124 glRasterPos2f(width, height);
129 if (bstate->
rate.size()){
130 glRasterPos2f(width, height);
133 for (
unsigned int i=0;
i<bstate->
rate.size();
i++){
134 sprintf(buf,
" %8.4f %8.4f %8.4f",
136 glRasterPos2f(width, height);
141 if (bstate->
force.size()){
142 glRasterPos2f(width, height);
145 for (
unsigned int i=0;
i<bstate->
force.size();
i++){
146 sprintf(buf,
" %6.1f %6.1f %6.1f %6.2f %6.2f %6.2f",
153 glRasterPos2f(width, height);
158 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
160 glColor4f(0.0,0.0,0.0, 0.5);
180 <<
") for " << body->
name() << std::endl;
187 const std::vector<double> distances = state.
range[sensor->
id];
188 if (distances.empty())
return;
193 glDisable(GL_LIGHTING);
196 for (
int i = -scan_half,
j=0;
i<= scan_half;
i++,
j++){
201 glVertex3f(0,0,0); glVertex3f(v[0], v[1], v[2]);
204 glEnable(GL_LIGHTING);
205 }
else if(sensor->
type == Sensor::VISION){
207 double far = v->
far, near = v->
near;
208 glDisable(GL_LIGHTING);
211 double t = tan(v->
fovy/2);
213 glVertex3f( xf, yf, -far); glVertex3f(-xf, yf, -far);
214 glVertex3f(-xf, yf, -far); glVertex3f(-xf, -yf, -far);
215 glVertex3f(-xf, -yf, -far); glVertex3f( xf, -yf, -far);
216 glVertex3f( xf, -yf, -far); glVertex3f( xf, yf, -far);
217 double xn = t*near*v->
width/v->
height, yn = t*near;
218 glVertex3f( xn, yn, -near); glVertex3f(-xn, yn, -near);
219 glVertex3f(-xn, yn, -near); glVertex3f(-xn, -yn, -near);
220 glVertex3f(-xn, -yn, -near); glVertex3f( xn, -yn, -near);
221 glVertex3f( xn, -yn, -near); glVertex3f( xn, yn, -near);
222 glVertex3f( xn, yn, -near); glVertex3f( xf, yf, -far);
223 glVertex3f(-xn, yn, -near); glVertex3f(-xf, yf, -far);
224 glVertex3f(-xn, -yn, -near); glVertex3f(-xf, -yf, -far);
225 glVertex3f( xn, -yn, -near); glVertex3f( xf, -yf, -far);
228 || v->
imageType == VisionSensor::COLOR_DEPTH
229 || v->
imageType == VisionSensor::MONO_DEPTH){
230 bool colored = v->
imageType == VisionSensor::COLOR_DEPTH;
234 glVertex3f(ptr[0], ptr[1], ptr[2]);
237 unsigned char *rgb = (
unsigned char *)ptr;
238 glColor3f(rgb[0]/255.0, rgb[1]/255.0, rgb[2]/255.0);
247 glEnable(GL_LIGHTING);
int bodyIndex(const std::string &name)
std::vector< hrp::Vector3 > acc
void drawAdditionalLines()
static void drawString2(const char *str)
std::vector< CollisionInfo > collisions
png_infop png_uint_32 * width
GLbody * body(unsigned int i_rank)
png_infop png_uint_32 png_uint_32 * height
def j(str, encoding="cp932")
const std::string & name()
std::vector< std::vector< double > > range
unsigned int numBodies() const
Link * joint(int id) const
Link * link(int index) const
std::vector< hrp::Vector3 > rate
void drawSensorOutput(hrp::Body *i_body, hrp::Sensor *i_sensor)
std::vector< unsigned char > depth
void setPosture(const double *i_angles)
std::string sprintf(char const *__restrict fmt,...)
unsigned int numJoints() const
std::vector< BodyState > bodyStates
std::vector< hrp::dvector6, Eigen::aligned_allocator< hrp::dvector6 > > force
unsigned int numLinks() const
#define SLIDER_AREA_HEIGHT
void setSensorDrawCallback(boost::function2< void, hrp::Body *, hrp::Sensor * > f)