Update of /cvsroot/robotflow/RobotFlow/Devices/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22524
Modified Files:
SNCRZ30RS232.cc
Log Message:
testing pan -tilt abs positions
Index: SNCRZ30RS232.cc
===================================================================
RCS file: /cvsroot/robotflow/RobotFlow/Devices/src/SNCRZ30RS232.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** SNCRZ30RS232.cc 8 Jul 2005 19:58:14 -0000 1.6
--- SNCRZ30RS232.cc 19 Sep 2005 13:38:43 -0000 1.7
***************
*** 523,561 ****
{
!
! //cerr<<"Abs pan "<<pan_position<<" Abs tilt "<<tilt_position<<endl;
!
! string message;
! string last;
! int Sep1 = 0x000F;
! int Sep2 = 0x00F0;
! int Sep3 = 0x0F00;
! int Sep4 = 0xF000;
!
! message += 0x81;
! message += 0x01;
! message += 0x06;
! message += 0x02;
!
! message += max(0,min(pan_speed,24));
! message += max(0,min(tilt_speed,20));
!
pan_position = max(min(pan_position,1700), -1700);
tilt_position = max(min(tilt_position,425), -725);
! message += (Sep4 & pan_position)>>12;
! message += (Sep3 & pan_position)>>8;
! message += (Sep2 & pan_position)>>4;
! message += (Sep1 & pan_position);
!
! message += (Sep4 & tilt_position)>>12;
! message += (Sep3 & tilt_position)>>8;
! message += (Sep2 & tilt_position)>>4;
! message += (Sep1 & tilt_position);
!
! message += 0xFF;
!
// add it to the list
! Add_message_to_send(message,false);
}
--- 523,564 ----
{
! //LIMIT PAN & TILT SPEED VALUES
! pan_speed = max(0,min(pan_speed,24));
! tilt_speed = max(0,min(tilt_speed,20));
pan_position = max(min(pan_position,1700), -1700);
tilt_position = max(min(tilt_position,425), -725);
! //CREATE VISCA COMMAND
! ostringstream my_stream;
! static const unsigned int mask1 = 0x000F;
! static const unsigned int mask2 = 0x00F0;
! static const unsigned int mask3 = 0x0F00;
! static const unsigned int mask4 = 0xF000;
! //header
! my_stream << 0x81;
! my_stream << 0x01;
! my_stream << 0x06;
! my_stream << 0x02;
! //pan & tilt speeds
! my_stream << std::hex<<((mask2 & pan_speed)>>4);//pan speed
! my_stream << std::hex<<((mask1 & pan_speed));
!
! my_stream << std::hex<<((mask2 & tilt_speed)>>4);//tilt speed
! my_stream << std::hex<<((mask1 & tilt_speed));
! //pan & tilt commands
! my_stream << "0"<<std::hex<<((mask4 & pan_position)>>12); //pan position
! my_stream << "0"<<std::hex<<((mask3 & pan_position)>>8);
! my_stream << "0"<<std::hex<<((mask2 & pan_position)>>4);
! my_stream << "0"<<std::hex<<((mask1 & pan_position));
!
! my_stream << "0"<<std::hex<<((mask4 & tilt_position)>>12); //tilt position
! my_stream << "0"<<std::hex<<((mask3 & tilt_position)>>8);
! my_stream << "0"<<std::hex<<((mask2 & tilt_position)>>4);
! my_stream << "0"<<std::hex<<((mask1 & tilt_position));
!
! my_stream << "FF\r\n"; //end message
!
// add it to the list
! Add_message_to_send(my_stream.str(),false);
}
|